Get modified nodes and links

I would appreciate you give me the code to adapt it :blush:

Thanks!

OK, we have done some of this work for version 1.6, but it’s not going to be easy for you to adapt the code to work in version 1.5.

It might be easier for you if you wait until an alpha release of 1.6 becomes available. But that might be weeks away, at least.

the new patch includes something like isModified property in nodes / links like Diagram.isModified? Or how will it work?

There will be a new method, Model.toIncrementalJson. Here’s the doc string:

/**
* Produce a JSON-format string representing the changes in the most recent {@link Transaction}.
* This writes out JSON for a model, but recording only changes in the given Transaction,
* with the addition of the "incremental" property to mark it as different from a complete model.
* Instead of the "nodeDataArray" property (and "linkDataArray" property for {@link GraphLinksModel}s),
* this will have "inserted...", "modified...", and "removed..." properties that are Arrays.
* <p>
* The "modifiedNodeData" Array holds JavaScript objects.
* The "insertedNodeKeys" and "removedNodeKeys" Arrays hold keys (numbers or strings) of data,
* not whole objects, that have been added and/or deleted.
* <p>
* Note that it is entirely plausible for the same object be in all three Arrays,
* because a single {@link Transaction} can include adding a node, modifying it, and removing it.
* <p>
* The purpose of this method is to make it easier to send incremental changes to the server/database,
* instead of sending the whole model.
* Whereas it has always been easy to perform "batch" updates or "file saves":
* <pre>
*   myDiagram.model = ...;
*   myDiagram.model.addChangedListener(function(e) {
*     if (e.isTransactionFinished) {
*       var json = myDiagram.model.toJson();
*       // this saves the whole model upon each transaction completion or undo or redo
*       ... send to server/database ...
*     }
*   });
* </pre>
* You can now easily send "incremental" updates:
* <pre>
*   myDiagram.model = ...;
*   myDiagram.model.addChangedListener(function(e) {
*     if (e.isTransactionFinished) {
*       var json = myDiagram.model.toIncrementalJson(e);
*       // this records each Transaction as a JSON-format string
*       ... send to server/database ...
*     }
*   });
* </pre>
* Note that these incremental changes include the results of undo and redo operations.
* <p>
* For {@link GraphLinksModel}s, this method requires that {@link GraphLinksModel#linkKeyProperty} is not an empty string.
* The incremental JSON for GraphLinksModels will include "modifiedLinkData", "insertedLinkKeys", and "removedLinkKeys"
* properties that are Arrays.
* @this {Model}
* @param {ChangedEvent} e a Transaction ChangedEvent for which {@link ChangedEvent.isTransactionFinished} is true
* @param {string=} classname for the written model, defaults to the name of the class of the model
* @return {string}
* @since 1.6
*/

So you wouldn’t need to use a hack like putting a “u” property on the data.

You can try using Model.toIncrementalJson in 1.6: GoJS - Build Interactive Diagrams for the Web .

Example: State Chart With Incremental Saves