diff --git a/src/simple-flowchart/components/SimpleFlowchart.vue b/src/simple-flowchart/components/SimpleFlowchart.vue index 6236f4f..716dabf 100644 --- a/src/simple-flowchart/components/SimpleFlowchart.vue +++ b/src/simple-flowchart/components/SimpleFlowchart.vue @@ -225,7 +225,6 @@ export default { this.draggingLink = null; } if (typeof target.className === 'string' && target.className.indexOf('node-delete') > -1) { - // console.log('delete2', this.action.dragging); this.nodeDelete(this.action.dragging); this.action.dragging = null; } @@ -261,13 +260,17 @@ export default { })); }, nodeDelete(id) { + const deleted_node = this.scene.nodes.find((node) => node.id === id); + console.log(deleted_node); + this.scene.nodes = this.scene.nodes.filter((node) => { return node.id !== id; }) + this.scene.links = this.scene.links.filter((link) => { return link.from !== id && link.to !== id - }) - this.$emit('nodeDelete', id) + }); + this.$emit('nodeDelete', deleted_node); }, dataUpdated(id, newData) { this.$emit('nodeDataEdited', id, newData); diff --git a/src/views/Dashboard.vue b/src/views/Dashboard.vue index adb5f74..c05f267 100644 --- a/src/views/Dashboard.vue +++ b/src/views/Dashboard.vue @@ -49,7 +49,7 @@ export default { pendingChanges: { created: [], updated: [], - deleted: [] + deleted: [] // Stores apiId instead of localId }, model: { centerX: 0, @@ -101,7 +101,7 @@ export default { }, // Vuejs can not track changes of a set, so we do this magic hack to fix it - enqueuePendingNodeDeletion(id) { + enqueuePendingNodeDeletion({id, apiId}) { let pending_deletes = new Set(this.pendingChanges.deleted); let pending_updates = new Set(this.pendingChanges.updated); let pending_creations = new Set(this.pendingChanges.created); @@ -110,7 +110,9 @@ export default { if (pending_creations.has(id)) { pending_creations.delete(id); } else { - pending_deletes.add(id); + if (apiId) { + pending_deletes.add(apiId); + } } pending_updates.delete(id); @@ -133,7 +135,7 @@ export default { handleNodeMove() { // TODO }, - handleLinkBreak({from,to}) { + handleLinkBreak({from, to}) { this.enqueuePendingNodeUpdate(from); this.enqueuePendingNodeUpdate(to); },