Skip to content
Snippets Groups Projects
Commit 3a1890ec authored by Maximilian Giller's avatar Maximilian Giller :squid:
Browse files

Implemented deleting multiple nodes at once and disabling storing temporarily

parent 98337097
No related branches found
No related tags found
No related merge requests found
Pipeline #52781 passed
......@@ -117,7 +117,7 @@ export class Graph extends ManagedData {
var classIndex = this.nodeTypes.indexOf(typeClass);
if (classIndex <= -1) {
return 'black';
return "black";
}
return COLOR_PALETTE[classIndex % COLOR_PALETTE.length];
......@@ -139,6 +139,25 @@ export class Graph extends ManagedData {
this.storeCurrentData("Deleted node with id [" + nodeId + "]");
}
deleteNodes(nodeIds) {
if (nodeIds === undefined || nodeIds.length <= 0) {
return;
}
try {
this.disableStoring();
nodeIds.forEach((id) => {
this.deleteNode(id);
});
} finally {
// Gotta make sure that storing is turned back on again
this.enableStoring();
}
this.storeCurrentData("Deleted nodes with ids [" + nodeIds.join(",") + "]");
}
stopPhysics() {
this.data[GRAPH_NODES].forEach((n) => {
n.fx = n.x;
......
......@@ -8,6 +8,7 @@ export default class ManagedData {
this.history = []; // Newest state is always at 0
this.historyPosition = 0;
this.savedHistoryId = 0;
this.storingEnabled = true;
this.storeCurrentData("Initial state", false);
}
......@@ -39,6 +40,14 @@ export default class ManagedData {
this.updateUnsavedChangesHandler();
}
disableStoring() {
this.storingEnabled = false;
}
enableStoring() {
this.storingEnabled = true;
}
onUndo() {}
onRedo() {}
......@@ -83,6 +92,10 @@ export default class ManagedData {
}
storeCurrentData(description, relevantChanges = true) {
if (this.storingEnabled === false) {
return;
}
var formattedData = this.storableData(this.data);
var nextId = 0;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment