Skip to content

Commit 5ccd8c4

Browse files
committed
Update diagram.component.ts
1 parent 579d83d commit 5ccd8c4

File tree

1 file changed

+7
-12
lines changed

1 file changed

+7
-12
lines changed

projects/gojs-angular/src/lib/diagram.component.ts

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -110,12 +110,12 @@ export class DiagramComponent {
110110
} // end ngAfterViewInit
111111

112112
/**
113-
* Merges changes from app data into GoJS model data,
113+
* Merges changes from app data into GoJS model data,
114114
* making sure only actual changes (and not falsely flagged no-ops on array / obj data props) are logged
115115
* @param component an instance of DiagramComponent or PaletteComponent
116116
* @param kvchanges The kvchanges object produced by either a node or link Angular differ object
117117
* @param str "n" for node data changes, "l" for link data changes
118-
* */
118+
* */
119119
public static mergeChanges(component, kvchanges, str): boolean {
120120

121121
// helper function
@@ -193,7 +193,7 @@ export class DiagramComponent {
193193

194194
// handle changed data for nodes / links
195195
kvchanges.forEachChangedItem((r: KeyValueChangeRecord<string, any>) => {
196-
196+
197197
// ensure "changes" to array / object / enumerable data properties are legit
198198
const sameVals = compareObjs(r.currentValue, r.previousValue);
199199

@@ -232,10 +232,10 @@ export class DiagramComponent {
232232
}
233233
}
234234
}
235-
235+
236236
});
237237
}
238-
238+
239239
} // end mergeChanges function
240240

241241
/**
@@ -248,7 +248,7 @@ export class DiagramComponent {
248248

249249
// these need to be run each check, even if no merging happens
250250
// otherwise, they will detect all diffs that happened since last time skipsDiagram was false,
251-
// such as remove ops that happened in GoJS when skipsDiagram = true,
251+
// such as remove ops that happened in GoJS when skipsDiagram = true,
252252
// and then realllllly bad stuff happens (deleting random nodes, updating the wrong Parts)
253253
// Angular differs are a lot of fun
254254
var nodeDiffs = this._ndaDiffer.diff(this.nodeDataArray);
@@ -264,7 +264,7 @@ export class DiagramComponent {
264264
this.diagram.delayInitialization(() => {
265265
this.mergeAppDataWithModel(this, nodeDiffs, linkDiffs, true);
266266
this.wasCleared = false;
267-
});
267+
});
268268
} else {
269269
this.mergeAppDataWithModel(this, nodeDiffs, linkDiffs, false);
270270
}
@@ -276,17 +276,12 @@ export class DiagramComponent {
276276
if (component.modelChangedListener !== null) this.diagram.model.removeChangedListener(this.modelChangedListener);
277277

278278
component.diagram.model.startTransaction('update data');
279-
// if (isInit) component.diagram.model.modelData = {};
280279
// update modelData first, in case bindings on nodes / links depend on model data
281280
component.diagram.model.assignAllDataProperties(this.diagram.model.modelData, this.modelData);
282281
// merge node / link data
283-
// if (isInit) component.diagram.model.nodeDataArray = [];
284-
// DiagramComponent.mergeChanges(component, nodeDiffs, "n");
285282
this.diagram.model.mergeNodeDataArray(this.nodeDataArray);
286283
if (component.linkDataArray && component.diagram.model instanceof go.GraphLinksModel) {
287-
// if (isInit) component.diagram.model.linkDataArray = [];
288284
component.diagram.model.mergeLinkDataArray(this.linkDataArray);
289-
// DiagramComponent.mergeChanges(component, linkDiffs, "l");
290285
}
291286
component.diagram.model.commitTransaction('update data');
292287

0 commit comments

Comments
 (0)