I am unsure how to proceed, when testing, there is only one node in the diagram. And Model.findNodeDataForKey returns that node.
I printed the value of Model.findNodeDataForKey in different places in the process
changeSelectedNodeData(key: number, property: string, changedNodeData: any): void {
this.diagramComponent.diagram.model.commit((m) => {
console.group('Changing property');
console.group('Before m.setDataProperty');
console.log(m.findNodeDataForKey(key));
console.groupEnd();
m.setDataProperty(m.findNodeDataForKey(key), property, changedNodeData);
console.group('After m.setDataProperty');
console.log(m.findNodeDataForKey(key));
console.groupEnd();
}, 'change selected node data');
console.group('After commit');
console.log(this.diagramComponent.diagram.model.findNodeDataForKey(key));
console.groupEnd();
console.groupEnd();
}
Which results in the following
(Output below is same as in screenshot, in the screenshot and code above I did cut off console.log(this.diagramComponent.diagram.model.toJson());
, and there is also the modifiedNodeData that got called.)
diagram-visualisation.component.ts:497 Changing property
diagram-visualisation.component.ts:498 Before m.setDataProperty
diagram-visualisation.component.ts:499 {name: 'Placeholder', category: 'HvacNode', portArray: Array(4), __gohashid: 3882, key: -4}category: "HvacNode"key: -4name: "Placeholder2"portArray: Array(4)0: {portId: 'l1', alignment: '0 0.4', side: 'l', __gohashid: 3662}1: {portId: 'l2', alignment: '0 0.6', side: 'l', __gohashid: 3666}2: {portId: 'r1', alignment: '1 0.4', side: 'r', __gohashid: 3670}3: {portId: 'r2', alignment: '1 0.6', side: 'r', __gohashid: 3674}__gohashid: 3655length: 4[[Prototype]]: Array(0)__gohashid: 3882[[Prototype]]: Object
diagram-visualisation.component.ts:504 After m.setDataProperty
diagram-visualisation.component.ts:505 {name: 'Placeholder2', category: 'HvacNode', portArray: Array(4), __gohashid: 3882, key: -4}category: "HvacNode"key: -4name: "Placeholder2"portArray: Array(4)0: {portId: 'l1', alignment: '0 0.4', side: 'l', __gohashid: 3662}1: {portId: 'l2', alignment: '0 0.6', side: 'l', __gohashid: 3666}2: {portId: 'r1', alignment: '1 0.4', side: 'r', __gohashid: 3670}3: {portId: 'r2', alignment: '1 0.6', side: 'r', __gohashid: 3674}__gohashid: 3655length: 4[[Prototype]]: Array(0)__gohashid: 3882[[Prototype]]: Object
diagram-visualisation.component.ts:482 {modifiedNodeData: Array(1)}modifiedNodeData: Array(1)0: {name: 'Placeholder2', category: 'HvacNode', portArray: Array(4), key: -4}length: 1[[Prototype]]: Array(0)[[Prototype]]: Object
diagram-visualisation.component.ts:510 After commit
diagram-visualisation.component.ts:511 {name: 'Placeholder2', category: 'HvacNode', portArray: Array(4), __gohashid: 3882, key: -4}category: "HvacNode"key: -4name: "Placeholder2"portArray: Array(4)0: {portId: 'l1', alignment: '0 0.4', side: 'l', __gohashid: 3662}1: {portId: 'l2', alignment: '0 0.6', side: 'l', __gohashid: 3666}2: {portId: 'r1', alignment: '1 0.4', side: 'r', __gohashid: 3670}3: {portId: 'r2', alignment: '1 0.6', side: 'r', __gohashid: 3674}__gohashid: 3655length: 4[[Prototype]]: Array(0)__gohashid: 3882[[Prototype]]: Object
diagram-visualisation.component.ts:516 { "class": "GraphLinksModel",
"linkKeyProperty": "key",
"linkFromPortIdProperty": "fromPort",
"linkToPortIdProperty": "toPort",
"nodeDataArray": [{"name":"Placeholder2","category":"HvacNode","portArray":[{"portId":"l1","alignment":"0 0.4","side":"l"},{"portId":"l2","alignment":"0 0.6","side":"l"},{"portId":"r1","alignment":"1 0.4","side":"r"},{"portId":"r2","alignment":"1 0.6","side":"r"}],"key":-4}],
"linkDataArray": []}