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

Somewhat implemented storing data in graph on collective change

parent c8a34221
No related branches found
No related tags found
No related merge requests found
Pipeline #52768 passed
......@@ -203,19 +203,27 @@ export class Graph extends ManagedData {
return false;
}
changeDetails(selectionDetails) {
changeDetails(selectionDetails, storeChange = true) {
if (selectionDetails.node === true) {
this.changeNodeDetails(selectionDetails[NODE_ID], selectionDetails);
this.changeNodeDetails(selectionDetails[NODE_ID], selectionDetails, storeChange);
} else if (selectionDetails.link === true) {
this.changeLinkDetails(
selectionDetails[LINK_SOURCE][NODE_ID],
selectionDetails[LINK_TARGET][NODE_ID],
selectionDetails
selectionDetails,
storeChange
);
}
}
changeNodeDetails(nodeId, newDetails) {
changeDetailsOfCollection(collection) {
collection.forEach((el) => {
this.changeDetails(el, false);
});
this.storeCurrentData("Changed details of collection");
}
changeNodeDetails(nodeId, newDetails, storeChange = true) {
var nodes = this.data[GRAPH_NODES];
for (var i = 0; i < nodes.length; i++) {
// Is relevant node?
......@@ -226,13 +234,17 @@ export class Graph extends ManagedData {
// Change details
nodes[i] = Object.assign(nodes[i], newDetails);
// All done
this.storeCurrentData("Changed node details");
if (storeChange) {
this.storeCurrentData("Changed node details");
}
return;
}
}
changeLinkDetails(sourceId, targetId, newDetails) {
changeLinkDetails(sourceId, targetId, newDetails, storeChange = true) {
var links = this.data[GRAPH_LINKS];
for (var i = 0; i < links.length; i++) {
// Is relevant link?
......@@ -246,8 +258,12 @@ export class Graph extends ManagedData {
// Change details
links[i] = Object.assign(links[i], newDetails);
// All done
this.storeCurrentData("Changed link details");
if (storeChange) {
this.storeCurrentData("Changed link details");
}
return;
}
}
......
......@@ -20,8 +20,16 @@ export default class CollectTool extends Tool {
}
onMenuChange(key, value) {
if (key === COLLECTION_KEY) {
graph.changeDetails(value);
if (key !== COLLECTION_KEY) {
return;
}
if (value === undefined) {
// Clear items if menue says its empty
state.clearSelectedItems();
this.menu.value(COLLECTION_KEY, []);
} else {
graph.changeDetailsOfCollection(value);
}
}
......@@ -89,13 +97,6 @@ export default class CollectTool extends Tool {
this.menu.value(COLLECTION_KEY, state.selectedItems);
}
onMenuChange(key, value) {
if (key === COLLECTION_KEY && value === undefined) {
state.clearSelectedItems();
this.menu.value(COLLECTION_KEY, []);
}
}
setupBoxSelect() {
window.addEventListener("load", () => {
// Source: https://github.com/vasturiano/force-graph/issues/151#issuecomment-735850938
......
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