From 4bff05a1c60d3c49a1bfe93d76363f7ba31e2f5e Mon Sep 17 00:00:00 2001 From: proddy Date: Mon, 8 Jun 2026 21:22:59 +0200 Subject: [PATCH] have to save before executing --- interface/src/app/main/CommandsDialog.tsx | 36 +++++++++++++++++------ 1 file changed, 27 insertions(+), 9 deletions(-) diff --git a/interface/src/app/main/CommandsDialog.tsx b/interface/src/app/main/CommandsDialog.tsx index 1d71995cc..ac8dd74ea 100644 --- a/interface/src/app/main/CommandsDialog.tsx +++ b/interface/src/app/main/CommandsDialog.tsx @@ -46,6 +46,7 @@ const CommandsDialog = ({ validator }: CommandsDialogProps) => { const { LL } = useI18nContext(); + const [hasChanges, setHasChanges] = useState(false); const [editItem, setEditItem] = useState(selectedItem); const [fieldErrors, setFieldErrors] = useState(); @@ -62,6 +63,17 @@ const CommandsDialog = ({ } }, [open, selectedItem]); + const hasChanged = (ci: CommandItem) => + ci.id !== ci.o_id || + (ci.name || '') !== (ci.o_name || '') || + ci.cmd !== ci.o_cmd || + ci.value !== ci.o_value || + ci.deleted !== ci.o_deleted; + + useEffect(() => { + setHasChanges(hasChanged(editItem)); + }, [editItem]); + const handleSave = async (itemToSave: CommandItem) => { try { setFieldErrors(undefined); @@ -69,6 +81,8 @@ const CommandsDialog = ({ onSave(itemToSave); } catch (error) { setFieldErrors((error as ValidationError).fieldErrors); + } finally { + setHasChanges(false); } }; @@ -162,15 +176,19 @@ const CommandsDialog = ({ > {LL.CANCEL()} - - {!creating && editItem.cmd !== '' && ( + + {hasChanges && ( + + )} + + {!creating && !hasChanges && editItem.cmd !== '' && (