Which event gets fired when ports are changed for link ? I need to save the diagram when only ports are changed.
I’m sorry but I do not understand your question.
In my view ports are not changed when links are connected or disconnected. You can change ports by implementing the linkConnected and/or linkDisconnected event handlers in order to modify ports, but by default no modification of the color or size or shape of a port will occur.
Well, following is the template for nodes defined -
current.goObj(go.Shape, { name: "SHAPE", fill: current.ActivityNodeFill, stroke: current.ActivityNodeStroke, portId: "", //width: 100, height: 100, fromLinkable: true, toLinkable: true, fromSpot: go.Spot.AllSides, toSpot: go.Spot.AllSides, stretch: go.GraphObject.Fill, },
Using LinkShifting tool, I am able to change the spot where link is connected to the node.
On selectionMoved, I am saving my diagram. But this event gets fired when some node is moved.
With this approach, when diagram is loaded again, I am able to see the spots correctly where link was connected.
Now, What i need is when the link connected point gets shifted (using LinkShiftingTool), I need to immediately save diagram.
Hope this clears the expectation.
So your nodes have a single port, and the ports are not modified when a link is connected or modified.
Rather than trying to handle each modification case separately, why not add a “ModelChanged” DiagramEvent listener that saves the model after each transaction?
For example, in the Diagram initialization:
"ModelChanged": function(e) {
if (e.isTransactionFinished) saveModel(e.diagram.model);
}