implement renaming feature for vorgang

UI and backend logic
make ´NameItemEditor´ reusable to be able to use with Vorgang
This commit is contained in:
2025-11-20 09:46:28 +01:00
parent b3ba6256e0
commit b6996902cc
4 changed files with 139 additions and 30 deletions

View File

@@ -13,7 +13,8 @@
// props, old syntax
export let list: ListItem[] = [];
export let currentName: string;
export let onSave: (n: string, o: string) => unknown = () => {};
export let vorgangToken: string | null;
export let onSave: (n: string, o: string, t?: string) => unknown = () => {};
export let onDelete: (n: string) => unknown = () => {};
let localName = currentName;
@@ -43,8 +44,10 @@
}
function commitEdit() {
if (!error && localName != currentName) onSave(localName, currentName);
if (!error && localName != currentName) onSave(localName, currentName, vorgangToken);
// restore original value
if (error) { localName = currentName }
isEditing = false;
}
@@ -54,7 +57,8 @@
}
function handleDeleteClick() {
onDelete(currentName);
// vorgangToken defined when deleting Vorgang, otherwise Crime
onDelete(vorgangToken || currentName);
}
</script>