Skip to content

Commit

Permalink
ugurdogrusoz/visuall#347 fix overriding
Browse files Browse the repository at this point in the history
  • Loading branch information
canbax committed Feb 5, 2021
1 parent 17bc24e commit 1bcf335
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 7 deletions.
24 changes: 20 additions & 4 deletions cytoscape-expand-collapse.js

Large diffs are not rendered by default.

22 changes: 19 additions & 3 deletions src/saveLoadUtilities.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ function saveLoadUtilities(cy, api) {
let e = null;
if (existing.length > 0) {
if (isOverrideExisting) {
existing.json(json);
overrideJson2Elem(existing, json);
}
e = existing;
} else {
Expand Down Expand Up @@ -141,6 +141,22 @@ function saveLoadUtilities(cy, api) {
anchor.click();
}

function overrideJson2Elem(elem, json) {
const collapsedChildren = elem.data('collapsedChildren');
const collapsedEdges = elem.data('collapsedEdges');
const originalEnds = elem.data('originalEnds');
elem.json(json);
if (collapsedChildren) {
elem.data('collapsedChildren', collapsedChildren);
}
if (collapsedEdges) {
elem.data('collapsedEdges', collapsedEdges);
}
if (originalEnds) {
elem.data('originalEnds', originalEnds);
}
}

return {

/** Load elements from JSON formatted string representation.
Expand All @@ -165,7 +181,7 @@ function saveLoadUtilities(cy, api) {
let node = null;
if (existing.length > 0) {
if (isOverrideExisting) {
existing.json(n);
overrideJson2Elem(existing, n);
}
node = existing;
} else {
Expand All @@ -184,7 +200,7 @@ function saveLoadUtilities(cy, api) {
let edge = null;
if (existing.length > 0) {
if (isOverrideExisting) {
existing.json(e);
overrideJson2Elem(existing, e);
}
edge = existing;
} else {
Expand Down

0 comments on commit 1bcf335

Please # to comment.