pict-section-flow 1.3.0 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +7 -2
- package/source/Pict-Section-Flow.js +20 -14
- package/source/providers/PictProvider-Flow-Background.js +303 -0
- package/source/providers/PictProvider-Flow-CSS.js +99 -7
- package/source/providers/PictProvider-Flow-ConnectorShapes.js +8 -0
- package/source/providers/PictProvider-Flow-Geometry.js +11 -421
- package/source/providers/PictProvider-Flow-Icons.js +20 -0
- package/source/providers/PictProvider-Flow-Layouts.js +107 -0
- package/source/services/PictService-Flow-ConnectionRenderer.js +77 -5
- package/source/services/PictService-Flow-CursorManager.js +113 -0
- package/source/services/PictService-Flow-InteractionManager.js +443 -61
- package/source/services/PictService-Flow-Layout.js +21 -16
- package/source/services/PictService-Flow-PathGenerator.js +30 -417
- package/source/services/PictService-Flow-RenderManager.js +9 -1
- package/source/services/PictService-Flow-ViewportManager.js +102 -0
- package/source/views/PictView-Flow-FloatingToolbar.js +57 -0
- package/source/views/PictView-Flow-Node.js +36 -0
- package/source/views/PictView-Flow-PropertiesPanel.js +27 -5
- package/source/views/PictView-Flow-Toolbar.js +148 -13
- package/source/views/PictView-Flow.js +628 -3
- package/.claude/launch.json +0 -11
- package/docs/.nojekyll +0 -0
- package/docs/Architecture.md +0 -163
- package/docs/Custom-Styling.md +0 -275
- package/docs/Data_Model.md +0 -149
- package/docs/Event_System.md +0 -156
- package/docs/Getting_Started.md +0 -237
- package/docs/Implementation_Reference.md +0 -528
- package/docs/Layout_Persistence.md +0 -117
- package/docs/README.md +0 -103
- package/docs/Theme_Integration.md +0 -150
- package/docs/_brand.json +0 -18
- package/docs/_cover.md +0 -17
- package/docs/_playground.json +0 -24
- package/docs/_sidebar.md +0 -57
- package/docs/_topbar.md +0 -8
- package/docs/_version.json +0 -7
- package/docs/api/PictFlowCard.md +0 -216
- package/docs/api/PictFlowCardPropertiesPanel.md +0 -235
- package/docs/api/addConnection.md +0 -101
- package/docs/api/addNode.md +0 -137
- package/docs/api/autoLayout.md +0 -77
- package/docs/api/getFlowData.md +0 -112
- package/docs/api/marshalToView.md +0 -95
- package/docs/api/openPanel.md +0 -128
- package/docs/api/registerHandler.md +0 -174
- package/docs/api/registerNodeType.md +0 -142
- package/docs/api/removeConnection.md +0 -57
- package/docs/api/removeNode.md +0 -80
- package/docs/api/saveLayout.md +0 -152
- package/docs/api/screenToSVGCoords.md +0 -68
- package/docs/api/selectNode.md +0 -116
- package/docs/api/setTheme.md +0 -168
- package/docs/api/setZoom.md +0 -97
- package/docs/api/toggleFullscreen.md +0 -68
- package/docs/card-help/EACH.md +0 -19
- package/docs/card-help/FREAD.md +0 -24
- package/docs/card-help/FWRITE.md +0 -24
- package/docs/card-help/GET.md +0 -22
- package/docs/card-help/ITE.md +0 -23
- package/docs/card-help/LOG.md +0 -23
- package/docs/card-help/NOTE.md +0 -17
- package/docs/card-help/PREV.md +0 -18
- package/docs/card-help/SET.md +0 -27
- package/docs/card-help/SPKL.md +0 -22
- package/docs/card-help/STAT.md +0 -23
- package/docs/card-help/SW.md +0 -25
- package/docs/diagrams/architecture-at-a-glance.excalidraw +0 -4270
- package/docs/diagrams/architecture-at-a-glance.mmd +0 -30
- package/docs/diagrams/architecture-at-a-glance.svg +0 -2
- package/docs/diagrams/data-flow.excalidraw +0 -1451
- package/docs/diagrams/data-flow.mmd +0 -17
- package/docs/diagrams/data-flow.svg +0 -2
- package/docs/diagrams/high-level-design.excalidraw +0 -5767
- package/docs/diagrams/high-level-design.mmd +0 -86
- package/docs/diagrams/high-level-design.svg +0 -2
- package/docs/diagrams/relationships.excalidraw +0 -3852
- package/docs/diagrams/relationships.mmd +0 -9
- package/docs/diagrams/relationships.svg +0 -2
- package/docs/diagrams/service-initialization-sequence.excalidraw +0 -1466
- package/docs/diagrams/service-initialization-sequence.mmd +0 -19
- package/docs/diagrams/service-initialization-sequence.svg +0 -2
- package/docs/diagrams/svg-layer-structure.excalidraw +0 -1060
- package/docs/diagrams/svg-layer-structure.mmd +0 -18
- package/docs/diagrams/svg-layer-structure.svg +0 -2
- package/docs/examples/README.md +0 -9
- package/docs/examples/simple_cards/README.md +0 -677
- package/docs/examples/simple_cards/css/flowexample.css +0 -65
- package/docs/examples/simple_cards/index.html +0 -32
- package/docs/examples/simple_cards/js/pict.min.js +0 -12
- package/docs/examples/simple_cards/pict-section-flow-example-simple-cards.compatible.min.js +0 -1
- package/docs/index.html +0 -38
- package/docs/playground/app.json +0 -6
- package/docs/playground/appdata.json +0 -85
- package/docs/playground/application.js +0 -23
- package/docs/playground/pict.json +0 -17
- package/docs/playground/runtime/pict-application.min.js +0 -2
- package/docs/playground/runtime/pict-section-flow.min.js +0 -2
- package/docs/playground/runtime/pict-section-modal.min.js +0 -2
- package/docs/playground/runtime/pict.min.js +0 -12
- package/docs/retold-catalog.json +0 -244
- package/docs/retold-keyword-index.json +0 -26028
- package/example_applications/simple_cards/css/flowexample.css +0 -65
- package/example_applications/simple_cards/html/index.html +0 -32
- package/example_applications/simple_cards/package.json +0 -52
- package/example_applications/simple_cards/source/Pict-Application-FlowExample-Configuration.json +0 -15
- package/example_applications/simple_cards/source/Pict-Application-FlowExample.js +0 -539
- package/example_applications/simple_cards/source/card-help-content.js +0 -16
- package/example_applications/simple_cards/source/cards/FlowCard-Comment.js +0 -38
- package/example_applications/simple_cards/source/cards/FlowCard-DataPreview.js +0 -44
- package/example_applications/simple_cards/source/cards/FlowCard-Each.js +0 -38
- package/example_applications/simple_cards/source/cards/FlowCard-FileRead.js +0 -56
- package/example_applications/simple_cards/source/cards/FlowCard-FileWrite.js +0 -50
- package/example_applications/simple_cards/source/cards/FlowCard-GetValue.js +0 -37
- package/example_applications/simple_cards/source/cards/FlowCard-IfThenElse.js +0 -49
- package/example_applications/simple_cards/source/cards/FlowCard-LogValues.js +0 -55
- package/example_applications/simple_cards/source/cards/FlowCard-SetValue.js +0 -97
- package/example_applications/simple_cards/source/cards/FlowCard-Sparkline.js +0 -100
- package/example_applications/simple_cards/source/cards/FlowCard-StatusMonitor.js +0 -46
- package/example_applications/simple_cards/source/cards/FlowCard-Switch.js +0 -39
- package/example_applications/simple_cards/source/providers/PictRouter-FlowExample-Configuration.json +0 -22
- package/example_applications/simple_cards/source/sample-flows.js +0 -410
- package/example_applications/simple_cards/source/views/PictView-FlowExample-About.js +0 -184
- package/example_applications/simple_cards/source/views/PictView-FlowExample-BottomBar.js +0 -77
- package/example_applications/simple_cards/source/views/PictView-FlowExample-Documentation.js +0 -325
- package/example_applications/simple_cards/source/views/PictView-FlowExample-FileWriteInfo.js +0 -59
- package/example_applications/simple_cards/source/views/PictView-FlowExample-Layout.js +0 -90
- package/example_applications/simple_cards/source/views/PictView-FlowExample-MainWorkspace.js +0 -453
- package/example_applications/simple_cards/source/views/PictView-FlowExample-TopBar.js +0 -95
- package/scripts/generate-card-help.js +0 -214
- package/source/providers/edges/Edge-Bezier.js +0 -41
- package/source/providers/edges/Edge-Orthogonal.js +0 -37
- package/source/providers/edges/Edge-OrthogonalSnap.js +0 -72
- package/source/providers/edges/Edge-Perimeter-Linear.js +0 -31
- package/source/providers/edges/Edge-Perimeter-Orthogonal.js +0 -39
- package/source/providers/edges/Edge-Perimeter.js +0 -48
- package/source/providers/edges/Edge-PerimeterMath.js +0 -92
- package/source/providers/edges/Edge-Straight.js +0 -24
- package/source/providers/layouts/Layout-Circular.js +0 -203
- package/source/providers/layouts/Layout-Coerce.js +0 -40
- package/source/providers/layouts/Layout-Columnar.js +0 -134
- package/source/providers/layouts/Layout-Custom.js +0 -27
- package/source/providers/layouts/Layout-ForcedFromCenter.js +0 -256
- package/source/providers/layouts/Layout-Grid.js +0 -134
- package/source/providers/layouts/Layout-Layered.js +0 -155
- package/source/providers/layouts/Layout-Rank.js +0 -141
- package/source/providers/layouts/Layout-Staggered.js +0 -131
- package/source/providers/layouts/Layout-Tabular.js +0 -94
- package/test/ConnectionHandleManager_tests.js +0 -717
- package/test/ConnectionRenderer_tests.js +0 -591
- package/test/DataManager_tests.js +0 -859
- package/test/Geometry_tests.js +0 -767
- package/test/InteractionManager_tests.js +0 -279
- package/test/Layout_tests.js +0 -1604
- package/test/NodeView_tests.js +0 -66
- package/test/PanelManager_tests.js +0 -172
- package/test/PathGenerator_tests.js +0 -978
- package/test/PortRenderer_tests.js +0 -376
- package/test/RenderManager_tests.js +0 -756
- package/test/Renderer_tests.js +0 -133
- package/test/SelectionManager_tests.js +0 -185
- package/test/StylePresets_tests.js +0 -153
|
@@ -1,717 +0,0 @@
|
|
|
1
|
-
const libFable = require('fable');
|
|
2
|
-
const libChai = require('chai');
|
|
3
|
-
const libExpect = libChai.expect;
|
|
4
|
-
|
|
5
|
-
const libConnectionHandleManager = require('../source/services/PictService-Flow-ConnectionHandleManager.js');
|
|
6
|
-
|
|
7
|
-
suite
|
|
8
|
-
(
|
|
9
|
-
'PictService-Flow-ConnectionHandleManager',
|
|
10
|
-
function ()
|
|
11
|
-
{
|
|
12
|
-
let _Fable;
|
|
13
|
-
let _HandleManager;
|
|
14
|
-
let _MockFlowView;
|
|
15
|
-
|
|
16
|
-
setup
|
|
17
|
-
(
|
|
18
|
-
function ()
|
|
19
|
-
{
|
|
20
|
-
_Fable = new libFable({});
|
|
21
|
-
|
|
22
|
-
_MockFlowView =
|
|
23
|
-
{
|
|
24
|
-
fable: _Fable,
|
|
25
|
-
log: _Fable.log,
|
|
26
|
-
_FlowData:
|
|
27
|
-
{
|
|
28
|
-
Nodes:
|
|
29
|
-
[
|
|
30
|
-
{
|
|
31
|
-
Hash: 'n1',
|
|
32
|
-
X: 100, Y: 100,
|
|
33
|
-
Width: 160, Height: 80,
|
|
34
|
-
Ports:
|
|
35
|
-
[
|
|
36
|
-
{ Hash: 'p-out', Direction: 'output', Side: 'right', Label: 'Out' }
|
|
37
|
-
]
|
|
38
|
-
},
|
|
39
|
-
{
|
|
40
|
-
Hash: 'n2',
|
|
41
|
-
X: 400, Y: 100,
|
|
42
|
-
Width: 160, Height: 80,
|
|
43
|
-
Ports:
|
|
44
|
-
[
|
|
45
|
-
{ Hash: 'p-in', Direction: 'input', Side: 'left', Label: 'In' }
|
|
46
|
-
]
|
|
47
|
-
}
|
|
48
|
-
],
|
|
49
|
-
Connections:
|
|
50
|
-
[
|
|
51
|
-
{
|
|
52
|
-
Hash: 'c1',
|
|
53
|
-
SourceNodeHash: 'n1',
|
|
54
|
-
SourcePortHash: 'p-out',
|
|
55
|
-
TargetNodeHash: 'n2',
|
|
56
|
-
TargetPortHash: 'p-in',
|
|
57
|
-
Data: {}
|
|
58
|
-
}
|
|
59
|
-
],
|
|
60
|
-
OpenPanels: [],
|
|
61
|
-
ViewState:
|
|
62
|
-
{
|
|
63
|
-
SelectedConnectionHash: null
|
|
64
|
-
}
|
|
65
|
-
},
|
|
66
|
-
_ConnectionRenderer:
|
|
67
|
-
{
|
|
68
|
-
computeInsertionIndex: function () { return 0; },
|
|
69
|
-
_computeDirectionalGeometry: function (pStart, pEnd)
|
|
70
|
-
{
|
|
71
|
-
return {
|
|
72
|
-
departX: pStart.x + 20,
|
|
73
|
-
departY: pStart.y,
|
|
74
|
-
approachX: pEnd.x - 20,
|
|
75
|
-
approachY: pEnd.y,
|
|
76
|
-
startDir: { dx: 1, dy: 0 },
|
|
77
|
-
endDir: { dx: -1, dy: 0 }
|
|
78
|
-
};
|
|
79
|
-
}
|
|
80
|
-
},
|
|
81
|
-
_TetherService:
|
|
82
|
-
{
|
|
83
|
-
resetHandlesForNode: function () {},
|
|
84
|
-
resetHandlePositions: function () {}
|
|
85
|
-
},
|
|
86
|
-
_EventHandlerProvider:
|
|
87
|
-
{
|
|
88
|
-
fireEvent: function () {}
|
|
89
|
-
},
|
|
90
|
-
getConnection: function (pHash)
|
|
91
|
-
{
|
|
92
|
-
return _MockFlowView._FlowData.Connections.find(
|
|
93
|
-
(pConn) => pConn.Hash === pHash
|
|
94
|
-
) || null;
|
|
95
|
-
},
|
|
96
|
-
getPortPosition: function (pNodeHash, pPortHash)
|
|
97
|
-
{
|
|
98
|
-
let tmpNode = _MockFlowView._FlowData.Nodes.find((n) => n.Hash === pNodeHash);
|
|
99
|
-
if (!tmpNode) return null;
|
|
100
|
-
let tmpPort = tmpNode.Ports.find((p) => p.Hash === pPortHash);
|
|
101
|
-
if (!tmpPort) return null;
|
|
102
|
-
return {
|
|
103
|
-
x: tmpPort.Side === 'right' ? tmpNode.X + tmpNode.Width : tmpNode.X,
|
|
104
|
-
y: tmpNode.Y + tmpNode.Height / 2,
|
|
105
|
-
side: tmpPort.Side
|
|
106
|
-
};
|
|
107
|
-
},
|
|
108
|
-
_renderSingleConnection: function () {},
|
|
109
|
-
renderFlow: function () {},
|
|
110
|
-
marshalFromView: function () {}
|
|
111
|
-
};
|
|
112
|
-
|
|
113
|
-
_HandleManager = new libConnectionHandleManager(_Fable, { FlowView: _MockFlowView }, 'HM-Test');
|
|
114
|
-
}
|
|
115
|
-
);
|
|
116
|
-
|
|
117
|
-
// ---- Constructor ----
|
|
118
|
-
|
|
119
|
-
suite
|
|
120
|
-
(
|
|
121
|
-
'Constructor',
|
|
122
|
-
function ()
|
|
123
|
-
{
|
|
124
|
-
test
|
|
125
|
-
(
|
|
126
|
-
'should instantiate with correct serviceType',
|
|
127
|
-
function (fDone)
|
|
128
|
-
{
|
|
129
|
-
libExpect(_HandleManager).to.be.an('object');
|
|
130
|
-
libExpect(_HandleManager.serviceType).to.equal('PictServiceFlowConnectionHandleManager');
|
|
131
|
-
fDone();
|
|
132
|
-
}
|
|
133
|
-
);
|
|
134
|
-
|
|
135
|
-
test
|
|
136
|
-
(
|
|
137
|
-
'should store FlowView reference from options',
|
|
138
|
-
function (fDone)
|
|
139
|
-
{
|
|
140
|
-
libExpect(_HandleManager._FlowView).to.equal(_MockFlowView);
|
|
141
|
-
fDone();
|
|
142
|
-
}
|
|
143
|
-
);
|
|
144
|
-
|
|
145
|
-
test
|
|
146
|
-
(
|
|
147
|
-
'should handle missing FlowView',
|
|
148
|
-
function (fDone)
|
|
149
|
-
{
|
|
150
|
-
let tmpManager = new libConnectionHandleManager(_Fable, {}, 'NoView');
|
|
151
|
-
libExpect(tmpManager._FlowView).to.be.null;
|
|
152
|
-
fDone();
|
|
153
|
-
}
|
|
154
|
-
);
|
|
155
|
-
}
|
|
156
|
-
);
|
|
157
|
-
|
|
158
|
-
// ---- updateConnectionHandle ----
|
|
159
|
-
|
|
160
|
-
suite
|
|
161
|
-
(
|
|
162
|
-
'updateConnectionHandle',
|
|
163
|
-
function ()
|
|
164
|
-
{
|
|
165
|
-
test
|
|
166
|
-
(
|
|
167
|
-
'should update bezier-handle-N position',
|
|
168
|
-
function (fDone)
|
|
169
|
-
{
|
|
170
|
-
let tmpConn = _MockFlowView._FlowData.Connections[0];
|
|
171
|
-
tmpConn.Data.BezierHandles = [{ x: 200, y: 100 }];
|
|
172
|
-
tmpConn.Data.HandleCustomized = true;
|
|
173
|
-
|
|
174
|
-
_HandleManager.updateConnectionHandle('c1', 'bezier-handle-0', 250, 150);
|
|
175
|
-
|
|
176
|
-
libExpect(tmpConn.Data.BezierHandles[0].x).to.equal(250);
|
|
177
|
-
libExpect(tmpConn.Data.BezierHandles[0].y).to.equal(150);
|
|
178
|
-
fDone();
|
|
179
|
-
}
|
|
180
|
-
);
|
|
181
|
-
|
|
182
|
-
test
|
|
183
|
-
(
|
|
184
|
-
'should update bezier-midpoint with legacy sync',
|
|
185
|
-
function (fDone)
|
|
186
|
-
{
|
|
187
|
-
let tmpConn = _MockFlowView._FlowData.Connections[0];
|
|
188
|
-
tmpConn.Data = {};
|
|
189
|
-
|
|
190
|
-
_HandleManager.updateConnectionHandle('c1', 'bezier-midpoint', 300, 200);
|
|
191
|
-
|
|
192
|
-
libExpect(tmpConn.Data.HandleCustomized).to.be.true;
|
|
193
|
-
libExpect(tmpConn.Data.BezierHandles).to.have.length(1);
|
|
194
|
-
libExpect(tmpConn.Data.BezierHandles[0].x).to.equal(300);
|
|
195
|
-
libExpect(tmpConn.Data.BezierHandles[0].y).to.equal(200);
|
|
196
|
-
// Legacy fields should be kept in sync
|
|
197
|
-
libExpect(tmpConn.Data.BezierHandleX).to.equal(300);
|
|
198
|
-
libExpect(tmpConn.Data.BezierHandleY).to.equal(200);
|
|
199
|
-
fDone();
|
|
200
|
-
}
|
|
201
|
-
);
|
|
202
|
-
|
|
203
|
-
test
|
|
204
|
-
(
|
|
205
|
-
'should update existing bezier-midpoint handle',
|
|
206
|
-
function (fDone)
|
|
207
|
-
{
|
|
208
|
-
let tmpConn = _MockFlowView._FlowData.Connections[0];
|
|
209
|
-
tmpConn.Data = { BezierHandles: [{ x: 100, y: 100 }] };
|
|
210
|
-
|
|
211
|
-
_HandleManager.updateConnectionHandle('c1', 'bezier-midpoint', 500, 500);
|
|
212
|
-
|
|
213
|
-
libExpect(tmpConn.Data.BezierHandles[0].x).to.equal(500);
|
|
214
|
-
libExpect(tmpConn.Data.BezierHandles[0].y).to.equal(500);
|
|
215
|
-
fDone();
|
|
216
|
-
}
|
|
217
|
-
);
|
|
218
|
-
|
|
219
|
-
test
|
|
220
|
-
(
|
|
221
|
-
'should update ortho-corner1',
|
|
222
|
-
function (fDone)
|
|
223
|
-
{
|
|
224
|
-
let tmpConn = _MockFlowView._FlowData.Connections[0];
|
|
225
|
-
tmpConn.Data = {};
|
|
226
|
-
|
|
227
|
-
_HandleManager.updateConnectionHandle('c1', 'ortho-corner1', 250, 80);
|
|
228
|
-
|
|
229
|
-
libExpect(tmpConn.Data.HandleCustomized).to.be.true;
|
|
230
|
-
libExpect(tmpConn.Data.OrthoCorner1X).to.equal(250);
|
|
231
|
-
libExpect(tmpConn.Data.OrthoCorner1Y).to.equal(80);
|
|
232
|
-
fDone();
|
|
233
|
-
}
|
|
234
|
-
);
|
|
235
|
-
|
|
236
|
-
test
|
|
237
|
-
(
|
|
238
|
-
'should update ortho-corner2',
|
|
239
|
-
function (fDone)
|
|
240
|
-
{
|
|
241
|
-
let tmpConn = _MockFlowView._FlowData.Connections[0];
|
|
242
|
-
tmpConn.Data = {};
|
|
243
|
-
|
|
244
|
-
_HandleManager.updateConnectionHandle('c1', 'ortho-corner2', 350, 120);
|
|
245
|
-
|
|
246
|
-
libExpect(tmpConn.Data.OrthoCorner2X).to.equal(350);
|
|
247
|
-
libExpect(tmpConn.Data.OrthoCorner2Y).to.equal(120);
|
|
248
|
-
fDone();
|
|
249
|
-
}
|
|
250
|
-
);
|
|
251
|
-
|
|
252
|
-
test
|
|
253
|
-
(
|
|
254
|
-
'should compute OrthoMidOffset for horizontal departure',
|
|
255
|
-
function (fDone)
|
|
256
|
-
{
|
|
257
|
-
let tmpConn = _MockFlowView._FlowData.Connections[0];
|
|
258
|
-
tmpConn.Data = {};
|
|
259
|
-
|
|
260
|
-
_HandleManager.updateConnectionHandle('c1', 'ortho-midpoint', 300, 100);
|
|
261
|
-
|
|
262
|
-
libExpect(tmpConn.Data.OrthoMidOffset).to.be.a('number');
|
|
263
|
-
fDone();
|
|
264
|
-
}
|
|
265
|
-
);
|
|
266
|
-
|
|
267
|
-
test
|
|
268
|
-
(
|
|
269
|
-
'should call _renderSingleConnection for real-time feedback',
|
|
270
|
-
function (fDone)
|
|
271
|
-
{
|
|
272
|
-
let tmpRenderCalled = false;
|
|
273
|
-
_MockFlowView._renderSingleConnection = function () { tmpRenderCalled = true; };
|
|
274
|
-
|
|
275
|
-
let tmpConn = _MockFlowView._FlowData.Connections[0];
|
|
276
|
-
tmpConn.Data = {};
|
|
277
|
-
|
|
278
|
-
_HandleManager.updateConnectionHandle('c1', 'ortho-corner1', 250, 80);
|
|
279
|
-
|
|
280
|
-
libExpect(tmpRenderCalled).to.be.true;
|
|
281
|
-
fDone();
|
|
282
|
-
}
|
|
283
|
-
);
|
|
284
|
-
|
|
285
|
-
test
|
|
286
|
-
(
|
|
287
|
-
'should do nothing for non-existent connection',
|
|
288
|
-
function (fDone)
|
|
289
|
-
{
|
|
290
|
-
// Should not throw
|
|
291
|
-
_HandleManager.updateConnectionHandle('non-existent', 'bezier-midpoint', 100, 100);
|
|
292
|
-
fDone();
|
|
293
|
-
}
|
|
294
|
-
);
|
|
295
|
-
|
|
296
|
-
test
|
|
297
|
-
(
|
|
298
|
-
'should do nothing when no FlowView',
|
|
299
|
-
function (fDone)
|
|
300
|
-
{
|
|
301
|
-
let tmpManager = new libConnectionHandleManager(_Fable, {}, 'NoView');
|
|
302
|
-
tmpManager.updateConnectionHandle('c1', 'bezier-midpoint', 100, 100);
|
|
303
|
-
fDone();
|
|
304
|
-
}
|
|
305
|
-
);
|
|
306
|
-
}
|
|
307
|
-
);
|
|
308
|
-
|
|
309
|
-
// ---- addConnectionHandle ----
|
|
310
|
-
|
|
311
|
-
suite
|
|
312
|
-
(
|
|
313
|
-
'addConnectionHandle',
|
|
314
|
-
function ()
|
|
315
|
-
{
|
|
316
|
-
test
|
|
317
|
-
(
|
|
318
|
-
'should add a handle to a connection',
|
|
319
|
-
function (fDone)
|
|
320
|
-
{
|
|
321
|
-
let tmpConn = _MockFlowView._FlowData.Connections[0];
|
|
322
|
-
tmpConn.Data = {};
|
|
323
|
-
|
|
324
|
-
_HandleManager.addConnectionHandle('c1', 250, 150);
|
|
325
|
-
|
|
326
|
-
libExpect(tmpConn.Data.BezierHandles).to.have.length(1);
|
|
327
|
-
libExpect(tmpConn.Data.BezierHandles[0].x).to.equal(250);
|
|
328
|
-
libExpect(tmpConn.Data.BezierHandles[0].y).to.equal(150);
|
|
329
|
-
libExpect(tmpConn.Data.HandleCustomized).to.be.true;
|
|
330
|
-
libExpect(tmpConn.Data.LineMode).to.equal('bezier');
|
|
331
|
-
fDone();
|
|
332
|
-
}
|
|
333
|
-
);
|
|
334
|
-
|
|
335
|
-
test
|
|
336
|
-
(
|
|
337
|
-
'should migrate legacy format before adding',
|
|
338
|
-
function (fDone)
|
|
339
|
-
{
|
|
340
|
-
let tmpConn = _MockFlowView._FlowData.Connections[0];
|
|
341
|
-
tmpConn.Data = { BezierHandleX: 200, BezierHandleY: 100 };
|
|
342
|
-
|
|
343
|
-
_HandleManager.addConnectionHandle('c1', 300, 200);
|
|
344
|
-
|
|
345
|
-
// Should have migrated legacy + added new
|
|
346
|
-
libExpect(tmpConn.Data.BezierHandles).to.have.length(2);
|
|
347
|
-
fDone();
|
|
348
|
-
}
|
|
349
|
-
);
|
|
350
|
-
|
|
351
|
-
test
|
|
352
|
-
(
|
|
353
|
-
'should use computeInsertionIndex for placement',
|
|
354
|
-
function (fDone)
|
|
355
|
-
{
|
|
356
|
-
let tmpInsertIndexUsed = false;
|
|
357
|
-
_MockFlowView._ConnectionRenderer.computeInsertionIndex = function ()
|
|
358
|
-
{
|
|
359
|
-
tmpInsertIndexUsed = true;
|
|
360
|
-
return 0;
|
|
361
|
-
};
|
|
362
|
-
|
|
363
|
-
let tmpConn = _MockFlowView._FlowData.Connections[0];
|
|
364
|
-
tmpConn.Data = {};
|
|
365
|
-
|
|
366
|
-
_HandleManager.addConnectionHandle('c1', 250, 150);
|
|
367
|
-
|
|
368
|
-
libExpect(tmpInsertIndexUsed).to.be.true;
|
|
369
|
-
fDone();
|
|
370
|
-
}
|
|
371
|
-
);
|
|
372
|
-
|
|
373
|
-
test
|
|
374
|
-
(
|
|
375
|
-
'should call renderFlow and marshalFromView',
|
|
376
|
-
function (fDone)
|
|
377
|
-
{
|
|
378
|
-
let tmpRenderCalled = false;
|
|
379
|
-
let tmpMarshalCalled = false;
|
|
380
|
-
_MockFlowView.renderFlow = function () { tmpRenderCalled = true; };
|
|
381
|
-
_MockFlowView.marshalFromView = function () { tmpMarshalCalled = true; };
|
|
382
|
-
|
|
383
|
-
let tmpConn = _MockFlowView._FlowData.Connections[0];
|
|
384
|
-
tmpConn.Data = {};
|
|
385
|
-
|
|
386
|
-
_HandleManager.addConnectionHandle('c1', 250, 150);
|
|
387
|
-
|
|
388
|
-
libExpect(tmpRenderCalled).to.be.true;
|
|
389
|
-
libExpect(tmpMarshalCalled).to.be.true;
|
|
390
|
-
fDone();
|
|
391
|
-
}
|
|
392
|
-
);
|
|
393
|
-
|
|
394
|
-
test
|
|
395
|
-
(
|
|
396
|
-
'should fire onFlowChanged event',
|
|
397
|
-
function (fDone)
|
|
398
|
-
{
|
|
399
|
-
let tmpEvents = [];
|
|
400
|
-
_MockFlowView._EventHandlerProvider.fireEvent = function (pEvent) { tmpEvents.push(pEvent); };
|
|
401
|
-
|
|
402
|
-
let tmpConn = _MockFlowView._FlowData.Connections[0];
|
|
403
|
-
tmpConn.Data = {};
|
|
404
|
-
|
|
405
|
-
_HandleManager.addConnectionHandle('c1', 250, 150);
|
|
406
|
-
|
|
407
|
-
libExpect(tmpEvents).to.include('onFlowChanged');
|
|
408
|
-
fDone();
|
|
409
|
-
}
|
|
410
|
-
);
|
|
411
|
-
|
|
412
|
-
test
|
|
413
|
-
(
|
|
414
|
-
'should do nothing for non-existent connection',
|
|
415
|
-
function (fDone)
|
|
416
|
-
{
|
|
417
|
-
_HandleManager.addConnectionHandle('non-existent', 250, 150);
|
|
418
|
-
fDone();
|
|
419
|
-
}
|
|
420
|
-
);
|
|
421
|
-
|
|
422
|
-
test
|
|
423
|
-
(
|
|
424
|
-
'should do nothing when no FlowView',
|
|
425
|
-
function (fDone)
|
|
426
|
-
{
|
|
427
|
-
let tmpManager = new libConnectionHandleManager(_Fable, {}, 'NoView');
|
|
428
|
-
tmpManager.addConnectionHandle('c1', 250, 150);
|
|
429
|
-
fDone();
|
|
430
|
-
}
|
|
431
|
-
);
|
|
432
|
-
}
|
|
433
|
-
);
|
|
434
|
-
|
|
435
|
-
// ---- removeConnectionHandle ----
|
|
436
|
-
|
|
437
|
-
suite
|
|
438
|
-
(
|
|
439
|
-
'removeConnectionHandle',
|
|
440
|
-
function ()
|
|
441
|
-
{
|
|
442
|
-
test
|
|
443
|
-
(
|
|
444
|
-
'should remove a handle by index',
|
|
445
|
-
function (fDone)
|
|
446
|
-
{
|
|
447
|
-
let tmpConn = _MockFlowView._FlowData.Connections[0];
|
|
448
|
-
tmpConn.Data = {
|
|
449
|
-
BezierHandles: [{ x: 200, y: 100 }, { x: 300, y: 150 }],
|
|
450
|
-
HandleCustomized: true
|
|
451
|
-
};
|
|
452
|
-
|
|
453
|
-
_HandleManager.removeConnectionHandle('c1', 0);
|
|
454
|
-
|
|
455
|
-
libExpect(tmpConn.Data.BezierHandles).to.have.length(1);
|
|
456
|
-
libExpect(tmpConn.Data.BezierHandles[0].x).to.equal(300);
|
|
457
|
-
fDone();
|
|
458
|
-
}
|
|
459
|
-
);
|
|
460
|
-
|
|
461
|
-
test
|
|
462
|
-
(
|
|
463
|
-
'should reset HandleCustomized when last handle removed',
|
|
464
|
-
function (fDone)
|
|
465
|
-
{
|
|
466
|
-
let tmpConn = _MockFlowView._FlowData.Connections[0];
|
|
467
|
-
tmpConn.Data = {
|
|
468
|
-
BezierHandles: [{ x: 200, y: 100 }],
|
|
469
|
-
HandleCustomized: true,
|
|
470
|
-
BezierHandleX: 200,
|
|
471
|
-
BezierHandleY: 100
|
|
472
|
-
};
|
|
473
|
-
|
|
474
|
-
_HandleManager.removeConnectionHandle('c1', 0);
|
|
475
|
-
|
|
476
|
-
libExpect(tmpConn.Data.BezierHandles).to.have.length(0);
|
|
477
|
-
libExpect(tmpConn.Data.HandleCustomized).to.be.false;
|
|
478
|
-
libExpect(tmpConn.Data.BezierHandleX).to.be.null;
|
|
479
|
-
libExpect(tmpConn.Data.BezierHandleY).to.be.null;
|
|
480
|
-
fDone();
|
|
481
|
-
}
|
|
482
|
-
);
|
|
483
|
-
|
|
484
|
-
test
|
|
485
|
-
(
|
|
486
|
-
'should do nothing for out-of-range index',
|
|
487
|
-
function (fDone)
|
|
488
|
-
{
|
|
489
|
-
let tmpConn = _MockFlowView._FlowData.Connections[0];
|
|
490
|
-
tmpConn.Data = {
|
|
491
|
-
BezierHandles: [{ x: 200, y: 100 }],
|
|
492
|
-
HandleCustomized: true
|
|
493
|
-
};
|
|
494
|
-
|
|
495
|
-
_HandleManager.removeConnectionHandle('c1', 5);
|
|
496
|
-
libExpect(tmpConn.Data.BezierHandles).to.have.length(1);
|
|
497
|
-
|
|
498
|
-
_HandleManager.removeConnectionHandle('c1', -1);
|
|
499
|
-
libExpect(tmpConn.Data.BezierHandles).to.have.length(1);
|
|
500
|
-
fDone();
|
|
501
|
-
}
|
|
502
|
-
);
|
|
503
|
-
|
|
504
|
-
test
|
|
505
|
-
(
|
|
506
|
-
'should do nothing when no BezierHandles array',
|
|
507
|
-
function (fDone)
|
|
508
|
-
{
|
|
509
|
-
let tmpConn = _MockFlowView._FlowData.Connections[0];
|
|
510
|
-
tmpConn.Data = {};
|
|
511
|
-
|
|
512
|
-
_HandleManager.removeConnectionHandle('c1', 0);
|
|
513
|
-
// Should not throw
|
|
514
|
-
fDone();
|
|
515
|
-
}
|
|
516
|
-
);
|
|
517
|
-
|
|
518
|
-
test
|
|
519
|
-
(
|
|
520
|
-
'should do nothing for non-existent connection',
|
|
521
|
-
function (fDone)
|
|
522
|
-
{
|
|
523
|
-
_HandleManager.removeConnectionHandle('non-existent', 0);
|
|
524
|
-
fDone();
|
|
525
|
-
}
|
|
526
|
-
);
|
|
527
|
-
|
|
528
|
-
test
|
|
529
|
-
(
|
|
530
|
-
'should call renderFlow and marshalFromView',
|
|
531
|
-
function (fDone)
|
|
532
|
-
{
|
|
533
|
-
let tmpRenderCalled = false;
|
|
534
|
-
let tmpMarshalCalled = false;
|
|
535
|
-
_MockFlowView.renderFlow = function () { tmpRenderCalled = true; };
|
|
536
|
-
_MockFlowView.marshalFromView = function () { tmpMarshalCalled = true; };
|
|
537
|
-
|
|
538
|
-
let tmpConn = _MockFlowView._FlowData.Connections[0];
|
|
539
|
-
tmpConn.Data = {
|
|
540
|
-
BezierHandles: [{ x: 200, y: 100 }],
|
|
541
|
-
HandleCustomized: true
|
|
542
|
-
};
|
|
543
|
-
|
|
544
|
-
_HandleManager.removeConnectionHandle('c1', 0);
|
|
545
|
-
|
|
546
|
-
libExpect(tmpRenderCalled).to.be.true;
|
|
547
|
-
libExpect(tmpMarshalCalled).to.be.true;
|
|
548
|
-
fDone();
|
|
549
|
-
}
|
|
550
|
-
);
|
|
551
|
-
}
|
|
552
|
-
);
|
|
553
|
-
|
|
554
|
-
// ---- resetHandlesForNode ----
|
|
555
|
-
|
|
556
|
-
suite
|
|
557
|
-
(
|
|
558
|
-
'resetHandlesForNode',
|
|
559
|
-
function ()
|
|
560
|
-
{
|
|
561
|
-
test
|
|
562
|
-
(
|
|
563
|
-
'should reset customized handles for connections involving the node',
|
|
564
|
-
function (fDone)
|
|
565
|
-
{
|
|
566
|
-
let tmpConn = _MockFlowView._FlowData.Connections[0];
|
|
567
|
-
tmpConn.Data =
|
|
568
|
-
{
|
|
569
|
-
HandleCustomized: true,
|
|
570
|
-
BezierHandleX: 200,
|
|
571
|
-
BezierHandleY: 100,
|
|
572
|
-
OrthoCorner1X: 150,
|
|
573
|
-
OrthoCorner1Y: 80,
|
|
574
|
-
OrthoCorner2X: 350,
|
|
575
|
-
OrthoCorner2Y: 120,
|
|
576
|
-
OrthoMidOffset: 25
|
|
577
|
-
};
|
|
578
|
-
|
|
579
|
-
_HandleManager.resetHandlesForNode('n1');
|
|
580
|
-
|
|
581
|
-
libExpect(tmpConn.Data.HandleCustomized).to.be.false;
|
|
582
|
-
libExpect(tmpConn.Data.BezierHandleX).to.be.null;
|
|
583
|
-
libExpect(tmpConn.Data.BezierHandleY).to.be.null;
|
|
584
|
-
libExpect(tmpConn.Data.OrthoCorner1X).to.be.null;
|
|
585
|
-
libExpect(tmpConn.Data.OrthoCorner1Y).to.be.null;
|
|
586
|
-
libExpect(tmpConn.Data.OrthoCorner2X).to.be.null;
|
|
587
|
-
libExpect(tmpConn.Data.OrthoCorner2Y).to.be.null;
|
|
588
|
-
libExpect(tmpConn.Data.OrthoMidOffset).to.equal(0);
|
|
589
|
-
fDone();
|
|
590
|
-
}
|
|
591
|
-
);
|
|
592
|
-
|
|
593
|
-
test
|
|
594
|
-
(
|
|
595
|
-
'should not reset connections not involving the node',
|
|
596
|
-
function (fDone)
|
|
597
|
-
{
|
|
598
|
-
_MockFlowView._FlowData.Connections.push({
|
|
599
|
-
Hash: 'c2',
|
|
600
|
-
SourceNodeHash: 'n3',
|
|
601
|
-
TargetNodeHash: 'n4',
|
|
602
|
-
Data: { HandleCustomized: true, BezierHandleX: 500 }
|
|
603
|
-
});
|
|
604
|
-
|
|
605
|
-
_HandleManager.resetHandlesForNode('n1');
|
|
606
|
-
|
|
607
|
-
// c2 should be untouched
|
|
608
|
-
let tmpC2 = _MockFlowView._FlowData.Connections.find((c) => c.Hash === 'c2');
|
|
609
|
-
libExpect(tmpC2.Data.HandleCustomized).to.be.true;
|
|
610
|
-
libExpect(tmpC2.Data.BezierHandleX).to.equal(500);
|
|
611
|
-
fDone();
|
|
612
|
-
}
|
|
613
|
-
);
|
|
614
|
-
|
|
615
|
-
test
|
|
616
|
-
(
|
|
617
|
-
'should call TetherService.resetHandlesForNode',
|
|
618
|
-
function (fDone)
|
|
619
|
-
{
|
|
620
|
-
let tmpTetherResetCalled = false;
|
|
621
|
-
_MockFlowView._TetherService.resetHandlesForNode = function ()
|
|
622
|
-
{
|
|
623
|
-
tmpTetherResetCalled = true;
|
|
624
|
-
};
|
|
625
|
-
|
|
626
|
-
_HandleManager.resetHandlesForNode('n1');
|
|
627
|
-
|
|
628
|
-
libExpect(tmpTetherResetCalled).to.be.true;
|
|
629
|
-
fDone();
|
|
630
|
-
}
|
|
631
|
-
);
|
|
632
|
-
|
|
633
|
-
test
|
|
634
|
-
(
|
|
635
|
-
'should skip connections without Data',
|
|
636
|
-
function (fDone)
|
|
637
|
-
{
|
|
638
|
-
_MockFlowView._FlowData.Connections[0].Data = null;
|
|
639
|
-
// Should not throw
|
|
640
|
-
_HandleManager.resetHandlesForNode('n1');
|
|
641
|
-
fDone();
|
|
642
|
-
}
|
|
643
|
-
);
|
|
644
|
-
|
|
645
|
-
test
|
|
646
|
-
(
|
|
647
|
-
'should do nothing when no FlowView',
|
|
648
|
-
function (fDone)
|
|
649
|
-
{
|
|
650
|
-
let tmpManager = new libConnectionHandleManager(_Fable, {}, 'NoView');
|
|
651
|
-
tmpManager.resetHandlesForNode('n1');
|
|
652
|
-
fDone();
|
|
653
|
-
}
|
|
654
|
-
);
|
|
655
|
-
}
|
|
656
|
-
);
|
|
657
|
-
|
|
658
|
-
// ---- resetHandlesForPanel ----
|
|
659
|
-
|
|
660
|
-
suite
|
|
661
|
-
(
|
|
662
|
-
'resetHandlesForPanel',
|
|
663
|
-
function ()
|
|
664
|
-
{
|
|
665
|
-
test
|
|
666
|
-
(
|
|
667
|
-
'should call TetherService.resetHandlePositions for the panel',
|
|
668
|
-
function (fDone)
|
|
669
|
-
{
|
|
670
|
-
let tmpResetPanel = null;
|
|
671
|
-
_MockFlowView._TetherService.resetHandlePositions = function (pPanel)
|
|
672
|
-
{
|
|
673
|
-
tmpResetPanel = pPanel;
|
|
674
|
-
};
|
|
675
|
-
|
|
676
|
-
_MockFlowView._FlowData.OpenPanels = [{ Hash: 'panel-1', NodeHash: 'n1' }];
|
|
677
|
-
|
|
678
|
-
_HandleManager.resetHandlesForPanel('panel-1');
|
|
679
|
-
|
|
680
|
-
libExpect(tmpResetPanel).to.not.be.null;
|
|
681
|
-
libExpect(tmpResetPanel.Hash).to.equal('panel-1');
|
|
682
|
-
fDone();
|
|
683
|
-
}
|
|
684
|
-
);
|
|
685
|
-
|
|
686
|
-
test
|
|
687
|
-
(
|
|
688
|
-
'should do nothing for non-existent panel',
|
|
689
|
-
function (fDone)
|
|
690
|
-
{
|
|
691
|
-
let tmpResetCalled = false;
|
|
692
|
-
_MockFlowView._TetherService.resetHandlePositions = function ()
|
|
693
|
-
{
|
|
694
|
-
tmpResetCalled = true;
|
|
695
|
-
};
|
|
696
|
-
|
|
697
|
-
_HandleManager.resetHandlesForPanel('non-existent');
|
|
698
|
-
|
|
699
|
-
libExpect(tmpResetCalled).to.be.false;
|
|
700
|
-
fDone();
|
|
701
|
-
}
|
|
702
|
-
);
|
|
703
|
-
|
|
704
|
-
test
|
|
705
|
-
(
|
|
706
|
-
'should do nothing when no FlowView',
|
|
707
|
-
function (fDone)
|
|
708
|
-
{
|
|
709
|
-
let tmpManager = new libConnectionHandleManager(_Fable, {}, 'NoView');
|
|
710
|
-
tmpManager.resetHandlesForPanel('panel-1');
|
|
711
|
-
fDone();
|
|
712
|
-
}
|
|
713
|
-
);
|
|
714
|
-
}
|
|
715
|
-
);
|
|
716
|
-
}
|
|
717
|
-
);
|