Link Template
let linkTemplate = $(
go.Link, // the whole link panel
{
// routing: go.Link.AvoidsNodes,
routing: go.Link.Orthogonal,
reshapable: true,
resegmentable: true,
adjusting: go.Link.Stretch,
layerName: 'Background',
selectionChanged: link => {
handleLinkClick(link);
},
doubleClick: (e, node) => {
handleDoubleClick(node?.part?.data);
},
},
new go.Binding('visible', 'displayOptions', displayOptions => {
return displayOptions.includes(
constants.HIDE_SHOW_RELATIONSHIP_DISPLAY,
);
}).ofModel(),
// new go.Binding("visible", "viewMode", (viewMode, tb) => {
// if (viewMode === constants.VIEW_MODE_PHYSICAL) {
// return tb.data.HideInPhysical === "true" ? false : true;
// } else {
// return tb.data.HideInLogical === "true" ? false : true;
// }
// }).ofModel(),
// @ts-ignore
new go.Binding('fromSpot', value => {
if (value.Type === 'Subtype') {
return value.fromSpot.replace('Side', '')
} else {
return go.Spot.BottomCenter;
}
}, go.Spot.parse),
// @ts-ignore
new go.Binding('toSpot', value => {
if (value.Type === 'Subtype') {
return value.toSpot.replace('Side', '')
} else {
return go.Spot.TopCenter;
}
}, go.Spot.parse),
$(
go.Shape, // the link shape
// @ts-ignore
new go.Binding('stroke', value => {
return value.fillOptions.linecolor === null ||
value.fillOptions.linecolor === undefined ||
value.fillOptions.linecolor === ''
? '#9c9b9c'
: value.fillOptions.linecolor;
}),
// @ts-ignore
new go.Binding('strokeWidth', val => {
return val.fillOptions.linewidth;
}),
// @ts-ignore
new go.Binding('strokeDashArray', value => {
return value.isDashed === 'true' || value.Type === '7'
? [15, 3]
: [0, 0];
}),
),
$(
go.Shape, // the "to" end arrowhead
new go.Binding('toArrow', 'toArrowShape'),
// @ts-ignore
new go.Binding('fill', value => {
return value.toArrowColor === null ||
value.toArrowColor === undefined ||
value.toArrowColor === '' ||
value.toArrowColor === '#000000'
? '#FFFFFF'
: value.fillOptions?.linecolor;
}),
),
$(
go.Shape, // the "to" end arrowhead
new go.Binding('fromArrow', 'fromArrowShape'),
// @ts-ignore
new go.Binding('fill', value => {
return value.fromArrowColor === null ||
value.fromArrowColor === undefined ||
value.fromArrowColor === '' ||
value.fromArrowColor === '#000000'
? '#FFFFFF'
: value.fillOptions?.linecolor;
}),
),
$(
go.TextBlock, // the "from" label
{ segmentOffset: new go.Point(0, -10) },
{
contextMenu: $(
'ContextMenu',
$(
// @ts-ignore
'ContextMenuButton',
{
'ButtonBorder.fill': 'white',
_buttonFillOver: 'skyblue',
},
$(go.TextBlock, 'Properties'),
{ click: (e, node) => handleGetProperties(node?.part?.data) },
),
),
},
// @ts-ignore
new go.Binding('font', val => {
return erDiagramUtils.getFontStyle(val.fontOptions);
}),
// @ts-ignore
new go.Binding('stroke', val => {
return val.fontOptions.color === null ||
val.fontOptions.color === undefined
? 'black'
: val.fontOptions.color;
}),
// new go.Binding("visible", "hiddenLabels").ofModel(),
new go.Binding('text', 'viewMode', (val, tb) => {
return val === constants.VIEW_MODE_PHYSICAL
? tb.part.data.PhysicalName
: tb.part.data.Name;
}).ofModel(),
new go.Binding('visible', 'displayOptions', displayOptions => {
return displayOptions.includes(constants.DISPLAY_RELATIONSHIP_NAME);
}).ofModel(),
),
$(
go.TextBlock,
'to',
{
segmentIndex: -1,
segmentOffset: new go.Point(NaN, NaN),
segmentOrientation: go.Link.OrientUpright,
},
// @ts-ignore
new go.Binding('visible', 'displayOptions', displayOptions => {
return displayOptions.includes(constants.DISPLAY_CARDINALITY);
}).ofModel(),
// @ts-ignore
new go.Binding('text', val => {
return val.Cardinality;
}),
// @ts-ignore
new go.Binding('stroke', val => {
return val.fontOptions.color === null ||
val.fontOptions.color === undefined
? 'black'
: val.fontOptions.color;
}),
),
{
// define a tooltip for each node that displays the color as text
toolTip: $(
'ToolTip',
$(
go.TextBlock,
{ margin: 4 },
{ alignment: go.Spot.Top, stroke: 'blue' },
// @ts-ignore
new go.Binding('text', 'viewMode', (val, tb) => {
let physicalTooltip =
tb.part.data.PhysicalName +
' (' +
tb.part.data.Parent_PhysicalName +
' to ' +
tb.part.data.Child_PhysicalName +
')';
let logicalTooltip =
tb.part.data.Name +
' (' +
tb.part.data.Parent_Name +
' to ' +
tb.part.data.Child_Name +
')';
return val === constants.VIEW_MODE_PHYSICAL
? physicalTooltip +
'\n' +
'Parent:' +
tb.part.data.Parent_PhysicalName +
'\n' +
'Child: ' +
tb.part.data.Child_PhysicalName +
'\n' +
'Auto Routing: Off'
: logicalTooltip +
'\n' +
'Parent:' +
tb.part.data.Parent_Name +
'\n' +
'Child: ' +
tb.part.data.Child_Name +
'\n' +
'Auto Routing: Off';
}).ofModel(),
),
), // end of Adornment
},
);
Node Template
let columnAttributeTemplate = $(
go.Node,
'Vertical',
{
selectionAdorned: true,
resizable: true,
layoutConditions: go.Part.LayoutStandard & ~go.Part.LayoutNodeSized,
resizeObjectName: 'ITEMARRAYPANEL',
doubleClick: (e, node) => {
handleDoubleClick(node?.part?.data);
},
},
/*new go.Binding('visible', 'viewMode', (viewMode, tb) => {
if (viewMode === constants.VIEW_MODE_PHYSICAL) {
return tb.data.HideInPhysical !== 'true';
} else {
return tb.data.HideInLogical !== 'true';
}
}).ofModel(),*/
new go.Binding('location', 'Coordinates', go.Point.parse),
$(
go.TextBlock,
{
margin: 3,
alignment: go.Spot.Left,
},
{
contextMenu: $(
'ContextMenu',
$(
// @ts-ignore
'ContextMenuButton',
{
'ButtonBorder.fill': 'white',
_buttonFillOver: 'skyblue',
},
$(go.TextBlock, 'Properties'),
{ click: (e, node) => handleGetProperties(node?.part?.data) },
),
),
},
// @ts-ignore
new go.Binding('stroke', val => {
return val.fontOptions.color;
}),
new go.Binding('text', '', (val, tb) => {
return val.viewMode === 'physical'
? tb.part.data.PhysicalName
: tb.part.data.Name;
}).ofModel(),
),
$(
go.Panel,
'Auto',
$(
go.Shape,
{
minSize: new go.Size(100, 20),
strokeWidth: 2,
portId: '',
// spot1: go.Spot.TopLeft,
// spot2: go.Spot.BottomRight,
fromSpot: go.Spot.Right, // port properties go on the port!
toSpot: go.Spot.Left
},
// @ts-ignore
new go.Binding('stroke', value => {
return value.fillOptions.outlineColor !== undefined
? value.fillOptions.outlineColor
: '#000000';
}),
// @ts-ignore
new go.Binding('strokeDashArray', value => {
return value.icon === 'View' ? [2, 4] : [0, 0];
}),
// @ts-ignore
new go.Binding('fill', val => {
return $(go.Brush, 'Linear', {
0: val.fillOptions.startingColor,
1: val.fillOptions.endingColor,
});
}),
{
// define a tooltip for each node that displays the color as text
toolTip: $(
'ToolTip',
$(
go.TextBlock,
{ margin: 4, stroke: 'blue' },
// @ts-ignore
new go.Binding('text', value => {
return (
value.Name +
'\nAuto Sizing: On' +
'\nDefinition: ' +
value.Definition
);
}),
),
), // end of Adornment
},
//new go.Binding("width", "width"),
new go.Binding('figure', 'figure'),
),
$(
go.Panel,
'Table',
new go.Binding('itemArray', 'Attribute'),
// @ts-ignore
{
name: 'ITEMARRAYPANEL',
// margin: 3,
defaultAlignment: go.Spot.Left,
// itemTemplate: itemTempl, // map was defined above
itemTemplateMap: acItemTemplateMap,
// alignment: go.Spot.Left
},
// $(go.RowColumnDefinition,
// { separatorStroke: "#C71585", row: 1 })
),
),
);