Skip to content

Commit

Permalink
Merge pull request #1372 from ProcessMaker/bugfix/ticket-593
Browse files Browse the repository at this point in the history
Fix remove pools
  • Loading branch information
boliviacoca authored Aug 18, 2021
2 parents eafb509 + e5a6343 commit ebf7f9c
Show file tree
Hide file tree
Showing 14 changed files with 627 additions and 5 deletions.
1 change: 1 addition & 0 deletions src/components/crown/crownButtons/deleteButton.vue
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ export default {
methods: {
removeFlows,
removeShape() {
// @todo this should be handled by the Modeler.vue
this.removeFlows(this.graph, this.shape);
this.$emit('remove-node', this.node);
},
Expand Down
52 changes: 52 additions & 0 deletions src/components/crown/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,58 @@ export function removeFlows(graph, shape) {
linkShapes.forEach(shape => this.$emit('remove-node', shape.component.node));
}

// Remove the incoming and outgoing flows of a node
export function removeNodeFlows(node, modeler) {
if (node.definition.incoming) {
node.definition.incoming.forEach((flow) => {
const node = modeler.nodes.find(node => node.definition === flow);
modeler.removeNode(node);
});
}
if (node.definition.outgoing) {
node.definition.outgoing.forEach((flow) => {
const node = modeler.nodes.find(node => node.definition === flow);
modeler.removeNode(node);
});
}
}
// Remove the associations of a node
export function removeNodeMessageFlows(node, modeler) {
const linkedMessages = modeler.nodes.filter(n => {
if (n.definition.sourceRef) {
if (n.definition.sourceRef === node.definition) {
return true;
}
}
if (n.definition.targetRef) {
if (n.definition.targetRef === node.definition) {
return true;
}
}
});
linkedMessages.forEach((messageFlow) => {
modeler.removeNode(messageFlow);
});
}
// Remove the associations of a node
export function removeNodeAssociations(node, modeler) {
const linkedAssociations = modeler.nodes.filter(n => {
if (n.definition.sourceRef) {
if (n.definition.sourceRef === node.definition) {
return true;
}
}
if (n.definition.targetRef) {
if (n.definition.targetRef === node.definition) {
return true;
}
}
});
linkedAssociations.forEach((association) => {
modeler.removeNode(association);
});
}

export function removeBoundaryEvents(graph, node, removeNode) {
const nodeShape = graph.getCells().find(el => el.component && el.component.node === node);

Expand Down
36 changes: 31 additions & 5 deletions src/components/modeler/Modeler.vue
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ import setUpSelectionBox from '@/components/modeler/setUpSelectionBox';
import TimerEventNode from '@/components/nodes/timerEventNode';
import focusNameInputAndHighlightLabel from '@/components/modeler/focusNameInputAndHighlightLabel';
import XMLManager from '@/components/modeler/XMLManager';
import { removeOutgoingAndIncomingRefsToFlow, removeBoundaryEvents, removeSourceDefault } from '@/components/crown/utils';
import { removeNodeFlows, removeNodeMessageFlows, removeNodeAssociations, removeOutgoingAndIncomingRefsToFlow, removeBoundaryEvents, removeSourceDefault } from '@/components/crown/utils';
import { getInvalidNodes } from '@/components/modeler/modelerUtils';
import { NodeMigrator } from '@/components/modeler/NodeMigrator';
Expand Down Expand Up @@ -779,12 +779,18 @@ export default {
});
});
},
async removeNode(node) {
async removeNode(node, { removeRelationships = true } = {}) {
if (removeRelationships) {
removeNodeFlows(node, this);
removeNodeMessageFlows(node, this);
removeNodeAssociations(node, this);
}
removeOutgoingAndIncomingRefsToFlow(node);
removeBoundaryEvents(this.graph, node, this.removeNode);
removeSourceDefault(node);
this.removeNodeFromLane(node);
this.removeNodesFromLane(node);
this.removeNodesFromPool(node);
store.commit('removeNode', node);
store.commit('highlightNode', this.processNode);
await this.$nextTick();
Expand All @@ -800,7 +806,7 @@ export default {
nodeThatWillBeReplaced: node,
});
await this.removeNode(node);
await this.removeNode(node, { removeRelationships: false });
this.highlightNode(newNode);
});
});
Expand All @@ -823,7 +829,7 @@ export default {
undoRedoStore.commit('enableSavingState');
this.pushToUndoStack();
},
removeNodeFromLane(node) {
removeNodesFromLane(node) {
const containingLane = node.pool && node.pool.component.laneSet &&
node.pool.component.laneSet.get('lanes').find(lane => {
return lane.get('flowNodeRef').includes(node.definition);
Expand All @@ -835,6 +841,26 @@ export default {
pull(containingLane.get('flowNodeRef'), node.definition);
},
removeNodesFromPool(node) {
if (node.type === 'processmaker-modeler-pool' && node.definition.processRef) {
if (node.definition.processRef.artifacts) {
node.definition.processRef.artifacts.forEach(artifact => {
const nodeToRemove = this.nodes.find(n => n.definition === artifact);
if (nodeToRemove) {
this.removeNode(nodeToRemove);
}
});
}
if (node.definition.processRef.flowElements) {
node.definition.processRef.flowElements.forEach(flowElement => {
const nodeToRemove = this.nodes.find(n => n.definition === flowElement);
if (nodeToRemove) {
this.removeNode(nodeToRemove);
}
});
}
}
},
handleResize() {
const { clientWidth, clientHeight } = this.$el.parentElement;
this.parentWidth = clientWidth + 'px';
Expand Down
25 changes: 25 additions & 0 deletions tests/e2e/fixtures/AssociationInsidePool.after.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?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" id="Definitions_03dabax" targetNamespace="http://bpmn.io/schema/bpmn" exporter="ProcessMaker Modeler" exporterVersion="1.0">
<bpmn:process id="Process_1" isExecutable="true">
<bpmn:startEvent id="node_2" name="Start Event" />
<bpmn:textAnnotation id="node_3">
<bpmn:text>Text Annotation</bpmn:text>
</bpmn:textAnnotation>
</bpmn:process>
<bpmn:collaboration id="collaboration_0">
<bpmn:participant id="node_1" name="Pool" processRef="Process_1" />
</bpmn:collaboration>
<bpmndi:BPMNDiagram id="BPMNDiagram_1">
<bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="collaboration_0">
<bpmndi:BPMNShape id="node_1_di" bpmnElement="node_1">
<dc:Bounds x="80" y="110" width="600" height="300" />
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="node_2_di" bpmnElement="node_2">
<dc:Bounds x="170" y="250" width="36" height="36" />
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="node_3_di" bpmnElement="node_3">
<dc:Bounds x="440" y="160" width="150" height="30" />
</bpmndi:BPMNShape>
</bpmndi:BPMNPlane>
</bpmndi:BPMNDiagram>
</bpmn:definitions>
43 changes: 43 additions & 0 deletions tests/e2e/fixtures/AssociationInsidePool.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
<?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:di="http://www.omg.org/spec/DD/20100524/DI" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:pm="http://processmaker.com/BPMN/2.0/Schema.xsd" id="Definitions_03dabax" targetNamespace="http://bpmn.io/schema/bpmn" exporter="ProcessMaker Modeler" exporterVersion="1.0">
<bpmn:process id="Process_1" isExecutable="true">
<bpmn:startEvent id="node_2" name="Start Event">
<bpmn:outgoing>node_6</bpmn:outgoing>
</bpmn:startEvent>
<bpmn:task id="node_4" name="Form Task" pm:assignment="requester">
<bpmn:incoming>node_6</bpmn:incoming>
</bpmn:task>
<bpmn:sequenceFlow id="node_6" sourceRef="node_2" targetRef="node_4" />
<bpmn:textAnnotation id="node_3">
<bpmn:text>Text Annotation</bpmn:text>
</bpmn:textAnnotation>
<bpmn:association id="node_7" associationDirection="None" sourceRef="node_3" targetRef="node_4" />
</bpmn:process>
<bpmn:collaboration id="collaboration_0">
<bpmn:participant id="node_1" name="Pool" processRef="Process_1" />
</bpmn:collaboration>
<bpmndi:BPMNDiagram id="BPMNDiagram_1">
<bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="collaboration_0">
<bpmndi:BPMNShape id="node_1_di" bpmnElement="node_1">
<dc:Bounds x="80" y="110" width="600" height="300" />
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="node_2_di" bpmnElement="node_2">
<dc:Bounds x="170" y="250" width="36" height="36" />
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="node_3_di" bpmnElement="node_3">
<dc:Bounds x="440" y="160" width="150" height="30" />
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="node_4_di" bpmnElement="node_4">
<dc:Bounds x="290" y="230" width="116" height="76" />
</bpmndi:BPMNShape>
<bpmndi:BPMNEdge id="node_6_di" bpmnElement="node_6">
<di:waypoint x="188" y="268" />
<di:waypoint x="348" y="268" />
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge id="node_7_di" bpmnElement="node_7">
<di:waypoint x="445" y="174.01" />
<di:waypoint x="348" y="268" />
</bpmndi:BPMNEdge>
</bpmndi:BPMNPlane>
</bpmndi:BPMNDiagram>
</bpmn:definitions>
7 changes: 7 additions & 0 deletions tests/e2e/fixtures/Pools-DeleteLastPool.after.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?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" id="Definitions_03dabax" targetNamespace="http://bpmn.io/schema/bpmn" exporter="ProcessMaker Modeler" exporterVersion="1.0">
<bpmn:process id="Process_1" isExecutable="true" />
<bpmndi:BPMNDiagram id="BPMNDiagram_1">
<bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="Process_1" />
</bpmndi:BPMNDiagram>
</bpmn:definitions>
44 changes: 44 additions & 0 deletions tests/e2e/fixtures/Pools-DeleteLastPool.xml
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:di="http://www.omg.org/spec/DD/20100524/DI" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:pm="http://processmaker.com/BPMN/2.0/Schema.xsd" id="Definitions_03dabax" targetNamespace="http://bpmn.io/schema/bpmn" exporter="ProcessMaker Modeler" exporterVersion="1.0">
<bpmn:process id="Process_1" isExecutable="true">
<bpmn:startEvent id="node_3" name="Start Event">
<bpmn:outgoing>node_6</bpmn:outgoing>
</bpmn:startEvent>
<bpmn:task id="node_4" name="Form Task" pm:assignment="requester">
<bpmn:incoming>node_6</bpmn:incoming>
<bpmn:outgoing>node_9</bpmn:outgoing>
</bpmn:task>
<bpmn:sequenceFlow id="node_6" sourceRef="node_3" targetRef="node_4" />
<bpmn:endEvent id="node_7" name="End Event">
<bpmn:incoming>node_9</bpmn:incoming>
</bpmn:endEvent>
<bpmn:sequenceFlow id="node_9" sourceRef="node_4" targetRef="node_7" />
</bpmn:process>
<bpmn:collaboration id="collaboration_0">
<bpmn:participant id="node_2" name="Pool" processRef="Process_1" />
</bpmn:collaboration>
<bpmndi:BPMNDiagram id="BPMNDiagram_1">
<bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="collaboration_0">
<bpmndi:BPMNShape id="node_2_di" bpmnElement="node_2">
<dc:Bounds x="90" y="100" width="600" height="300" />
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="node_3_di" bpmnElement="node_3">
<dc:Bounds x="170" y="220" width="36" height="36" />
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="node_4_di" bpmnElement="node_4">
<dc:Bounds x="300" y="200" width="116" height="76" />
</bpmndi:BPMNShape>
<bpmndi:BPMNEdge id="node_6_di" bpmnElement="node_6">
<di:waypoint x="188" y="238" />
<di:waypoint x="358" y="238" />
</bpmndi:BPMNEdge>
<bpmndi:BPMNShape id="node_7_di" bpmnElement="node_7">
<dc:Bounds x="510" y="220" width="36" height="36" />
</bpmndi:BPMNShape>
<bpmndi:BPMNEdge id="node_9_di" bpmnElement="node_9">
<di:waypoint x="358" y="238" />
<di:waypoint x="528" y="238" />
</bpmndi:BPMNEdge>
</bpmndi:BPMNPlane>
</bpmndi:BPMNDiagram>
</bpmn:definitions>
47 changes: 47 additions & 0 deletions tests/e2e/fixtures/Pools-DeletePoolCommonSignalEvents.after.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
<?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:di="http://www.omg.org/spec/DD/20100524/DI" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:pm="http://processmaker.com/BPMN/2.0/Schema.xsd" id="Definitions_03dabax" targetNamespace="http://bpmn.io/schema/bpmn" exporter="ProcessMaker Modeler" exporterVersion="1.0">
<bpmn:process id="Process_1" isExecutable="true">
<bpmn:startEvent id="node_2" name="Start Event">
<bpmn:outgoing>node_6</bpmn:outgoing>
</bpmn:startEvent>
<bpmn:task id="node_3" name="Form Task" pm:assignment="requester">
<bpmn:incoming>node_6</bpmn:incoming>
<bpmn:outgoing>node_8</bpmn:outgoing>
</bpmn:task>
<bpmn:sequenceFlow id="node_6" name="flow1" sourceRef="node_2" targetRef="node_3" />
<bpmn:endEvent id="node_9" name="Signal End Event">
<bpmn:incoming>node_8</bpmn:incoming>
<bpmn:signalEventDefinition signalRef="global_1" />
</bpmn:endEvent>
<bpmn:sequenceFlow id="node_8" name="flow2" sourceRef="node_3" targetRef="node_9" />
</bpmn:process>
<bpmn:collaboration id="collaboration_0">
<bpmn:participant id="node_1" name="Pool" processRef="Process_1" />
</bpmn:collaboration>
<bpmn:signal id="global_1" name="global signal 1" />
<bpmn:signal id="global_2" name="global signal 2" />
<bpmndi:BPMNDiagram id="BPMNDiagram_1">
<bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="collaboration_0">
<bpmndi:BPMNShape id="node_1_di" bpmnElement="node_1">
<dc:Bounds x="90" y="110" width="600" height="300" />
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="node_2_di" bpmnElement="node_2">
<dc:Bounds x="160" y="230" width="36" height="36" />
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="node_3_di" bpmnElement="node_3">
<dc:Bounds x="290" y="210" width="116" height="76" />
</bpmndi:BPMNShape>
<bpmndi:BPMNEdge id="node_6_di" bpmnElement="node_6">
<di:waypoint x="178" y="248" />
<di:waypoint x="348" y="248" />
</bpmndi:BPMNEdge>
<bpmndi:BPMNShape id="node_9_di" bpmnElement="node_9">
<dc:Bounds x="500" y="230" width="36" height="36" />
</bpmndi:BPMNShape>
<bpmndi:BPMNEdge id="node_8_di" bpmnElement="node_8">
<di:waypoint x="348" y="248" />
<di:waypoint x="518" y="248" />
</bpmndi:BPMNEdge>
</bpmndi:BPMNPlane>
</bpmndi:BPMNDiagram>
</bpmn:definitions>
84 changes: 84 additions & 0 deletions tests/e2e/fixtures/Pools-DeletePoolCommonSignalEvents.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
<?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:di="http://www.omg.org/spec/DD/20100524/DI" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:pm="http://processmaker.com/BPMN/2.0/Schema.xsd" id="Definitions_03dabax" targetNamespace="http://bpmn.io/schema/bpmn" exporter="ProcessMaker Modeler" exporterVersion="1.0">
<bpmn:process id="Process_1" isExecutable="true">
<bpmn:startEvent id="node_2" name="Start Event">
<bpmn:outgoing>node_6</bpmn:outgoing>
</bpmn:startEvent>
<bpmn:task id="node_3" name="Form Task" pm:assignment="requester">
<bpmn:incoming>node_6</bpmn:incoming>
<bpmn:outgoing>node_8</bpmn:outgoing>
</bpmn:task>
<bpmn:sequenceFlow id="node_6" name="flow1" sourceRef="node_2" targetRef="node_3" />
<bpmn:endEvent id="node_9" name="Signal End Event">
<bpmn:incoming>node_8</bpmn:incoming>
<bpmn:signalEventDefinition signalRef="global_1" />
</bpmn:endEvent>
<bpmn:sequenceFlow id="node_8" name="flow2" sourceRef="node_3" targetRef="node_9" />
<bpmn:sequenceFlow id="node_17" name="flow3" sourceRef="node_14" targetRef="node_15" />
<bpmn:sequenceFlow id="node_21" name="flow4" sourceRef="node_15" targetRef="node_19" />
</bpmn:process>
<bpmn:collaboration id="collaboration_0">
<bpmn:participant id="node_1" name="Pool" processRef="Process_1" />
<bpmn:participant id="node_12" name="Pool" processRef="process_2" />
</bpmn:collaboration>
<bpmn:signal id="global_1" name="global signal 1" />
<bpmn:process id="process_2">
<bpmn:startEvent id="node_14" name="Signal Start Event">
<bpmn:outgoing>node_17</bpmn:outgoing>
<bpmn:signalEventDefinition />
</bpmn:startEvent>
<bpmn:task id="node_15" name="Form Task" pm:assignment="requester">
<bpmn:incoming>node_17</bpmn:incoming>
<bpmn:outgoing>node_21</bpmn:outgoing>
</bpmn:task>
<bpmn:endEvent id="node_19" name="Signal End Event">
<bpmn:incoming>node_21</bpmn:incoming>
<bpmn:signalEventDefinition signalRef="global_2" />
</bpmn:endEvent>
</bpmn:process>
<bpmn:signal id="global_2" name="global signal 2" />
<bpmndi:BPMNDiagram id="BPMNDiagram_1">
<bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="collaboration_0">
<bpmndi:BPMNShape id="node_1_di" bpmnElement="node_1">
<dc:Bounds x="90" y="110" width="600" height="300" />
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="node_2_di" bpmnElement="node_2">
<dc:Bounds x="160" y="230" width="36" height="36" />
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="node_3_di" bpmnElement="node_3">
<dc:Bounds x="290" y="210" width="116" height="76" />
</bpmndi:BPMNShape>
<bpmndi:BPMNEdge id="node_6_di" bpmnElement="node_6">
<di:waypoint x="178" y="248" />
<di:waypoint x="348" y="248" />
</bpmndi:BPMNEdge>
<bpmndi:BPMNShape id="node_9_di" bpmnElement="node_9">
<dc:Bounds x="500" y="230" width="36" height="36" />
</bpmndi:BPMNShape>
<bpmndi:BPMNEdge id="node_8_di" bpmnElement="node_8">
<di:waypoint x="348" y="248" />
<di:waypoint x="518" y="248" />
</bpmndi:BPMNEdge>
<bpmndi:BPMNShape id="node_12_di" bpmnElement="node_12">
<dc:Bounds x="90" y="440" width="600" height="300" />
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="node_14_di" bpmnElement="node_14">
<dc:Bounds x="170" y="570" width="36" height="36" />
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="node_15_di" bpmnElement="node_15">
<dc:Bounds x="310" y="550" width="116" height="76" />
</bpmndi:BPMNShape>
<bpmndi:BPMNEdge id="node_17_di" bpmnElement="node_17">
<di:waypoint x="188" y="588" />
<di:waypoint x="368" y="588" />
</bpmndi:BPMNEdge>
<bpmndi:BPMNShape id="node_19_di" bpmnElement="node_19">
<dc:Bounds x="520" y="570" width="36" height="36" />
</bpmndi:BPMNShape>
<bpmndi:BPMNEdge id="node_21_di" bpmnElement="node_21">
<di:waypoint x="368" y="588" />
<di:waypoint x="538" y="588" />
</bpmndi:BPMNEdge>
</bpmndi:BPMNPlane>
</bpmndi:BPMNDiagram>
</bpmn:definitions>
Loading

0 comments on commit ebf7f9c

Please sign in to comment.