pict-section-flow 1.4.0 → 2.0.1

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.
Files changed (164) hide show
  1. package/package.json +7 -2
  2. package/source/Pict-Section-Flow.js +20 -14
  3. package/source/providers/PictProvider-Flow-Background.js +303 -0
  4. package/source/providers/PictProvider-Flow-CSS.js +73 -7
  5. package/source/providers/PictProvider-Flow-Geometry.js +11 -421
  6. package/source/providers/PictProvider-Flow-Icons.js +12 -0
  7. package/source/providers/PictProvider-Flow-Layouts.js +107 -0
  8. package/source/services/PictService-Flow-ConnectionRenderer.js +1 -1
  9. package/source/services/PictService-Flow-CursorManager.js +113 -0
  10. package/source/services/PictService-Flow-InteractionManager.js +439 -59
  11. package/source/services/PictService-Flow-Layout.js +21 -16
  12. package/source/services/PictService-Flow-PathGenerator.js +30 -417
  13. package/source/services/PictService-Flow-RenderManager.js +23 -3
  14. package/source/services/PictService-Flow-ViewportManager.js +102 -0
  15. package/source/views/PictView-Flow-FloatingToolbar.js +5 -1
  16. package/source/views/PictView-Flow-Node.js +29 -0
  17. package/source/views/PictView-Flow-Toolbar.js +50 -3
  18. package/source/views/PictView-Flow.js +591 -2
  19. package/.claude/launch.json +0 -11
  20. package/docs/.nojekyll +0 -0
  21. package/docs/Architecture.md +0 -163
  22. package/docs/Custom-Styling.md +0 -275
  23. package/docs/Data_Model.md +0 -149
  24. package/docs/Event_System.md +0 -156
  25. package/docs/Getting_Started.md +0 -237
  26. package/docs/Implementation_Reference.md +0 -528
  27. package/docs/Layout_Persistence.md +0 -117
  28. package/docs/README.md +0 -103
  29. package/docs/Theme_Integration.md +0 -150
  30. package/docs/_brand.json +0 -18
  31. package/docs/_cover.md +0 -17
  32. package/docs/_playground.json +0 -24
  33. package/docs/_sidebar.md +0 -57
  34. package/docs/_topbar.md +0 -8
  35. package/docs/_version.json +0 -7
  36. package/docs/api/PictFlowCard.md +0 -216
  37. package/docs/api/PictFlowCardPropertiesPanel.md +0 -235
  38. package/docs/api/addConnection.md +0 -101
  39. package/docs/api/addNode.md +0 -137
  40. package/docs/api/autoLayout.md +0 -77
  41. package/docs/api/getFlowData.md +0 -112
  42. package/docs/api/marshalToView.md +0 -95
  43. package/docs/api/openPanel.md +0 -128
  44. package/docs/api/registerHandler.md +0 -174
  45. package/docs/api/registerNodeType.md +0 -142
  46. package/docs/api/removeConnection.md +0 -57
  47. package/docs/api/removeNode.md +0 -80
  48. package/docs/api/saveLayout.md +0 -152
  49. package/docs/api/screenToSVGCoords.md +0 -68
  50. package/docs/api/selectNode.md +0 -116
  51. package/docs/api/setTheme.md +0 -168
  52. package/docs/api/setZoom.md +0 -97
  53. package/docs/api/toggleFullscreen.md +0 -68
  54. package/docs/card-help/EACH.md +0 -19
  55. package/docs/card-help/FREAD.md +0 -24
  56. package/docs/card-help/FWRITE.md +0 -24
  57. package/docs/card-help/GET.md +0 -22
  58. package/docs/card-help/ITE.md +0 -23
  59. package/docs/card-help/LOG.md +0 -23
  60. package/docs/card-help/NOTE.md +0 -17
  61. package/docs/card-help/PREV.md +0 -18
  62. package/docs/card-help/SET.md +0 -27
  63. package/docs/card-help/SPKL.md +0 -22
  64. package/docs/card-help/STAT.md +0 -23
  65. package/docs/card-help/SW.md +0 -25
  66. package/docs/diagrams/architecture-at-a-glance.excalidraw +0 -4270
  67. package/docs/diagrams/architecture-at-a-glance.mmd +0 -30
  68. package/docs/diagrams/architecture-at-a-glance.svg +0 -2
  69. package/docs/diagrams/data-flow.excalidraw +0 -1451
  70. package/docs/diagrams/data-flow.mmd +0 -17
  71. package/docs/diagrams/data-flow.svg +0 -2
  72. package/docs/diagrams/high-level-design.excalidraw +0 -5767
  73. package/docs/diagrams/high-level-design.mmd +0 -86
  74. package/docs/diagrams/high-level-design.svg +0 -2
  75. package/docs/diagrams/relationships.excalidraw +0 -3852
  76. package/docs/diagrams/relationships.mmd +0 -9
  77. package/docs/diagrams/relationships.svg +0 -2
  78. package/docs/diagrams/service-initialization-sequence.excalidraw +0 -1466
  79. package/docs/diagrams/service-initialization-sequence.mmd +0 -19
  80. package/docs/diagrams/service-initialization-sequence.svg +0 -2
  81. package/docs/diagrams/svg-layer-structure.excalidraw +0 -1060
  82. package/docs/diagrams/svg-layer-structure.mmd +0 -18
  83. package/docs/diagrams/svg-layer-structure.svg +0 -2
  84. package/docs/examples/README.md +0 -9
  85. package/docs/examples/simple_cards/README.md +0 -677
  86. package/docs/examples/simple_cards/css/flowexample.css +0 -65
  87. package/docs/examples/simple_cards/index.html +0 -32
  88. package/docs/examples/simple_cards/js/pict.min.js +0 -12
  89. package/docs/examples/simple_cards/pict-section-flow-example-simple-cards.compatible.min.js +0 -1
  90. package/docs/index.html +0 -38
  91. package/docs/playground/app.json +0 -6
  92. package/docs/playground/appdata.json +0 -85
  93. package/docs/playground/application.js +0 -23
  94. package/docs/playground/pict.json +0 -17
  95. package/docs/playground/runtime/pict-application.min.js +0 -2
  96. package/docs/playground/runtime/pict-section-flow.min.js +0 -2
  97. package/docs/playground/runtime/pict-section-modal.min.js +0 -2
  98. package/docs/playground/runtime/pict.min.js +0 -12
  99. package/docs/retold-catalog.json +0 -244
  100. package/docs/retold-keyword-index.json +0 -26028
  101. package/example_applications/simple_cards/css/flowexample.css +0 -65
  102. package/example_applications/simple_cards/html/index.html +0 -32
  103. package/example_applications/simple_cards/package.json +0 -52
  104. package/example_applications/simple_cards/source/Pict-Application-FlowExample-Configuration.json +0 -15
  105. package/example_applications/simple_cards/source/Pict-Application-FlowExample.js +0 -539
  106. package/example_applications/simple_cards/source/card-help-content.js +0 -16
  107. package/example_applications/simple_cards/source/cards/FlowCard-Comment.js +0 -38
  108. package/example_applications/simple_cards/source/cards/FlowCard-DataPreview.js +0 -44
  109. package/example_applications/simple_cards/source/cards/FlowCard-Each.js +0 -38
  110. package/example_applications/simple_cards/source/cards/FlowCard-FileRead.js +0 -56
  111. package/example_applications/simple_cards/source/cards/FlowCard-FileWrite.js +0 -50
  112. package/example_applications/simple_cards/source/cards/FlowCard-GetValue.js +0 -37
  113. package/example_applications/simple_cards/source/cards/FlowCard-IfThenElse.js +0 -49
  114. package/example_applications/simple_cards/source/cards/FlowCard-LogValues.js +0 -55
  115. package/example_applications/simple_cards/source/cards/FlowCard-SetValue.js +0 -97
  116. package/example_applications/simple_cards/source/cards/FlowCard-Sparkline.js +0 -100
  117. package/example_applications/simple_cards/source/cards/FlowCard-StatusMonitor.js +0 -46
  118. package/example_applications/simple_cards/source/cards/FlowCard-Switch.js +0 -39
  119. package/example_applications/simple_cards/source/providers/PictRouter-FlowExample-Configuration.json +0 -22
  120. package/example_applications/simple_cards/source/sample-flows.js +0 -410
  121. package/example_applications/simple_cards/source/views/PictView-FlowExample-About.js +0 -184
  122. package/example_applications/simple_cards/source/views/PictView-FlowExample-BottomBar.js +0 -77
  123. package/example_applications/simple_cards/source/views/PictView-FlowExample-Documentation.js +0 -325
  124. package/example_applications/simple_cards/source/views/PictView-FlowExample-FileWriteInfo.js +0 -59
  125. package/example_applications/simple_cards/source/views/PictView-FlowExample-Layout.js +0 -90
  126. package/example_applications/simple_cards/source/views/PictView-FlowExample-MainWorkspace.js +0 -453
  127. package/example_applications/simple_cards/source/views/PictView-FlowExample-TopBar.js +0 -95
  128. package/scripts/generate-card-help.js +0 -214
  129. package/source/providers/edges/Edge-Bezier.js +0 -41
  130. package/source/providers/edges/Edge-Orthogonal.js +0 -37
  131. package/source/providers/edges/Edge-OrthogonalSnap.js +0 -72
  132. package/source/providers/edges/Edge-Perimeter-Linear.js +0 -31
  133. package/source/providers/edges/Edge-Perimeter-Orthogonal.js +0 -39
  134. package/source/providers/edges/Edge-Perimeter.js +0 -48
  135. package/source/providers/edges/Edge-PerimeterMath.js +0 -92
  136. package/source/providers/edges/Edge-Straight.js +0 -24
  137. package/source/providers/layouts/Layout-Circular.js +0 -203
  138. package/source/providers/layouts/Layout-Coerce.js +0 -40
  139. package/source/providers/layouts/Layout-Columnar.js +0 -134
  140. package/source/providers/layouts/Layout-Custom.js +0 -27
  141. package/source/providers/layouts/Layout-ForcedFromCenter.js +0 -256
  142. package/source/providers/layouts/Layout-Grid.js +0 -134
  143. package/source/providers/layouts/Layout-Layered.js +0 -155
  144. package/source/providers/layouts/Layout-Rank.js +0 -141
  145. package/source/providers/layouts/Layout-Staggered.js +0 -131
  146. package/source/providers/layouts/Layout-Tabular.js +0 -94
  147. package/test/CardPalette_tests.js +0 -43
  148. package/test/ConnectionHandleManager_tests.js +0 -717
  149. package/test/ConnectionRenderer_tests.js +0 -591
  150. package/test/ConnectionStyle_tests.js +0 -90
  151. package/test/DataManager_tests.js +0 -859
  152. package/test/Geometry_tests.js +0 -767
  153. package/test/InteractionManager_tests.js +0 -279
  154. package/test/Layout_tests.js +0 -1604
  155. package/test/NodeView_tests.js +0 -66
  156. package/test/PanelManager_tests.js +0 -172
  157. package/test/PathGenerator_tests.js +0 -978
  158. package/test/PortRenderer_tests.js +0 -376
  159. package/test/RenderManager_tests.js +0 -756
  160. package/test/Renderer_tests.js +0 -133
  161. package/test/SelectionManager_tests.js +0 -185
  162. package/test/StylePresets_tests.js +0 -153
  163. package/test/ToolbarExtraButtons_tests.js +0 -138
  164. package/test/UndirectedConnections_tests.js +0 -70
@@ -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
- );