Changed deleted local ids to api ids
This commit is contained in:
parent
4ff230007c
commit
b6cf9d2ed5
@ -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);
|
||||
|
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user