bpmn-js 0.20.3 → 0.20.7
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/.travis.yml +2 -0
- package/lib/draw/BpmnRenderer.js +3 -2
- package/lib/features/copy-paste/BpmnCopyPaste.js +11 -2
- package/lib/features/modeling/BpmnUpdater.js +17 -13
- package/lib/features/modeling/ElementFactory.js +36 -19
- package/lib/features/modeling/Modeling.js +5 -1
- package/lib/features/modeling/behavior/ReplaceElementBehaviour.js +4 -2
- package/lib/features/modeling/behavior/util/LabelLayoutUtil.js +3 -2
- package/lib/features/modeling/behavior/util/LineAttachmentUtil.js +36 -30
- package/lib/features/rules/BpmnRules.js +29 -11
- package/package.json +20 -20
- package/test/integration/CustomElementsSpec.js +2 -5
- package/test/spec/features/copy-paste/BpmnCopyPasteSpec.js +33 -0
- package/test/spec/features/modeling/LabelLayoutingSpec.js +211 -232
- package/test/spec/features/modeling/behavior/util/LabelLayoutUtilSpec.js +75 -0
- package/test/spec/features/modeling/behavior/util/LineAttachmentUtilSpec.js +55 -7
- package/test/spec/features/rules/BpmnRulesSpec.js +108 -64
|
@@ -75,26 +75,28 @@ describe('modeling - label layouting', function() {
|
|
|
75
75
|
|
|
76
76
|
describe('on segment move', function() {
|
|
77
77
|
|
|
78
|
-
it('label name not set -> move label to waypoints mid', inject(
|
|
78
|
+
it('label name not set -> move label to waypoints mid', inject(
|
|
79
|
+
function(modeling, elementRegistry, connectionSegmentMove, dragging) {
|
|
79
80
|
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
81
|
+
// given
|
|
82
|
+
var connection = elementRegistry.get('SequenceFlow_C'),
|
|
83
|
+
labelPosition = getLabelPosition(connection);
|
|
83
84
|
|
|
84
|
-
|
|
85
|
-
|
|
85
|
+
connection.label.businessObject.name = false;
|
|
86
|
+
connection.label.hidden = true;
|
|
86
87
|
|
|
87
|
-
|
|
88
|
-
|
|
88
|
+
// when
|
|
89
|
+
connectionSegmentMove.start(canvasEvent({ x: 0, y: 0 }), connection, 2);
|
|
89
90
|
|
|
90
|
-
|
|
91
|
+
dragging.move(canvasEvent({ x: 0, y: 50 }));
|
|
91
92
|
|
|
92
|
-
|
|
93
|
+
dragging.end();
|
|
93
94
|
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
95
|
+
// then
|
|
96
|
+
expect(connection.label.y - labelPosition.y).to.be.within(13, 16);
|
|
97
|
+
expect(connection.label.x - labelPosition.x).to.be.within(-87, -85);
|
|
98
|
+
}
|
|
99
|
+
));
|
|
98
100
|
|
|
99
101
|
|
|
100
102
|
it('left - no relayout', inject(function(elementRegistry, connectionSegmentMove, dragging) {
|
|
@@ -115,58 +117,64 @@ describe('modeling - label layouting', function() {
|
|
|
115
117
|
}));
|
|
116
118
|
|
|
117
119
|
|
|
118
|
-
it('left - remove bendpoint', inject(
|
|
120
|
+
it('left - remove bendpoint', inject(
|
|
121
|
+
function(elementRegistry, connectionSegmentMove, dragging) {
|
|
119
122
|
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
+
// given
|
|
124
|
+
var connection = elementRegistry.get('SequenceFlow_B'),
|
|
125
|
+
labelPosition = getLabelPosition(connection);
|
|
123
126
|
|
|
124
|
-
|
|
125
|
-
|
|
127
|
+
// when
|
|
128
|
+
connectionSegmentMove.start(canvasEvent({ x: 0, y: 0 }), connection, 2);
|
|
126
129
|
|
|
127
|
-
|
|
130
|
+
dragging.move(canvasEvent({ x: -70, y: 0 }));
|
|
128
131
|
|
|
129
|
-
|
|
132
|
+
dragging.end();
|
|
130
133
|
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
+
// then
|
|
135
|
+
expectLabelMoved(connection, labelPosition, { x: -70, y: 24 });
|
|
136
|
+
}
|
|
137
|
+
));
|
|
134
138
|
|
|
135
139
|
|
|
136
|
-
it('right - no relayout', inject(
|
|
140
|
+
it('right - no relayout', inject(
|
|
141
|
+
function(elementRegistry, connectionSegmentMove, dragging) {
|
|
137
142
|
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
143
|
+
// given
|
|
144
|
+
var connection = elementRegistry.get('SequenceFlow_B'),
|
|
145
|
+
labelPosition = getLabelPosition(connection);
|
|
141
146
|
|
|
142
|
-
|
|
143
|
-
|
|
147
|
+
// when
|
|
148
|
+
connectionSegmentMove.start(canvasEvent({ x: 0, y: 0 }), connection, 2);
|
|
144
149
|
|
|
145
|
-
|
|
150
|
+
dragging.move(canvasEvent({ x: 30, y: 0 }));
|
|
146
151
|
|
|
147
|
-
|
|
152
|
+
dragging.end();
|
|
148
153
|
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
154
|
+
// then
|
|
155
|
+
expectLabelMoved(connection, labelPosition, { x: 30, y: 0 });
|
|
156
|
+
}
|
|
157
|
+
));
|
|
152
158
|
|
|
153
159
|
|
|
154
|
-
it('right - remove bendpoint', inject(
|
|
160
|
+
it('right - remove bendpoint', inject(
|
|
161
|
+
function(elementRegistry, connectionSegmentMove, dragging) {
|
|
155
162
|
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
163
|
+
// given
|
|
164
|
+
var connection = elementRegistry.get('SequenceFlow_B'),
|
|
165
|
+
labelPosition = getLabelPosition(connection);
|
|
159
166
|
|
|
160
|
-
|
|
161
|
-
|
|
167
|
+
// when
|
|
168
|
+
connectionSegmentMove.start(canvasEvent({ x: 0, y: 0 }), connection, 2);
|
|
162
169
|
|
|
163
|
-
|
|
170
|
+
dragging.move(canvasEvent({ x: 70, y: 0 }));
|
|
164
171
|
|
|
165
|
-
|
|
172
|
+
dragging.end();
|
|
166
173
|
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
174
|
+
// then
|
|
175
|
+
expectLabelMoved(connection, labelPosition, { x: 70, y: -16 });
|
|
176
|
+
}
|
|
177
|
+
));
|
|
170
178
|
|
|
171
179
|
|
|
172
180
|
it('down', inject(function(elementRegistry, connectionSegmentMove, dragging) {
|
|
@@ -188,50 +196,54 @@ describe('modeling - label layouting', function() {
|
|
|
188
196
|
}));
|
|
189
197
|
|
|
190
198
|
|
|
191
|
-
it('up - remove two bendpoints', inject(
|
|
199
|
+
it('up - remove two bendpoints', inject(
|
|
200
|
+
function(elementRegistry, connectionSegmentMove, dragging) {
|
|
192
201
|
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
202
|
+
// given
|
|
203
|
+
var connection = elementRegistry.get('SequenceFlow_C'),
|
|
204
|
+
labelPosition = getLabelPosition(connection);
|
|
196
205
|
|
|
197
|
-
|
|
198
|
-
|
|
206
|
+
// when
|
|
207
|
+
connectionSegmentMove.start(canvasEvent({ x: 0, y: 0 }), connection, 2);
|
|
199
208
|
|
|
200
|
-
|
|
209
|
+
dragging.move(canvasEvent({ x: 0, y: -90 }));
|
|
201
210
|
|
|
202
|
-
|
|
211
|
+
dragging.end();
|
|
203
212
|
|
|
204
|
-
|
|
205
|
-
|
|
213
|
+
// then
|
|
214
|
+
expectLabelMoved(connection, labelPosition, { x: -39, y: -85 });
|
|
206
215
|
|
|
207
|
-
|
|
216
|
+
}
|
|
217
|
+
));
|
|
208
218
|
|
|
209
219
|
|
|
210
220
|
// TODO(@janstuemmel): solve by connectionSegmentMove refactoring
|
|
211
|
-
it('up - remove two bendpoints - redundant waypoints', inject(
|
|
221
|
+
it('up - remove two bendpoints - redundant waypoints', inject(
|
|
222
|
+
function(elementRegistry, connectionSegmentMove, dragging, bendpointMove) {
|
|
212
223
|
|
|
213
|
-
|
|
214
|
-
|
|
224
|
+
// given
|
|
225
|
+
var connection = elementRegistry.get('SequenceFlow_C');
|
|
215
226
|
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
227
|
+
bendpointMove.start(canvasEvent({ x: 0, y: 0 }), connection, 1);
|
|
228
|
+
dragging.move(canvasEvent({ x: 620, y: 435 }));
|
|
229
|
+
dragging.end();
|
|
219
230
|
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
231
|
+
bendpointMove.start(canvasEvent({ x: 0, y: 0 }), connection, 2);
|
|
232
|
+
dragging.move(canvasEvent({ x: 300, y: 435 }));
|
|
233
|
+
dragging.end();
|
|
223
234
|
|
|
224
|
-
|
|
235
|
+
var labelPosition = getLabelPosition(connection);
|
|
225
236
|
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
237
|
+
// when
|
|
238
|
+
connectionSegmentMove.start(canvasEvent({ x: 0, y: 0 }), connection, 2);
|
|
239
|
+
dragging.move(canvasEvent({ x: 0, y: -160 }));
|
|
240
|
+
dragging.end();
|
|
230
241
|
|
|
231
|
-
|
|
232
|
-
|
|
242
|
+
// then
|
|
243
|
+
expect(getLabelPosition(connection)).to.not.eql(labelPosition);
|
|
233
244
|
|
|
234
|
-
|
|
245
|
+
}
|
|
246
|
+
));
|
|
235
247
|
|
|
236
248
|
});
|
|
237
249
|
|
|
@@ -314,245 +326,212 @@ describe('modeling - label layouting', function() {
|
|
|
314
326
|
}));
|
|
315
327
|
|
|
316
328
|
|
|
317
|
-
it('move, label on bendpoint', inject(
|
|
329
|
+
it('move, label on bendpoint', inject(
|
|
330
|
+
function(elementRegistry, bendpointMove, dragging, modeling) {
|
|
318
331
|
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
// label out of segments, on a bendpoint (idx=1)
|
|
323
|
-
modeling.moveShape(connection.label, { x: 40, y: 0 });
|
|
332
|
+
// given
|
|
333
|
+
var connection = elementRegistry.get('SequenceFlow_C');
|
|
324
334
|
|
|
325
|
-
|
|
326
|
-
|
|
335
|
+
// label out of segments, on a bendpoint (idx=1)
|
|
336
|
+
modeling.moveShape(connection.label, { x: 40, y: 0 });
|
|
327
337
|
|
|
328
|
-
|
|
338
|
+
// when
|
|
339
|
+
bendpointMove.start(canvasEvent({ x: 0, y: 0 }), connection, 1);
|
|
329
340
|
|
|
330
|
-
|
|
341
|
+
dragging.move(canvasEvent({ x: 455 + 50, y: 500 }));
|
|
331
342
|
|
|
332
|
-
|
|
333
|
-
expect(Math.round(connection.label.x)).to.be.within(517, 519);
|
|
334
|
-
expect(Math.round(connection.label.y)).to.be.equal(507);
|
|
343
|
+
dragging.end();
|
|
335
344
|
|
|
336
|
-
|
|
345
|
+
// then
|
|
346
|
+
expect(Math.round(connection.label.x)).to.be.within(517, 519);
|
|
347
|
+
expect(Math.round(connection.label.y)).to.be.equal(507);
|
|
337
348
|
|
|
349
|
+
}
|
|
350
|
+
));
|
|
338
351
|
|
|
339
|
-
it('remove bendpoint when label on segment', inject(function(elementRegistry, bendpointMove, dragging) {
|
|
340
352
|
|
|
341
|
-
|
|
342
|
-
|
|
353
|
+
it('remove bendpoint when label on segment', inject(
|
|
354
|
+
function(elementRegistry, bendpointMove, dragging) {
|
|
343
355
|
|
|
344
|
-
|
|
345
|
-
|
|
356
|
+
// given
|
|
357
|
+
var connection = elementRegistry.get('SequenceFlow_B');
|
|
346
358
|
|
|
347
|
-
|
|
359
|
+
// when
|
|
360
|
+
bendpointMove.start(canvasEvent({ x: 0, y: 0 }), connection, 1);
|
|
348
361
|
|
|
349
|
-
|
|
362
|
+
dragging.move(canvasEvent({ x: 455, y: 120 + 160 }));
|
|
350
363
|
|
|
351
|
-
|
|
352
|
-
expect(Math.round(connection.label.x)).to.be.within(418, 421);
|
|
353
|
-
expect(Math.round(connection.label.y)).to.be.equal(191);
|
|
364
|
+
dragging.end();
|
|
354
365
|
|
|
355
|
-
|
|
366
|
+
// then
|
|
367
|
+
expect(Math.round(connection.label.x)).to.be.within(418, 421);
|
|
368
|
+
expect(Math.round(connection.label.y)).to.be.equal(191);
|
|
356
369
|
|
|
370
|
+
}
|
|
371
|
+
));
|
|
357
372
|
|
|
358
|
-
it('add bendpoint, label on right segment', inject(function(elementRegistry, bendpointMove, dragging, canvas) {
|
|
359
373
|
|
|
360
|
-
|
|
361
|
-
|
|
374
|
+
it('add bendpoint, label on right segment', inject(
|
|
375
|
+
function(elementRegistry, bendpointMove, dragging, canvas) {
|
|
362
376
|
|
|
363
|
-
|
|
364
|
-
|
|
377
|
+
// given
|
|
378
|
+
var connection = elementRegistry.get('SequenceFlow_A');
|
|
365
379
|
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
gfx: canvas.getGraphics(connection)
|
|
369
|
-
});
|
|
380
|
+
// when
|
|
381
|
+
bendpointMove.start(canvasEvent({ x: 0, y: 0 }), connection, 1, true);
|
|
370
382
|
|
|
371
|
-
|
|
383
|
+
dragging.hover({
|
|
384
|
+
element: connection,
|
|
385
|
+
gfx: canvas.getGraphics(connection)
|
|
386
|
+
});
|
|
372
387
|
|
|
373
|
-
|
|
388
|
+
dragging.move(canvasEvent({ x: 220, y: 200 }));
|
|
374
389
|
|
|
375
|
-
|
|
376
|
-
expect(Math.round(connection.label.x)).to.be.within(248, 251);
|
|
377
|
-
expect(Math.round(connection.label.y)).to.be.equal(152);
|
|
390
|
+
dragging.end();
|
|
378
391
|
|
|
379
|
-
|
|
392
|
+
// then
|
|
393
|
+
expect(Math.round(connection.label.x)).to.be.within(248, 251);
|
|
394
|
+
expect(Math.round(connection.label.y)).to.be.equal(152);
|
|
380
395
|
|
|
396
|
+
}
|
|
397
|
+
));
|
|
381
398
|
|
|
382
|
-
it('add bendpoint, label on left segment', inject(function(elementRegistry, bendpointMove, dragging, canvas) {
|
|
383
399
|
|
|
384
|
-
|
|
385
|
-
|
|
400
|
+
it('add bendpoint, label on left segment', inject(
|
|
401
|
+
function(elementRegistry, bendpointMove, dragging, canvas) {
|
|
386
402
|
|
|
387
|
-
|
|
388
|
-
|
|
403
|
+
// given
|
|
404
|
+
var connection = elementRegistry.get('SequenceFlow_A');
|
|
389
405
|
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
gfx: canvas.getGraphics(connection)
|
|
393
|
-
});
|
|
406
|
+
// when
|
|
407
|
+
bendpointMove.start(canvasEvent({ x: 0, y: 0 }), connection, 1, true);
|
|
394
408
|
|
|
395
|
-
|
|
409
|
+
dragging.hover({
|
|
410
|
+
element: connection,
|
|
411
|
+
gfx: canvas.getGraphics(connection)
|
|
412
|
+
});
|
|
396
413
|
|
|
397
|
-
|
|
414
|
+
dragging.move(canvasEvent({ x: 260, y: 200 }));
|
|
398
415
|
|
|
399
|
-
|
|
400
|
-
expect(Math.round(connection.label.x)).to.be.within(240, 242);
|
|
401
|
-
expect(Math.round(connection.label.y)).to.be.equal(148);
|
|
416
|
+
dragging.end();
|
|
402
417
|
|
|
418
|
+
// then
|
|
419
|
+
expect(Math.round(connection.label.x)).to.be.within(240, 242);
|
|
420
|
+
expect(Math.round(connection.label.y)).to.be.equal(148);
|
|
403
421
|
|
|
404
|
-
|
|
422
|
+
}
|
|
423
|
+
));
|
|
405
424
|
|
|
406
425
|
|
|
407
|
-
it('remove bendpoint when label on bendpoint', inject(
|
|
426
|
+
it('remove bendpoint when label on bendpoint', inject(
|
|
427
|
+
function(elementRegistry, bendpointMove, dragging, modeling) {
|
|
408
428
|
|
|
409
|
-
|
|
410
|
-
|
|
429
|
+
// given
|
|
430
|
+
var connection = elementRegistry.get('SequenceFlow_C');
|
|
411
431
|
|
|
412
|
-
|
|
413
|
-
|
|
432
|
+
// label out of segments, on a bendpoint
|
|
433
|
+
modeling.moveShape(connection.label, { x: 40, y: 0 });
|
|
414
434
|
|
|
415
|
-
|
|
416
|
-
|
|
435
|
+
// when
|
|
436
|
+
bendpointMove.start(canvasEvent({ x: 0, y: 0 }), connection, 1);
|
|
417
437
|
|
|
418
|
-
|
|
438
|
+
dragging.move(canvasEvent({ x: 455, y: 320 }));
|
|
419
439
|
|
|
420
|
-
|
|
440
|
+
dragging.end();
|
|
421
441
|
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
442
|
+
// then
|
|
443
|
+
expect(Math.round(connection.label.x)).to.be.within(462, 465);
|
|
444
|
+
expect(Math.round(connection.label.y)).to.be.within(290, 293);
|
|
425
445
|
|
|
426
|
-
|
|
446
|
+
}
|
|
447
|
+
));
|
|
427
448
|
|
|
428
449
|
|
|
429
|
-
it('add benpoint, label on segment, should not move', inject(
|
|
450
|
+
it('add benpoint, label on segment, should not move', inject(
|
|
451
|
+
function(elementRegistry, bendpointMove, canvas, dragging, modeling) {
|
|
430
452
|
|
|
431
|
-
|
|
432
|
-
|
|
453
|
+
// given
|
|
454
|
+
var connection = elementRegistry.get('SequenceFlow_C');
|
|
433
455
|
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
456
|
+
// label out of segments, on a bendpoint
|
|
457
|
+
modeling.moveShape(connection.label, { x: 40, y: -60 });
|
|
458
|
+
var position = getLabelPosition(connection);
|
|
437
459
|
|
|
438
|
-
|
|
439
|
-
|
|
460
|
+
// when
|
|
461
|
+
bendpointMove.start(canvasEvent({ x: 0, y: 0 }), connection, 2, true);
|
|
440
462
|
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
463
|
+
dragging.hover({
|
|
464
|
+
element: connection,
|
|
465
|
+
gfx: canvas.getGraphics(connection)
|
|
466
|
+
});
|
|
445
467
|
|
|
446
|
-
|
|
468
|
+
dragging.move(canvasEvent({ x: 400, y: 350 }));
|
|
447
469
|
|
|
448
|
-
|
|
470
|
+
dragging.end();
|
|
449
471
|
|
|
450
|
-
|
|
451
|
-
|
|
472
|
+
// then
|
|
473
|
+
expectLabelMoved(connection, position, { x: 0, y: 0 });
|
|
452
474
|
|
|
453
|
-
|
|
475
|
+
}
|
|
476
|
+
));
|
|
454
477
|
|
|
455
478
|
});
|
|
456
479
|
|
|
457
480
|
|
|
458
481
|
describe('special cases', function() {
|
|
459
482
|
|
|
460
|
-
it('should behave properly, right after importing', inject(
|
|
483
|
+
it('should behave properly, right after importing', inject(
|
|
484
|
+
function(elementRegistry, connectionSegmentMove, dragging, modeling) {
|
|
461
485
|
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
// when
|
|
468
|
-
connectionSegmentMove.start(canvasEvent({ x: 0, y: 0 }), connection, 2);
|
|
469
|
-
|
|
470
|
-
dragging.move(canvasEvent({ x: 0, y: 70 }));
|
|
471
|
-
|
|
472
|
-
dragging.end();
|
|
473
|
-
|
|
474
|
-
// move label
|
|
475
|
-
modeling.moveShape(label, { x: 40, y: -30 });
|
|
476
|
-
|
|
477
|
-
// drag again
|
|
478
|
-
connectionSegmentMove.start(canvasEvent({ x: 0, y: 0 }), connection, 1);
|
|
479
|
-
|
|
480
|
-
dragging.move(canvasEvent({ x: -20, y: 0 }));
|
|
481
|
-
|
|
482
|
-
dragging.end();
|
|
483
|
-
|
|
484
|
-
// then
|
|
485
|
-
expectLabelMoved(connection, labelPosition, { x: 20, y: 40 });
|
|
486
|
-
|
|
487
|
-
}));
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
it('should reposition on right segment', inject(function(elementRegistry, connectionSegmentMove, dragging) {
|
|
491
|
-
|
|
492
|
-
// given
|
|
493
|
-
var connection = elementRegistry.get('SequenceFlow_E'),
|
|
494
|
-
labelPosition = getLabelPosition(connection);
|
|
495
|
-
|
|
496
|
-
// when
|
|
497
|
-
connectionSegmentMove.start(canvasEvent({ x: 0, y: 0 }), connection, 2);
|
|
498
|
-
|
|
499
|
-
dragging.move(canvasEvent({ x: -100, y: 0 }));
|
|
500
|
-
|
|
501
|
-
dragging.end();
|
|
502
|
-
|
|
503
|
-
// then
|
|
504
|
-
expect(connection.label.y - labelPosition.y).to.be.within(-76, -70);
|
|
505
|
-
expect(connection.label.x - labelPosition.x).to.be.within(-54, -51);
|
|
506
|
-
|
|
507
|
-
}));
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
describe.skip('label out of bounds', function() {
|
|
486
|
+
// given
|
|
487
|
+
var connection = elementRegistry.get('SequenceFlow_C'),
|
|
488
|
+
labelPosition = getLabelPosition(connection),
|
|
489
|
+
label = connection.label;
|
|
511
490
|
|
|
512
|
-
|
|
491
|
+
// when
|
|
492
|
+
connectionSegmentMove.start(canvasEvent({ x: 0, y: 0 }), connection, 2);
|
|
513
493
|
|
|
514
|
-
|
|
515
|
-
var connection = elementRegistry.get('SequenceFlow_C');
|
|
494
|
+
dragging.move(canvasEvent({ x: 0, y: 70 }));
|
|
516
495
|
|
|
517
|
-
|
|
518
|
-
modeling.moveShape(connection.label, { x: 0, y: 140 });
|
|
496
|
+
dragging.end();
|
|
519
497
|
|
|
520
|
-
|
|
498
|
+
// move label
|
|
499
|
+
modeling.moveShape(label, { x: 40, y: -30 });
|
|
521
500
|
|
|
522
|
-
//
|
|
523
|
-
connectionSegmentMove.start(canvasEvent({ x: 0, y: 0 }), connection,
|
|
501
|
+
// drag again
|
|
502
|
+
connectionSegmentMove.start(canvasEvent({ x: 0, y: 0 }), connection, 1);
|
|
524
503
|
|
|
525
|
-
dragging.move(canvasEvent({ x:
|
|
504
|
+
dragging.move(canvasEvent({ x: -20, y: 0 }));
|
|
526
505
|
|
|
527
506
|
dragging.end();
|
|
528
507
|
|
|
529
508
|
// then
|
|
530
|
-
expectLabelMoved(connection, labelPosition, { x:
|
|
531
|
-
}));
|
|
532
|
-
|
|
509
|
+
expectLabelMoved(connection, labelPosition, { x: 20, y: 40 });
|
|
533
510
|
|
|
534
|
-
|
|
511
|
+
}
|
|
512
|
+
));
|
|
535
513
|
|
|
536
|
-
// given
|
|
537
|
-
var connection = elementRegistry.get('SequenceFlow_C');
|
|
538
514
|
|
|
539
|
-
|
|
540
|
-
|
|
515
|
+
it('should reposition on right segment', inject(
|
|
516
|
+
function(elementRegistry, connectionSegmentMove, dragging) {
|
|
541
517
|
|
|
542
|
-
|
|
518
|
+
// given
|
|
519
|
+
var connection = elementRegistry.get('SequenceFlow_E'),
|
|
520
|
+
labelPosition = getLabelPosition(connection);
|
|
543
521
|
|
|
544
522
|
// when
|
|
545
523
|
connectionSegmentMove.start(canvasEvent({ x: 0, y: 0 }), connection, 2);
|
|
546
524
|
|
|
547
|
-
dragging.move(canvasEvent({ x:
|
|
525
|
+
dragging.move(canvasEvent({ x: -100, y: 0 }));
|
|
548
526
|
|
|
549
527
|
dragging.end();
|
|
550
528
|
|
|
551
529
|
// then
|
|
552
|
-
|
|
553
|
-
|
|
530
|
+
expect(connection.label.y - labelPosition.y).to.be.within(-76, -70);
|
|
531
|
+
expect(connection.label.x - labelPosition.x).to.be.within(-54, -51);
|
|
554
532
|
|
|
555
|
-
|
|
533
|
+
}
|
|
534
|
+
));
|
|
556
535
|
|
|
557
536
|
});
|
|
558
537
|
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var getLabelAdjustment = require('lib/features/modeling/behavior/util/LabelLayoutUtil').getLabelAdjustment;
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
describe('modeling/behavior/util - LabelLayoutUtil#getLabelAdjustment', function() {
|
|
7
|
+
|
|
8
|
+
describe('should recognize on the line label', function() {
|
|
9
|
+
|
|
10
|
+
var newLine = [
|
|
11
|
+
{ x: 10, y: 10 },
|
|
12
|
+
// -
|
|
13
|
+
{ x: 15, y: 10 },
|
|
14
|
+
// |
|
|
15
|
+
{ x: 15, y: 5 },
|
|
16
|
+
// -
|
|
17
|
+
{ x: 30, y: 5 }
|
|
18
|
+
];
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
it('horizontal', function() {
|
|
22
|
+
|
|
23
|
+
// given
|
|
24
|
+
var line = [
|
|
25
|
+
{ x: 10, y: 10 },
|
|
26
|
+
// -
|
|
27
|
+
{ x: 20, y: 10 }
|
|
28
|
+
];
|
|
29
|
+
|
|
30
|
+
// label with center { x: 5, y: 10 }
|
|
31
|
+
|
|
32
|
+
var label = {
|
|
33
|
+
x: 0,
|
|
34
|
+
y: 5,
|
|
35
|
+
width: 10,
|
|
36
|
+
height: 10
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
// when
|
|
40
|
+
var delta = getLabelAdjustment(label, newLine, line, { connectionStart: true });
|
|
41
|
+
|
|
42
|
+
// then
|
|
43
|
+
expect(delta).to.eql({ x: 0, y: 0 });
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
it('zero-length line', function() {
|
|
48
|
+
|
|
49
|
+
// given
|
|
50
|
+
var line = [
|
|
51
|
+
{ x: 10, y: 10 },
|
|
52
|
+
// -
|
|
53
|
+
{ x: 10, y: 10 }
|
|
54
|
+
];
|
|
55
|
+
|
|
56
|
+
// label with center { x: 5, y: 10 }
|
|
57
|
+
|
|
58
|
+
var label = {
|
|
59
|
+
x: 0,
|
|
60
|
+
y: 5,
|
|
61
|
+
width: 10,
|
|
62
|
+
height: 10
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
// when
|
|
66
|
+
var delta = getLabelAdjustment(label, newLine, line, { connectionStart: true });
|
|
67
|
+
|
|
68
|
+
// then
|
|
69
|
+
expect(delta).to.eql({ x: 0, y: 0 });
|
|
70
|
+
});
|
|
71
|
+
|
|
72
|
+
});
|
|
73
|
+
|
|
74
|
+
|
|
75
|
+
});
|