cytoscape.js-expand-collapse
cytoscape.js-expand-collapse copied to clipboard
Update saveJSON to return serialized data
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
:
- Conditionally write to file
- Return the stringified data that is being written
Alternatively, this could be surfaced via a new method?
I think you're right. We will look into that.
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 seems to be working - thanks! One issue I'm running into is if I:
- collapse a node
- store the result of
saveJson
then refresh the page, and pass the previously stored result toloadJson
- 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?
So it never reached the master branch, right ? :D
@Nicolas-PredictaLab We are currently working on a unified complexity management framework, so this one is not maintained. Sorry.
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?
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
Thank you!