mirror of
https://github.com/hexastack/hexabot
synced 2024-11-24 04:53:41 +00:00
refactor: ids to be array by default
This commit is contained in:
parent
ee024afa05
commit
09b3201949
@ -71,7 +71,7 @@ const Diagrams = () => {
|
|||||||
const [engine, setEngine] = useState<DiagramEngine | undefined>();
|
const [engine, setEngine] = useState<DiagramEngine | undefined>();
|
||||||
const [canvas, setCanvas] = useState<JSX.Element | undefined>();
|
const [canvas, setCanvas] = useState<JSX.Element | undefined>();
|
||||||
const [selectedBlockId, setSelectedBlockId] = useState<string | undefined>();
|
const [selectedBlockId, setSelectedBlockId] = useState<string | undefined>();
|
||||||
const deleteDialogCtl = useDialog<string>(false);
|
const deleteDialogCtl = useDialog<string[]>(false);
|
||||||
const moveDialogCtl = useDialog<string[] | string>(false);
|
const moveDialogCtl = useDialog<string[] | string>(false);
|
||||||
const addCategoryDialogCtl = useDialog<ICategory>(false);
|
const addCategoryDialogCtl = useDialog<ICategory>(false);
|
||||||
const { mutateAsync: updateBlocks } = useUpdateMany(EntityType.BLOCK);
|
const { mutateAsync: updateBlocks } = useUpdateMany(EntityType.BLOCK);
|
||||||
@ -198,7 +198,7 @@ const Diagrams = () => {
|
|||||||
setter: setSelectedBlockId,
|
setter: setSelectedBlockId,
|
||||||
updateFn: updateBlock,
|
updateFn: updateBlock,
|
||||||
onRemoveNode: (ids, next) => {
|
onRemoveNode: (ids, next) => {
|
||||||
deleteDialogCtl.openDialog(ids.join(","));
|
deleteDialogCtl.openDialog(ids);
|
||||||
deleteCallbackRef.current = next;
|
deleteCallbackRef.current = next;
|
||||||
},
|
},
|
||||||
onDbClickNode: (event, id) => {
|
onDbClickNode: (event, id) => {
|
||||||
@ -459,7 +459,7 @@ const Diagrams = () => {
|
|||||||
});
|
});
|
||||||
engine?.repaintCanvas();
|
engine?.repaintCanvas();
|
||||||
};
|
};
|
||||||
deleteDialogCtl.openDialog(ids.join(","));
|
deleteDialogCtl.openDialog(ids);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
const handleMoveButton = () => {
|
const handleMoveButton = () => {
|
||||||
@ -471,18 +471,17 @@ const Diagrams = () => {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
const onDelete = async () => {
|
const onDelete = async () => {
|
||||||
const id = deleteDialogCtl?.data;
|
const ids = deleteDialogCtl?.data;
|
||||||
|
|
||||||
if (!id) {
|
if (!ids || ids?.length === 0) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const isLink = id.length === 36;
|
const isLink = ids[0].length === 36;
|
||||||
const listIds = id.split(",");
|
|
||||||
|
|
||||||
if (isLink) {
|
if (isLink) {
|
||||||
await handleLinkDeletion(listIds[0]);
|
await handleLinkDeletion(ids[0]);
|
||||||
} else {
|
} else {
|
||||||
await handleBlockDeletion(listIds);
|
await handleBlockDeletion(ids);
|
||||||
}
|
}
|
||||||
|
|
||||||
cleanupAfterDeletion();
|
cleanupAfterDeletion();
|
||||||
|
Loading…
Reference in New Issue
Block a user