fix(modeling): do not duplicate flow node refs
Closes: https://github.com/camunda/camunda-modeler/issues/1504
This commit is contained in:
parent
37bcd070e8
commit
168a1493b2
|
@ -34,7 +34,7 @@ UpdateFlowNodeRefsHandler.$inject = [
|
|||
|
||||
UpdateFlowNodeRefsHandler.prototype.computeUpdates = function(flowNodeShapes, laneShapes) {
|
||||
|
||||
var handledNodes = {};
|
||||
var handledNodes = [];
|
||||
|
||||
var updates = [];
|
||||
|
||||
|
@ -58,9 +58,9 @@ UpdateFlowNodeRefsHandler.prototype.computeUpdates = function(flowNodeShapes, la
|
|||
}
|
||||
|
||||
function addFlowNodeShape(flowNodeShape) {
|
||||
if (!handledNodes[flowNodeShape.id]) {
|
||||
if (handledNodes.indexOf(flowNodeShape) === -1) {
|
||||
allFlowNodeShapes.push(flowNodeShape);
|
||||
handledNodes[flowNodeShape.id] = flowNodeShape;
|
||||
handledNodes.push(flowNodeShape);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -92,7 +92,7 @@ UpdateFlowNodeRefsHandler.prototype.computeUpdates = function(flowNodeShapes, la
|
|||
laneShapes.forEach(function(laneShape) {
|
||||
var root = getLanesRoot(laneShape);
|
||||
|
||||
if (!root || handledNodes[root.id]) {
|
||||
if (!root || handledNodes.indexOf(root) !== -1) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -102,7 +102,7 @@ UpdateFlowNodeRefsHandler.prototype.computeUpdates = function(flowNodeShapes, la
|
|||
|
||||
children.forEach(addFlowNodeShape);
|
||||
|
||||
handledNodes[root.id] = root;
|
||||
handledNodes.push(root);
|
||||
});
|
||||
|
||||
flowNodeShapes.forEach(addFlowNodeShape);
|
||||
|
@ -190,4 +190,4 @@ UpdateFlowNodeRefsHandler.prototype.revert = function(context) {
|
|||
|
||||
// TODO(nikku): return changed elements
|
||||
// return [ ... ];
|
||||
};
|
||||
};
|
||||
|
|
|
@ -266,4 +266,28 @@ describe('features/modeling - lanes - flowNodeRefs', function() {
|
|||
expect(sourceLane.flowNodeRef).not.to.contain(event);
|
||||
}));
|
||||
|
||||
|
||||
it('should not create duplicate refs on attaching / detaching', inject(function(elementRegistry, modeling) {
|
||||
|
||||
// given
|
||||
var eventID = 'IntermediateThrowEvent',
|
||||
throwEvent = elementRegistry.get(eventID),
|
||||
task1 = elementRegistry.get('Task_1'),
|
||||
task2 = elementRegistry.get('Task_2'),
|
||||
lane1 = elementRegistry.get('Participant_C_Lane_1').businessObject,
|
||||
lane2 = elementRegistry.get('Participant_C_Lane_2').businessObject;
|
||||
|
||||
// when
|
||||
modeling.moveElements([ throwEvent ], { x: -280, y: 30 }, task1, { attach: true });
|
||||
|
||||
var boundaryEvent = elementRegistry.get(eventID);
|
||||
|
||||
modeling.moveElements([ boundaryEvent ], { x: 0, y: 150 }, task2, { attach: true });
|
||||
|
||||
// then
|
||||
expect(lane1.flowNodeRef).not.to.contain(boundaryEvent.businessObject);
|
||||
expect(lane2.flowNodeRef).to.contain(boundaryEvent.businessObject);
|
||||
expect(lane1.flowNodeRef).to.have.length(1);
|
||||
expect(lane2.flowNodeRef).to.have.length(2);
|
||||
}));
|
||||
});
|
||||
|
|
|
@ -1,8 +1,9 @@
|
|||
<?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="_2_FUoE-xEeWT0c1N_GlSWA" 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" 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: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_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:collaboration>
|
||||
<bpmn2:process id="Process_A" isExecutable="false">
|
||||
<bpmn2:laneSet id="LaneSet_1" name="Lane Set 1">
|
||||
|
@ -14,44 +15,76 @@
|
|||
<bpmn2:task id="Task_A" name="Task_A">
|
||||
<bpmn2:outgoing>SequenceFlow</bpmn2:outgoing>
|
||||
</bpmn2:task>
|
||||
<bpmn2:sequenceFlow id="SequenceFlow" name="" sourceRef="Task_A" targetRef="Event"/>
|
||||
<bpmn2:intermediateCatchEvent id="Event" name="Event">
|
||||
<bpmn2:incoming>SequenceFlow</bpmn2:incoming>
|
||||
</bpmn2:intermediateCatchEvent>
|
||||
<bpmn2:sequenceFlow id="SequenceFlow" name="" sourceRef="Task_A" targetRef="Event" />
|
||||
</bpmn2:process>
|
||||
<bpmn2:process id="Process_B" isExecutable="false">
|
||||
<bpmn2:task id="Task_B" name="Task_B"/>
|
||||
<bpmn2:task id="Task_B" name="Task_B" />
|
||||
</bpmn2:process>
|
||||
<bpmn2:process id="Process_1gjk6nk" isExecutable="false">
|
||||
<bpmn2:laneSet id="LaneSet_06y7y48">
|
||||
<bpmn2:lane id="Participant_C_Lane_1">
|
||||
<bpmn2:flowNodeRef>Task_1</bpmn2:flowNodeRef>
|
||||
<bpmn2:flowNodeRef>IntermediateThrowEvent</bpmn2:flowNodeRef>
|
||||
</bpmn2:lane>
|
||||
<bpmn2:lane id="Participant_C_Lane_2">
|
||||
<bpmn2:flowNodeRef>Task_2</bpmn2:flowNodeRef>
|
||||
</bpmn2:lane>
|
||||
</bpmn2:laneSet>
|
||||
<bpmn2:task id="Task_1" />
|
||||
<bpmn2:task id="Task_2" />
|
||||
<bpmn2:intermediateThrowEvent id="IntermediateThrowEvent" />
|
||||
</bpmn2:process>
|
||||
<bpmndi:BPMNDiagram id="BPMNDiagram_1">
|
||||
<bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="_Collaboration_2">
|
||||
<bpmndi:BPMNShape id="_BPMNShape_Participant_2" bpmnElement="Participant_A" isHorizontal="true">
|
||||
<dc:Bounds height="145.0" width="540.0" x="84.0" y="96.0"/>
|
||||
<dc:Bounds x="154" y="96" width="540" height="145" />
|
||||
</bpmndi:BPMNShape>
|
||||
<bpmndi:BPMNShape id="_BPMNShape_Participant_3" bpmnElement="Participant_B" isHorizontal="true">
|
||||
<dc:Bounds height="133.0" width="540.0" x="84.0" y="312.0"/>
|
||||
<dc:Bounds x="154" y="312" width="540" height="133" />
|
||||
</bpmndi:BPMNShape>
|
||||
<bpmndi:BPMNShape id="_BPMNShape_Task_2" bpmnElement="Task_A">
|
||||
<dc:Bounds height="80.0" width="100.0" x="168.0" y="129.0"/>
|
||||
<dc:Bounds x="238" y="129" width="100" height="80" />
|
||||
</bpmndi:BPMNShape>
|
||||
<bpmndi:BPMNShape id="_BPMNShape_Lane_2" bpmnElement="Lane" isHorizontal="true">
|
||||
<dc:Bounds height="145.0" width="510.0" x="114.0" y="96.0"/>
|
||||
<dc:Bounds x="184" y="96" width="510" height="145" />
|
||||
</bpmndi:BPMNShape>
|
||||
<bpmndi:BPMNShape id="_BPMNShape_IntermediateCatchEvent_2" bpmnElement="Event">
|
||||
<dc:Bounds height="36.0" width="36.0" x="384.0" y="151.0"/>
|
||||
<dc:Bounds x="454" y="151" width="36" height="36" />
|
||||
<bpmndi:BPMNLabel>
|
||||
<dc:Bounds height="21.0" width="112.0" x="346.0" y="192.0"/>
|
||||
<dc:Bounds x="458" y="192" width="29" height="14" />
|
||||
</bpmndi:BPMNLabel>
|
||||
</bpmndi:BPMNShape>
|
||||
<bpmndi:BPMNEdge id="BPMNEdge_SequenceFlow_1" bpmnElement="SequenceFlow" sourceElement="_BPMNShape_Task_2" targetElement="_BPMNShape_IntermediateCatchEvent_2">
|
||||
<di:waypoint xsi:type="dc:Point" x="268.0" y="169.0"/>
|
||||
<di:waypoint xsi:type="dc:Point" x="384.0" y="169.0"/>
|
||||
<di:waypoint x="338" y="169" />
|
||||
<di:waypoint x="454" y="169" />
|
||||
<bpmndi:BPMNLabel>
|
||||
<dc:Bounds height="6.0" width="6.0" x="290.0" y="169.0"/>
|
||||
<dc:Bounds x="290" y="169" width="6" height="6" />
|
||||
</bpmndi:BPMNLabel>
|
||||
</bpmndi:BPMNEdge>
|
||||
<bpmndi:BPMNShape id="_BPMNShape_Task_3" bpmnElement="Task_B">
|
||||
<dc:Bounds height="80.0" width="100.0" x="492.0" y="339.0"/>
|
||||
<dc:Bounds x="562" y="339" width="100" height="80" />
|
||||
</bpmndi:BPMNShape>
|
||||
<bpmndi:BPMNShape id="Participant_0emukbw_di" bpmnElement="Participant_0emukbw" 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">
|
||||
<dc:Bounds x="184" y="475" width="510" height="150" />
|
||||
</bpmndi:BPMNShape>
|
||||
<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">
|
||||
<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">
|
||||
<dc:Bounds x="230" y="650" width="100" height="80" />
|
||||
</bpmndi:BPMNShape>
|
||||
</bpmndi:BPMNPlane>
|
||||
</bpmndi:BPMNDiagram>
|
||||
</bpmn2:definitions>
|
||||
</bpmn2:definitions>
|
||||
|
|
Loading…
Reference in New Issue