implement renaming feature for vorgang
UI and backend logic make ´NameItemEditor´ reusable to be able to use with Vorgang
This commit is contained in:
@@ -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>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user