From 27664444a5d5ac37f4838961ac4c20154992637d Mon Sep 17 00:00:00 2001 From: Open TAK server Date: Mon, 27 Apr 2026 06:23:02 +0000 Subject: [PATCH] fix: reset Mission dialog title and warn on unsaved changes Addresses issues 1 and 2 of brian7704/OpenTAKServer-UI#180. - New Mission button now resets the dialog title back to "Add Mission" after the user has previously opened the Edit dialog. - Modal close (outside-click / ESC / x button) now opens a confirmation prompt when the form has unsaved changes, instead of discarding them silently. Issue 3 (password removal) needs a backend change in brian7704/OpenTAKServer mission_api.py and is out of scope for this PR. Co-Authored-By: Claude Opus 4.7 (1M context) --- src/pages/Missions.tsx | 27 +++++++++++++++++++-------- 1 file changed, 19 insertions(+), 8 deletions(-) diff --git a/src/pages/Missions.tsx b/src/pages/Missions.tsx index b197b81..165ba8e 100644 --- a/src/pages/Missions.tsx +++ b/src/pages/Missions.tsx @@ -58,6 +58,8 @@ export default function Missions() { const [addEditTitle, setAddEditTitle] = useState(t("Add Mission")); const [selectedGroups, setSelectedGroups] = useState([]); const [loading, setLoading] = useState(false); + const [isDirty, setIsDirty] = useState(false); + const [showUnsavedWarning, setShowUnsavedWarning] = useState(false); const [sortStatus, setSortStatus] = useState>({ columnAccessor: 'name', direction: 'asc', @@ -156,6 +158,7 @@ export default function Missions() { }); setShowAddMission(true); setAddEditTitle(t("Edit Mission")); + setIsDirty(false); let selected_groups: string[] = []; row.groups.map((group: any) => { selected_groups.push("" + group.id); @@ -397,9 +400,15 @@ export default function Missions() { - {setShowAddMission(false);}} title={addEditTitle}> - { missionProperties.name = e.target.value; }} mb="md" /> - { missionProperties.description = e.target.value; }} mb="md" /> + setShowUnsavedWarning(false)} title={t("Discard unsaved changes?")}> +
+ + +
+
+ { if (isDirty) { setShowUnsavedWarning(true); } else { setShowAddMission(false); } }} title={addEditTitle}> + { missionProperties.name = e.target.value; setIsDirty(true); }} mb="md" /> + { missionProperties.description = e.target.value; setIsDirty(true); }} mb="md" /> {setGroups(value)}} + onChange={(value) => { setGroups(value); setIsDirty(true); }} data={allGroups} />