From 2b9b6fb677229c4af646ae9392c00ad664f66a11 Mon Sep 17 00:00:00 2001 From: AdrySky Date: Thu, 4 Aug 2022 10:47:01 +0800 Subject: [PATCH] Able to delete multiple node at once --- src/commands/NodeActionCommands.tsx | 35 ++++++++++++++++------------- 1 file changed, 19 insertions(+), 16 deletions(-) diff --git a/src/commands/NodeActionCommands.tsx b/src/commands/NodeActionCommands.tsx index 0d16a839..8a5b8398 100644 --- a/src/commands/NodeActionCommands.tsx +++ b/src/commands/NodeActionCommands.tsx @@ -607,28 +607,31 @@ export function addNodeActionCommands( // When no node selected, just return return; } - if (node.getOptions()["name"] !== "undefined") { - let modelName = node.getOptions()["name"]; - const errorMsg = `${modelName} node cannot be deleted!` - if (modelName !== 'Start' && modelName !== 'Finish') { - if (!node.isLocked()) { - node.remove() - } else { + const selectedEntities = widget.xircuitsApp.getDiagramEngine().getModel().getSelectedEntities(); + selectedEntities.forEach((node) => { + if (node.getOptions()["name"] !== "undefined") { + let modelName = node.getOptions()["name"]; + const errorMsg = `${modelName} node cannot be deleted!` + if (modelName !== 'Start' && modelName !== 'Finish') { + if (!node.isLocked()) { + node.remove() + } else { + showDialog({ + title: 'Locked Node', + body: errorMsg, + buttons: [Dialog.warnButton({ label: 'OK' })] + }); + } + } + else { showDialog({ - title: 'Locked Node', + title: 'Undeletable Node', body: errorMsg, buttons: [Dialog.warnButton({ label: 'OK' })] }); } } - else { - showDialog({ - title: 'Undeletable Node', - body: errorMsg, - buttons: [Dialog.warnButton({ label: 'OK' })] - }); - } - } + }) widget.xircuitsApp.getDiagramEngine().repaintCanvas(); } }