From 173904ca583719bc420f17b4f33e4084ca31dce5 Mon Sep 17 00:00:00 2001 From: Sipke Schoorstra Date: Mon, 30 Jan 2023 17:28:09 +0100 Subject: [PATCH] Fix copy-pasta of ID --- .../src/modules/flowchart/flowchart.tsx | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/src/designer/elsa-workflows-designer/src/modules/flowchart/flowchart.tsx b/src/designer/elsa-workflows-designer/src/modules/flowchart/flowchart.tsx index b0b4d2b55..f384bf78e 100644 --- a/src/designer/elsa-workflows-designer/src/modules/flowchart/flowchart.tsx +++ b/src/designer/elsa-workflows-designer/src/modules/flowchart/flowchart.tsx @@ -337,9 +337,9 @@ export class FlowchartComponent { graph.on('edge:connected', this.onEdgeConnected); graph.on('node:moved', this.onNodeMoved); - //graph.on('node:change:*', this.onGraphChanged); graph.on('node:moved', this.onGraphChanged); - graph.on('node:added', this.onGraphChanged); + //graph.on('node:added', this.onGraphChanged); + graph.on('node:added', this.onNodeAdded); graph.on('node:removed', this.onNodeRemoved); graph.on('node:removed', this.onGraphChanged); graph.on('edge:added', this.onGraphChanged); @@ -615,12 +615,19 @@ export class FlowchartComponent { this.activityDeleted.emit({activity}); }; + private onNodeAdded = async (e: any) => { + debugger; + const activity = e.node.data as Activity; + const activityDescriptor = this.getActivityDescriptor(activity.type); + activity.id = await this.generateUniqueActivityName(activityDescriptor) + e.node.activity = {...activity}; + await this.onGraphChanged(e); + }; + private onToggleCanStartWorkflowClicked = (node: ActivityNodeShape) => { const activity = node.data as Activity; activity.canStartWorkflow = !activity.canStartWorkflow; node.activity = {...activity}; - // this.onGraphChanged().then(_ => { - // }); }; private onDeleteActivityClicked = (node: ActivityNodeShape) => {