Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Do not adjust lane parent to participant #1256

Merged
merged 3 commits into from
Dec 11, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions lib/features/modeling/behavior/CreateBehavior.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,10 @@ export default function CreateBehavior(injector) {

this.preExecute('shape.create', 1500, function(event) {
var context = event.context,
parent = context.parent;
parent = context.parent,
shape = context.shape;

if (is(parent, 'bpmn:Lane')) {
if (is(parent, 'bpmn:Lane') && !is(shape, 'bpmn:Lane')) {
context.parent = getParent(parent, 'bpmn:Participant');
}
});
Expand Down
44 changes: 44 additions & 0 deletions test/spec/features/modeling/lanes/SplitLane.nested.bpmn
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
<?xml version="1.0" encoding="UTF-8"?>
<bpmn:definitions xmlns:bpmn="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" id="Definitions_0czfmdy" targetNamespace="http://bpmn.io/schema/bpmn" exporter="Camunda Modeler" exporterVersion="3.5.0">
<bpmn:collaboration id="Collaboration_166yin4">
<bpmn:participant id="Participant" name="Participant" processRef="Process" />
</bpmn:collaboration>
<bpmn:process id="Process" isExecutable="true">
<bpmn:laneSet id="LaneSet_113taei">
<bpmn:lane id="Lane" name="Lane">
<bpmn:flowNodeRef>Event</bpmn:flowNodeRef>
<bpmn:flowNodeRef>Task</bpmn:flowNodeRef>
</bpmn:lane>
</bpmn:laneSet>
<bpmn:startEvent id="Event" name="Event">
<bpmn:outgoing>SequenceFlow_192h0e0</bpmn:outgoing>
</bpmn:startEvent>
<bpmn:task id="Task" name="Task">
<bpmn:incoming>SequenceFlow_192h0e0</bpmn:incoming>
</bpmn:task>
<bpmn:sequenceFlow id="SequenceFlow_192h0e0" sourceRef="Event" targetRef="Task" />
</bpmn:process>
<bpmndi:BPMNDiagram id="BPMNDiagram_1">
<bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="Collaboration_166yin4">
<bpmndi:BPMNShape id="Participant_00t6m8v_di" bpmnElement="Participant" isHorizontal="true">
<dc:Bounds x="170" y="90" width="791" height="450" />
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="_BPMNShape_StartEvent_2" bpmnElement="Event">
<dc:Bounds x="323" y="152" width="36" height="36" />
<bpmndi:BPMNLabel>
<dc:Bounds x="327" y="195" width="29" height="14" />
</bpmndi:BPMNLabel>
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="Task_05q93nk_di" bpmnElement="Task">
<dc:Bounds x="411" y="130" width="100" height="80" />
</bpmndi:BPMNShape>
<bpmndi:BPMNEdge id="SequenceFlow_192h0e0_di" bpmnElement="SequenceFlow_192h0e0">
<di:waypoint x="359" y="170" />
<di:waypoint x="411" y="170" />
</bpmndi:BPMNEdge>
<bpmndi:BPMNShape id="Lane_1f7sfho_di" bpmnElement="Lane" isHorizontal="true">
<dc:Bounds x="200" y="90" width="761" height="450" />
</bpmndi:BPMNShape>
</bpmndi:BPMNPlane>
</bpmndi:BPMNDiagram>
</bpmn:definitions>
67 changes: 61 additions & 6 deletions test/spec/features/modeling/lanes/SplitLaneSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,13 @@ function getBounds(element) {

describe('features/modeling - SplitLane', function() {

var testModules = [ coreModule, modelingModule ];


describe('should split Participant with Lane', function() {

var diagramXML = require('./participant-lane.bpmn');

var testModules = [ coreModule, modelingModule ];

beforeEach(bootstrapModeler(diagramXML, { modules: testModules }));


Expand Down Expand Up @@ -124,8 +125,6 @@ describe('features/modeling - SplitLane', function() {

var diagramXML = require('./participant-no-lane.bpmn');

var testModules = [ coreModule, modelingModule ];

beforeEach(bootstrapModeler(diagramXML, { modules: testModules }));


Expand All @@ -148,7 +147,7 @@ describe('features/modeling - SplitLane', function() {
expect(participantShape).to.have.bounds(oldBounds);

// and two child lanes
expect(childLanes.length).to.eql(2);
expect(childLanes).to.have.length(2);

// with respective bounds
expect(childLanes[0]).to.have.bounds({
Expand Down Expand Up @@ -186,7 +185,7 @@ describe('features/modeling - SplitLane', function() {
expect(participantShape).to.have.bounds(oldBounds);

// and two child lanes
expect(childLanes.length).to.eql(3);
expect(childLanes).to.have.length(3);

// with respective bounds
expect(childLanes[0]).to.have.bounds({
Expand All @@ -213,4 +212,60 @@ describe('features/modeling - SplitLane', function() {

});


describe('should split nested Lane', function() {

var diagramXML = require('./SplitLane.nested.bpmn');

beforeEach(bootstrapModeler(diagramXML, { modules: testModules }));


it('into two lanes', inject(function(elementRegistry, modeling) {

// given
var laneShape = elementRegistry.get('Lane'),
laneBo = laneShape.businessObject,
oldBounds = getBounds(laneShape);

// when
modeling.splitLane(laneShape, 2);

var childLanes = getChildLanes(laneShape);

var newLaneHeight = Math.round(laneShape.height / 2);

// then

// participant has original size
expect(laneShape).to.have.bounds(oldBounds);

// and two child lanes
expect(childLanes).to.have.length(2);

// with respective bounds
expect(childLanes[0]).to.have.bounds({
x: laneShape.x + 30,
y: laneShape.y,
width: laneShape.width - 30,
height: newLaneHeight
});

expect(childLanes[1]).to.have.bounds({
x: laneShape.x + 30,
y: laneShape.y + newLaneHeight,
width: laneShape.width - 30,
height: newLaneHeight
});

// BPMN internals are properly updated
expect(laneBo.childLaneSet).to.exist;
expect(laneBo.childLaneSet.lanes).to.eql([
childLanes[0].businessObject,
childLanes[1].businessObject
]);

}));

});

});
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?>
<bpmn2:definitions xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:bpmn2="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" id="_2_FUoE-xEeWT0c1N_GlSWA" targetNamespace="http://activiti.org/bpmn" exporter="Camunda Modeler" exporterVersion="3.4.0-dev" xsi:schemaLocation="http://www.omg.org/spec/BPMN/20100524/MODEL BPMN20.xsd">
<bpmn2:collaboration id="_Collaboration_2">
<bpmn2:definitions xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:bpmn2="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" id="_2_FUoE-xEeWT0c1N_GlSWA" targetNamespace="http://camunda.org/schema/1.0/bpmn" exporter="Camunda Modeler" exporterVersion="2.2.4" xsi:schemaLocation="http://www.omg.org/spec/BPMN/20100524/MODEL BPMN20.xsd">
<bpmn2:collaboration id="Collaboration">
<bpmn2:participant id="Participant_A" name="Participant_A" processRef="Process_A" />
<bpmn2:participant id="Participant_B" name="Participant_B" processRef="Process_B" />
<bpmn2:participant id="Participant_0emukbw" name="Participant_C" processRef="Process_1gjk6nk" />
<bpmn2:participant id="Participant_C" name="Participant_C" processRef="Process_C" />
<bpmn2:participant id="Participant_D" name="Participant_D" processRef="Process_D" />
</bpmn2:collaboration>
<bpmn2:process id="Process_A" isExecutable="false">
<bpmn2:laneSet id="LaneSet_1" name="Lane Set 1">
Expand All @@ -23,22 +24,37 @@
<bpmn2:process id="Process_B" isExecutable="false">
<bpmn2:task id="Task_B" name="Task_B" />
</bpmn2:process>
<bpmn2:process id="Process_1gjk6nk" isExecutable="false">
<bpmn2:process id="Process_C" isExecutable="false">
<bpmn2:laneSet id="LaneSet_06y7y48">
<bpmn2:lane id="Participant_C_Lane_1">
<bpmn2:flowNodeRef>Task_1</bpmn2:flowNodeRef>
<bpmn2:lane id="Participant_C_Lane_1" name="Participant_C_Lane_1">
<bpmn2:flowNodeRef>Task_C</bpmn2:flowNodeRef>
<bpmn2:flowNodeRef>IntermediateThrowEvent</bpmn2:flowNodeRef>
</bpmn2:lane>
<bpmn2:lane id="Participant_C_Lane_2">
<bpmn2:flowNodeRef>Task_2</bpmn2:flowNodeRef>
<bpmn2:lane id="Participant_C_Lane_2" name="Participant_C_Lane_2">
<bpmn2:flowNodeRef>Task_D</bpmn2:flowNodeRef>
</bpmn2:lane>
</bpmn2:laneSet>
<bpmn2:task id="Task_1" />
<bpmn2:task id="Task_2" />
<bpmn2:task id="Task_C" name="Task_C" />
<bpmn2:task id="Task_D" name="Task_D" />
<bpmn2:intermediateThrowEvent id="IntermediateThrowEvent" />
</bpmn2:process>
<bpmn2:process id="Process_D" isExecutable="false">
<bpmn2:laneSet id="LaneSet_1fp2wy1">
<bpmn2:lane id="Lane_D_1" name="Lane_D_1">
<bpmn2:flowNodeRef>Task_E</bpmn2:flowNodeRef>
<bpmn2:childLaneSet id="LaneSet_10kvuaz">
<bpmn2:lane id="Lane_D_1_2" name="Lane_D_1_2" />
<bpmn2:lane id="Lane_D_1_1" name="Lane_D_1_1">
<bpmn2:flowNodeRef>Task_E</bpmn2:flowNodeRef>
</bpmn2:lane>
</bpmn2:childLaneSet>
</bpmn2:lane>
<bpmn2:lane id="Lane_0z1sraf" />
</bpmn2:laneSet>
<bpmn2:task id="Task_E" name="Task_E" />
</bpmn2:process>
<bpmndi:BPMNDiagram id="BPMNDiagram_1">
<bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="_Collaboration_2">
<bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="Collaboration">
<bpmndi:BPMNShape id="_BPMNShape_Participant_2" bpmnElement="Participant_A" isHorizontal="true">
<dc:Bounds x="154" y="96" width="540" height="145" />
</bpmndi:BPMNShape>
Expand Down Expand Up @@ -67,7 +83,7 @@
<bpmndi:BPMNShape id="_BPMNShape_Task_3" bpmnElement="Task_B">
<dc:Bounds x="562" y="339" width="100" height="80" />
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="Participant_0emukbw_di" bpmnElement="Participant_0emukbw" isHorizontal="true">
<bpmndi:BPMNShape id="Participant_C_di" bpmnElement="Participant_C" isHorizontal="true">
<dc:Bounds x="154" y="475" width="540" height="285" />
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="Lane_0lsm3hs_di" bpmnElement="Participant_C_Lane_1" isHorizontal="true">
Expand All @@ -76,15 +92,33 @@
<bpmndi:BPMNShape id="Lane_16dmnot_di" bpmnElement="Participant_C_Lane_2" isHorizontal="true">
<dc:Bounds x="184" y="625" width="510" height="135" />
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="Task_1abs8bh_di" bpmnElement="Task_1">
<bpmndi:BPMNShape id="Task_1abs8bh_di" bpmnElement="Task_C">
<dc:Bounds x="230" y="510" width="100" height="80" />
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="IntermediateThrowEvent_0oto7vx_di" bpmnElement="IntermediateThrowEvent">
<dc:Bounds x="592" y="532" width="36" height="36" />
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="Task_0j7a294_di" bpmnElement="Task_2">
<bpmndi:BPMNShape id="Task_0j7a294_di" bpmnElement="Task_D">
<dc:Bounds x="230" y="650" width="100" height="80" />
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="Participant_D_di" bpmnElement="Participant_D">
<dc:Bounds x="154" y="835" width="539" height="379" />
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="Lane_1x5l7tv_di" bpmnElement="Lane_D_1">
<dc:Bounds x="184" y="835" width="509" height="315" />
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="Lane_0z1sraf_di" bpmnElement="Lane_0z1sraf">
<dc:Bounds x="184" y="1150" width="509" height="64" />
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="Lane_0l34pdv_di" bpmnElement="Lane_D_1_2">
<dc:Bounds x="214" y="835" width="479" height="137" />
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="Lane_05oigjv_di" bpmnElement="Lane_D_1_1">
<dc:Bounds x="214" y="972" width="479" height="178" />
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="Task_196nq81_di" bpmnElement="Task_E">
<dc:Bounds x="358" y="1011" width="100" height="80" />
</bpmndi:BPMNShape>
</bpmndi:BPMNPlane>
</bpmndi:BPMNDiagram>
</bpmn2:definitions>
24 changes: 19 additions & 5 deletions test/spec/features/modeling/lanes/UpdateFlowNodeRefsSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,16 @@ import modelingModule from 'lib/features/modeling';
import coreModule from 'lib/core';
import copyPasteModule from 'lib/features/copy-paste';

import {
find
} from 'min-dash';

/* global sinon */


describe('features/modeling - lanes - flowNodeRefs', function() {

var diagramXML = require('./flowNodeRefs.bpmn');
var diagramXML = require('./UpdateFlowNodeRefs.basic.bpmn');

beforeEach(bootstrapModeler(diagramXML, {
modules: [
Expand Down Expand Up @@ -279,8 +283,8 @@ describe('features/modeling - lanes - flowNodeRefs', function() {
// given
var eventID = 'IntermediateThrowEvent',
throwEvent = elementRegistry.get(eventID),
task1 = elementRegistry.get('Task_1'),
task2 = elementRegistry.get('Task_2'),
task1 = elementRegistry.get('Task_C'),
task2 = elementRegistry.get('Task_D'),
lane1 = elementRegistry.get('Participant_C_Lane_1').businessObject,
lane2 = elementRegistry.get('Participant_C_Lane_2').businessObject;

Expand All @@ -304,7 +308,7 @@ describe('features/modeling - lanes - flowNodeRefs', function() {
it('execute', inject(function(canvas, eventBus, elementRegistry, copyPaste) {

// given
var participant = elementRegistry.get('Participant_A');
var participant = elementRegistry.get('Participant_D');

var updateRefsSpy = sinon.spy();

Expand All @@ -313,16 +317,26 @@ describe('features/modeling - lanes - flowNodeRefs', function() {
// when
copyPaste.copy(participant);

copyPaste.paste({
var pastedElements = copyPaste.paste({
element: canvas.getRootElement(),
point: {
x: 350,
y: 150
}
});

var pastedLane = find(pastedElements, function(e) {
return e.businessObject.name === 'Lane_D_1_1';
});

var pastedTask = find(pastedElements, function(e) {
return e.businessObject.name === 'Task_E';
});

// then
expect(updateRefsSpy).to.have.been.calledOnce;

expect(pastedLane.businessObject.flowNodeRef).to.include(pastedTask.businessObject);
}));

});
Expand Down
2 changes: 1 addition & 1 deletion test/spec/features/modeling/lanes/lanes.bpmn
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<bpmn2:definitions xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:bpmn2="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" xsi:schemaLocation="http://www.omg.org/spec/BPMN/20100524/MODEL BPMN20.xsd" id="_4bAZoD9WEeWLcNBL4nCk1A" exporter="camunda modeler" exporterVersion="2.6.0" targetNamespace="http://activiti.org/bpmn">
<bpmn2:definitions xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:bpmn2="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" xsi:schemaLocation="http://www.omg.org/spec/BPMN/20100524/MODEL BPMN20.xsd" id="_4bAZoD9WEeWLcNBL4nCk1A" exporter="camunda modeler" exporterVersion="2.6.0" targetNamespace="http://camunda.org/schema/1.0/bpmn">
<bpmn2:collaboration id="_Collaboration_2">
<bpmn2:participant id="Participant_Lane" name="Participant_Lane" processRef="Process_Lane"/>
</bpmn2:collaboration>
Expand Down
4 changes: 2 additions & 2 deletions test/spec/features/modeling/lanes/participant-lane.bpmn
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<bpmn2:definitions xmlns:bpmn2="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" id="_DjEdwG27EeW3UIoxwJSm9g" targetNamespace="http://activiti.org/bpmn" exporter="camunda modeler" exporterVersion="2.6.0" xsi:schemaLocation="http://www.omg.org/spec/BPMN/20100524/MODEL BPMN20.xsd">
<bpmn2:definitions xmlns:bpmn2="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" id="_DjEdwG27EeW3UIoxwJSm9g" targetNamespace="http://camunda.org/schema/1.0/bpmn" exporter="camunda modeler" exporterVersion="2.6.0" xsi:schemaLocation="http://www.omg.org/spec/BPMN/20100524/MODEL BPMN20.xsd">
<bpmn2:collaboration id="_Collaboration_3">
<bpmn2:participant id="Participant_Lane" name="Participant_Lane" processRef="Process_Lane" />
</bpmn2:collaboration>
Expand All @@ -24,4 +24,4 @@
</bpmndi:BPMNShape>
</bpmndi:BPMNPlane>
</bpmndi:BPMNDiagram>
</bpmn2:definitions>
</bpmn2:definitions>
4 changes: 2 additions & 2 deletions test/spec/features/modeling/lanes/participant-no-lane.bpmn
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<bpmn2:definitions xmlns:bpmn2="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" id="_DjEdwG27EeW3UIoxwJSm9g" targetNamespace="http://activiti.org/bpmn" exporter="camunda modeler" exporterVersion="2.6.0" xsi:schemaLocation="http://www.omg.org/spec/BPMN/20100524/MODEL BPMN20.xsd">
<bpmn2:definitions xmlns:bpmn2="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" id="_DjEdwG27EeW3UIoxwJSm9g" targetNamespace="http://camunda.org/schema/1.0/bpmn" exporter="camunda modeler" exporterVersion="2.6.0" xsi:schemaLocation="http://www.omg.org/spec/BPMN/20100524/MODEL BPMN20.xsd">
<bpmn2:collaboration id="_Collaboration_3">
<bpmn2:participant id="Participant_No_Lane" name="Participant_No_Lane" processRef="Process_No_Lane" />
</bpmn2:collaboration>
Expand All @@ -19,4 +19,4 @@
</bpmndi:BPMNShape>
</bpmndi:BPMNPlane>
</bpmndi:BPMNDiagram>
</bpmn2:definitions>
</bpmn2:definitions>