This is one of my templates
They already have the makeTwoWay binding but they are not updating the original value, did I miss something ?
import go from 'gojs';
import { portDecoration } from './nodePorts';
import { textFont, titleFont } from './templateParams';
import { getContextMenuTemplate } from './ContextMenuTemplate';
const $ = go.GraphObject.make;
function sizeParse(size: string){
if(size == null) return null;
return go.Size.parse(size);
}
export const getNodeTemplate = () => {
return $(go.Node, 'Table',
{
isShadowed: false,
shadowColor: 'black',
shadowOffset: new go.Point(10, 10),
locationObjectName: 'BODY',
selectionObjectName: 'BODY',
locationSpot: go.Spot.TopLeft,
resizable: true,
minSize: new go.Size(60, 40),
contextMenu: getContextMenuTemplate,
selectionAdorned: false,
},
new go.Binding('isShadowed', 'shadowed'),
new go.Binding('isLayoutPositioned', 'layoutPositioned'),
new go.Binding('location', 'loc', go.Point.parse).makeTwoWay(go.Point.stringify),
new go.Binding('height', 'height').makeTwoWay(),
new go.Binding('width', 'width').makeTwoWay(),
new go.Binding('desiredSize', 'size', sizeParse).makeTwoWay(go.Size.stringify),
new go.Binding('visible', 'visible').makeTwoWay(),
$(go.Panel, 'Auto',
{
row: 1, column: 1, name: 'BODY',
stretch: go.GraphObject.Fill
},
$(go.Shape,
{
figure: 'Rectangle',
stroke: null,
fill: 'white',
stretch: go.GraphObject.Fill
},
new go.Binding('figure', 'shape'),
new go.Binding('fill', 'color'),
new go.Binding('stroke', 'borderColor'),
new go.Binding('strokeWidth', 'widthBorder'),
new go.Binding('strokeDashArray', 'widthBorderArray')
),
$(go.Panel, 'Table',
{ margin: 2, stretch: go.GraphObject.Fill, alignment: go.Spot.Center, row: 1, column: 0 },
$(go.Panel, 'Vertical',
{ stretch: go.GraphObject.Horizontal },
new go.Binding('margin', 'schemaName',
function (schemaName) {
return schemaName !== 'PSE' ?
new go.Margin(2, 22, 2, 22) : new go.Margin(2, 2, 2, 2);
}),
$(go.TextBlock,
{ margin: 4, font: titleFont },
new go.Binding('font', 'schemaName',
function (schemaName) {
return schemaName !== 'PSE' ?
titleFont : titleFont.replace('bold', '');
}),
new go.Binding('stroke', 'fontColor'),
new go.Binding('text', 'reference')),
$(go.TextBlock,
{
font: textFont,
margin: 4, wrap: go.TextBlock.WrapFit, overflow: go.TextBlock.OverflowEllipsis,
maxLines: 5
},
new go.Binding('stroke', 'fontColor'),
new go.Binding('text', 'name'),
new go.Binding('visible', 'schemaName',
function (schemaName) {
return schemaName !== 'PSE';
})
),
$(go.Picture,
new go.Binding('source', 'icon')
)
)
),
$(go.Picture,
{ margin: 1, width: 24, height: 24, alignment: go.Spot.TopLeft },
new go.Binding('source', 'flowDirectionIcon'),
new go.Binding('name', 'key'),
{
toolTip:
$('ToolTip',
$(go.TextBlock, { margin: 3 },
new go.Binding('text', 'flowDirectionIconTooltip')
))
},
{
click: (e: any, node: any) => console.log(e, node)
}
)
),
portDecoration("top"),
portDecoration("right"),
portDecoration("left"),
portDecoration("bottom"),
);
}