Hello Everyone,
I have an issue where my node template is not adhering to the properties ‘fromMaxLinks’ and ‘toMaxLinks’
I have a model that describes the nodeTemplate map where each type of node has its own definition of the max to and from links. I have a function that generates the map template (as below)
function createNodeTemplate(fill, activity) {
var tileText = activity.TileText;
if (tileText === undefined || tileText == null || tileText == '')
tileText = activity.Name;
return GO(go.Node, 'Vertical', {
locationSpot: go.Spot.Center,
locationObjectName: 'activity',
selectionAdorned: true,
selectionObjectName: 'activity',
resizable: false,
rotatable: false,
layoutConditions: go.Part.LayoutStandard & ~go.Part.LayoutNodeSized,
}, new go.Binding('location', 'loc', go.Point.parse).makeTwoWay(go.Point.stringify),
GO(go.Panel, 'Auto', {
height: 78,
width: 78,
<font color="#009933">portId: '1',</font>
<font color="#009933"> fromLinkable: true,</font>
<font color="#009933"> toLinkable: true,</font>
<font color="#009933"> fromMaxLinks: activity.OutboundLinks,</font>
<font color="#009933"> toMaxLinks: activity.InboundLinks,</font>
},
GO(go.Shape, 'Rectangle', {
name: 'activity',
fill: fill,
strokeWidth: 2,
stroke: '#666',
height: 72,
width: 72
}),
GO(go.Picture, {
source: activity.TileImage,
height: 44,
width: 44,
alignment: go.Spot.TopCenter,
margin: new go.Margin(6, 0, 0, 0),
stretch: go.GraphObject.UniformToFill
}),
GO(go.TextBlock, { font: '10px Arial', textAlign: 'center', width: 72, text: tileText, alignment: go.Spot.BottomCenter, margin: new go.Margin(0, 0, 2, 0) })),
GO(go.TextBlock, { margin: 2, font: '10px sans-serif', editable: false }, new go.Binding('text', 'name').makeTwoWay(go.Point.stringify)));
}
Now lets assume that all the activities are passing in a 1 for the toMaxLinks & fromMaxLinks properties. I would imagine that (as I only have 1 port on the node) that we should only be able to draw 1 link from the node and 1 link to the node. However the user can draw as many as they like.
Now if I change the model to pass in 0 for either of the properties then it functions correctly.
The full project code is rather lengthy but can provide more details if you wish.
Thank you for your time,
Nico