cytoscape.js-expand-collapse icon indicating copy to clipboard operation
cytoscape.js-expand-collapse copied to clipboard

Update saveJSON to return serialized data

Open HieronymusLex opened this issue 2 years ago • 8 comments

Currently the saveJSON returns nothing and always writes to file, however there are use cases where one would want the contents of what saveJSON is writing, without actually writing it to a file (e.g. in order to pass the data to an API call).

Could we have saveJSON:

  1. Conditionally write to file
  2. Return the stringified data that is being written

Alternatively, this could be surfaced via a new method?

HieronymusLex avatar Oct 05 '22 12:10 HieronymusLex

I think you're right. We will look into that.

hasanbalci avatar Oct 07 '22 17:10 hasanbalci

Now, saveJSON always returns the stringified data and writes to a file only if filename parameter is provided. If not, it doesn't write to a file. The change is done in the unstable branch and will also be active in the master branch when we merge it before a release. @HieronymusLex, can you please verify and close the issue if it is ok?

hasanbalci avatar Oct 12 '22 10:10 hasanbalci

@hasanbalci seems to be working - thanks! One issue I'm running into is if I:

  1. collapse a node
  2. store the result of saveJson then refresh the page, and pass the previously stored result to loadJson
  3. try to expand the collapsed node

only the collapsed children appear correctly, not the "collapsed edges". The console displays an error saying:

expandCollapseUtilities.js:622 Uncaught TypeError: Cannot read properties of undefined (reading 'id')
    at Object.findNewEnd (expandCollapseUtilities.js:622:1)
    at Object.repairEdges (expandCollapseUtilities.js:638:1)

which is caused by parent being undefined at parent = parentData[parent.id()];

Pseudo code for reference:

const data = canvas.expandCollapse('get').saveJson()
// store data....refresh... get data
const api = canvas.expandCollapse('get')
api.loadJson(data)

Any ideas what could be happening here?

HieronymusLex avatar Oct 20 '22 14:10 HieronymusLex

So it never reached the master branch, right ? :D

Nicolas-PredictaLab avatar Apr 24 '23 14:04 Nicolas-PredictaLab

@Nicolas-PredictaLab We are currently working on a unified complexity management framework, so this one is not maintained. Sorry.

ugurdogrusoz avatar Apr 25 '23 06:04 ugurdogrusoz

Can we put an indication in the README that this library is not maintained, just so people know for when they start new projects to use use something else?

svozza avatar May 03 '23 08:05 svozza

Can we put an indication in the README that this library is not maintained, just so people know for when they start new projects to use use something else?

Done

ugurdogrusoz avatar May 04 '23 05:05 ugurdogrusoz

Thank you!

svozza avatar May 05 '23 14:05 svozza