Skip to content

Commit 29baeb1

Browse files
sombrekfake-join[bot]
authored andcommitted
feat: edit vertical pool/lane labels
1 parent 60b392a commit 29baeb1

File tree

3 files changed

+246
-6
lines changed

3 files changed

+246
-6
lines changed

lib/features/label-editing/LabelEditingProvider.js

Lines changed: 43 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,11 @@ import {
1111
} from '../../util/ModelUtil';
1212

1313
import { isAny } from '../modeling/util/ModelingUtil';
14-
import { isExpanded } from '../../util/DiUtil';
14+
15+
import {
16+
isExpanded,
17+
isHorizontal
18+
} from '../../util/DiUtil';
1519

1620
import {
1721
getExternalLabelMid,
@@ -277,13 +281,47 @@ LabelEditingProvider.prototype.getEditingBBox = function(element) {
277281

278282
// adjust for expanded pools AND lanes
279283
if (is(element, 'bpmn:Lane') || isExpandedPool(element)) {
284+
var isHorizontalLane = isHorizontal(element);
280285

281-
assign(bounds, {
286+
var laneBounds = isHorizontalLane ? {
282287
width: bbox.height,
283288
height: 30 * zoom,
284289
x: bbox.x - bbox.height / 2 + (15 * zoom),
285290
y: mid.y - (30 * zoom) / 2
291+
} : {
292+
width: bbox.width,
293+
height: 30 * zoom
294+
};
295+
296+
assign(bounds, laneBounds);
297+
298+
assign(style, {
299+
fontSize: defaultFontSize + 'px',
300+
lineHeight: defaultLineHeight,
301+
paddingTop: (7 * zoom) + 'px',
302+
paddingBottom: (7 * zoom) + 'px',
303+
paddingLeft: (5 * zoom) + 'px',
304+
paddingRight: (5 * zoom) + 'px',
305+
transform: isHorizontalLane ? 'rotate(-90deg)' : null
286306
});
307+
}
308+
309+
310+
// internal labels for collapsed participants
311+
if (isCollapsedPool(element)) {
312+
var isHorizontalPool = isHorizontal(element);
313+
314+
var poolBounds = isHorizontalPool ? {
315+
width: bbox.width,
316+
height: bbox.height
317+
} : {
318+
width: bbox.height,
319+
height: bbox.width,
320+
x: mid.x - bbox.height / 2,
321+
y: mid.y - bbox.width / 2
322+
};
323+
324+
assign(bounds, poolBounds);
287325

288326
assign(style, {
289327
fontSize: defaultFontSize + 'px',
@@ -292,15 +330,14 @@ LabelEditingProvider.prototype.getEditingBBox = function(element) {
292330
paddingBottom: (7 * zoom) + 'px',
293331
paddingLeft: (5 * zoom) + 'px',
294332
paddingRight: (5 * zoom) + 'px',
295-
transform: 'rotate(-90deg)'
333+
transform: isHorizontalPool ? null : 'rotate(-90deg)'
296334
});
297335
}
298336

299337

300-
// internal labels for tasks and collapsed call activities,
301-
// sub processes and participants
338+
// internal labels for tasks and collapsed call activities
339+
// and sub processes
302340
if (isAny(element, [ 'bpmn:Task', 'bpmn:CallActivity' ]) ||
303-
isCollapsedPool(element) ||
304341
isCollapsedSubProcess(element)) {
305342

306343
assign(bounds, {

test/spec/features/label-editing/LabelEditing.bpmn

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
<bpmn:collaboration id="Collaboration_1o0amh9">
44
<bpmn:participant id="Participant_1" name="FOO BAR" processRef="Process_1" />
55
<bpmn:participant id="Participant_2" />
6+
<bpmn:participant id="Participant_3" name="VER" processRef="Process_3" />
7+
<bpmn:participant id="Participant_4" name="CAL" />
68
<bpmn:messageFlow id="MessageFlow_1" name="FOO" sourceRef="Task_1fo1fvh" targetRef="Participant_2" />
79
<bpmn:textAnnotation id="TextAnnotation_1"> <bpmn:text>FOO</bpmn:text>
810
</bpmn:textAnnotation>
@@ -75,6 +77,12 @@
7577
<bpmn:category id="Category_1">
7678
<bpmn:categoryValue id="CategoryValue_1" value="FOO" />
7779
</bpmn:category>
80+
<bpmn:process id="Process_3" isExecutable="false">
81+
<bpmn:laneSet id="LaneSet_0qq17vw">
82+
<bpmn:lane id="Vertical_Lane_2" name="TI" />
83+
<bpmn:lane id="Vertical_Lane_1" />
84+
</bpmn:laneSet>
85+
</bpmn:process>
7886
<bpmndi:BPMNDiagram id="BPMNDiagram_1">
7987
<bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="Collaboration_1o0amh9">
8088
<bpmndi:BPMNShape id="Participant_15tkgjw_di" bpmnElement="Participant_1">
@@ -193,6 +201,21 @@
193201
<bpmndi:BPMNShape id="Participant_0kzj58d_di" bpmnElement="Participant_2">
194202
<dc:Bounds x="161" y="646" width="600" height="250" />
195203
</bpmndi:BPMNShape>
204+
<bpmndi:BPMNShape id="Participant_09pdsq3_di" bpmnElement="Participant_3" isHorizontal="false">
205+
<dc:Bounds x="900" y="122" width="250" height="600" />
206+
<bpmndi:BPMNLabel />
207+
</bpmndi:BPMNShape>
208+
<bpmndi:BPMNShape id="Lane_1ja5e3n_di" bpmnElement="Vertical_Lane_2" isHorizontal="false">
209+
<dc:Bounds x="1025" y="152" width="125" height="570" />
210+
<bpmndi:BPMNLabel />
211+
</bpmndi:BPMNShape>
212+
<bpmndi:BPMNShape id="Lane_0u3fowr_di" bpmnElement="Vertical_Lane_1" isHorizontal="false">
213+
<dc:Bounds x="900" y="152" width="125" height="570" />
214+
</bpmndi:BPMNShape>
215+
<bpmndi:BPMNShape id="Participant_03y1uz8_di" bpmnElement="Participant_4" isHorizontal="false">
216+
<dc:Bounds x="1178" y="122" width="60" height="600" />
217+
<bpmndi:BPMNLabel />
218+
</bpmndi:BPMNShape>
196219
<bpmndi:BPMNShape id="DataOutput_di" bpmnElement="DataOutput">
197220
<dc:Bounds x="265" y="150" width="34" height="40" />
198221
<bpmndi:BPMNLabel>

test/spec/features/label-editing/LabelEditingProviderSpec.js

Lines changed: 180 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -500,6 +500,10 @@ describe('features - label-editing', function() {
500500

501501
it('pool, collapsed', directEdit('Participant_2'));
502502

503+
it('vertical pool', directEdit('Participant_3'));
504+
505+
it('vertical pool, collapsed', directEdit('Participant_4'));
506+
503507

504508
it('lane with label', directEdit('Lane_1'));
505509

@@ -932,6 +936,182 @@ describe('features - label-editing', function() {
932936

933937
});
934938

939+
940+
describe('collapsed pools', function() {
941+
942+
it('[zoom 1] should have width/height of element', inject(
943+
function(canvas, directEditing, elementRegistry) {
944+
945+
// given
946+
var zoom = 1;
947+
948+
canvas.zoom(zoom);
949+
950+
var pool = elementRegistry.get('Participant_2');
951+
952+
var bounds = canvas.getAbsoluteBBox(pool);
953+
954+
// when
955+
directEditing.activate(pool);
956+
957+
// then
958+
expectBounds(directEditing._textbox.parent, {
959+
x: bounds.x,
960+
y: bounds.y,
961+
width: bounds.width,
962+
height: bounds.height
963+
});
964+
}
965+
));
966+
967+
968+
it('[zoom 1.5] should have width/height of element', inject(
969+
function(canvas, directEditing, elementRegistry) {
970+
971+
// given
972+
var zoom = 1.5;
973+
974+
canvas.zoom(zoom);
975+
976+
var pool = elementRegistry.get('Participant_2');
977+
978+
var bounds = canvas.getAbsoluteBBox(pool);
979+
980+
// when
981+
directEditing.activate(pool);
982+
983+
// then
984+
expectBounds(directEditing._textbox.parent, {
985+
x: bounds.x,
986+
y: bounds.y,
987+
width: bounds.width,
988+
height: bounds.height
989+
});
990+
}
991+
));
992+
993+
});
994+
995+
996+
describe('vertical pools/lanes', function() {
997+
998+
it('[zoom 1] should have width of element width, height of 30', inject(
999+
function(canvas, directEditing, elementRegistry) {
1000+
1001+
// given
1002+
var zoom = 1;
1003+
1004+
canvas.zoom(zoom);
1005+
1006+
var pool = elementRegistry.get('Participant_3');
1007+
1008+
var bounds = canvas.getAbsoluteBBox(pool);
1009+
1010+
// when
1011+
directEditing.activate(pool);
1012+
1013+
// then
1014+
expectBounds(directEditing._textbox.parent, {
1015+
x: bounds.x,
1016+
y: bounds.y,
1017+
width: bounds.width,
1018+
height: 30 * zoom
1019+
});
1020+
}
1021+
));
1022+
1023+
1024+
it('[zoom 1.5] should have width of element width, height of 30', inject(
1025+
function(canvas, directEditing, elementRegistry) {
1026+
1027+
// given
1028+
var zoom = 1.5;
1029+
1030+
canvas.zoom(zoom);
1031+
1032+
var pool = elementRegistry.get('Participant_3');
1033+
1034+
var bounds = canvas.getAbsoluteBBox(pool);
1035+
1036+
// when
1037+
directEditing.activate(pool);
1038+
1039+
// then
1040+
expectBounds(directEditing._textbox.parent, {
1041+
x: bounds.x,
1042+
y: bounds.y,
1043+
width: bounds.width,
1044+
height: 30 * zoom
1045+
});
1046+
}
1047+
));
1048+
1049+
});
1050+
1051+
1052+
describe('vertical collapsed pools', function() {
1053+
1054+
it('[zoom 1] should have width/height of element', inject(
1055+
function(canvas, directEditing, elementRegistry) {
1056+
1057+
// given
1058+
var zoom = 1;
1059+
1060+
canvas.zoom(zoom);
1061+
1062+
var pool = elementRegistry.get('Participant_4');
1063+
1064+
var bounds = canvas.getAbsoluteBBox(pool);
1065+
var mid = {
1066+
x: bounds.x + bounds.width / 2,
1067+
y: bounds.y + bounds.height / 2
1068+
};
1069+
1070+
// when
1071+
directEditing.activate(pool);
1072+
1073+
// then
1074+
expectBounds(directEditing._textbox.parent, {
1075+
x: mid.x - bounds.height / 2,
1076+
y: mid.y - bounds.width / 2,
1077+
width: bounds.height,
1078+
height: bounds.width
1079+
});
1080+
}
1081+
));
1082+
1083+
1084+
it('[zoom 1.5] should have width/height of element', inject(
1085+
function(canvas, directEditing, elementRegistry) {
1086+
1087+
// given
1088+
var zoom = 1.5;
1089+
1090+
canvas.zoom(zoom);
1091+
1092+
var pool = elementRegistry.get('Participant_4');
1093+
1094+
var bounds = canvas.getAbsoluteBBox(pool);
1095+
var mid = {
1096+
x: bounds.x + bounds.width / 2,
1097+
y: bounds.y + bounds.height / 2
1098+
};
1099+
1100+
// when
1101+
directEditing.activate(pool);
1102+
1103+
// then
1104+
expectBounds(directEditing._textbox.parent, {
1105+
x: mid.x - bounds.height / 2,
1106+
y: mid.y - bounds.width / 2,
1107+
width: bounds.height,
1108+
height: bounds.width
1109+
});
1110+
}
1111+
));
1112+
1113+
});
1114+
9351115
});
9361116

9371117
});

0 commit comments

Comments
 (0)