Skip to content

Commit

Permalink
fix(attach-create-pad): do not show for compensation activities
Browse files Browse the repository at this point in the history
  • Loading branch information
philippfromme committed Jun 18, 2024
1 parent 72a8f7a commit 0e1aa08
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 7 deletions.
18 changes: 16 additions & 2 deletions lib/bpmn/attachCreatePad/AttachCreatePad.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
import { getBBox } from 'diagram-js/lib/util/Elements';

import { isEventSubProcess } from 'bpmn-js/lib/util/DiUtil';
import { is } from 'bpmn-js/lib/util/ModelUtil';

import {
getBusinessObject,
is
} from 'bpmn-js/lib/util/ModelUtil';

import CreatePad from '../../common/createPad/CreatePad';

Expand Down Expand Up @@ -29,6 +33,10 @@ export default class AttachCreatePad extends CreatePad {
return false;
}

if (isCompensationActivity(target)) {
return false;
}

return is(target, 'bpmn:Task') || (is(target, 'bpmn:SubProcess') && !isEventSubProcess(target));
}

Expand Down Expand Up @@ -143,4 +151,10 @@ AttachCreatePad.$inject = [
'modeling',
'selection',
'translate'
];
];

function isCompensationActivity(element) {
const businessObject = getBusinessObject(element);

return businessObject.get('isForCompensation');
}
21 changes: 16 additions & 5 deletions test/spec/bpmn/attachCreatePad/AttachCreatePad.bpmn
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?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" xmlns:modeler="http://camunda.org/schema/modeler/1.0" id="Definitions_0ohanf9" targetNamespace="http://bpmn.io/schema/bpmn" exporter="Camunda Modeler" exporterVersion="5.22.0" modeler:executionPlatform="Camunda Cloud" modeler:executionPlatformVersion="8.5.0">
<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" xmlns:modeler="http://camunda.org/schema/modeler/1.0" id="Definitions_0ohanf9" targetNamespace="http://bpmn.io/schema/bpmn" exporter="Camunda Modeler" exporterVersion="5.23.0" modeler:executionPlatform="Camunda Cloud" modeler:executionPlatformVersion="8.5.0">
<bpmn:process id="Process_1" isExecutable="true">
<bpmn:startEvent id="StartEvent_1">
<bpmn:outgoing>SequenceFlow_1</bpmn:outgoing>
Expand All @@ -23,8 +23,12 @@
<bpmn:incoming>SequenceFlow_4</bpmn:incoming>
</bpmn:endEvent>
<bpmn:sequenceFlow id="SequenceFlow_4" sourceRef="SubProcess_1" targetRef="EndEvent_1" />
<bpmn:boundaryEvent id="BoundaryEvent_1" attachedToRef="Task_2" />
<bpmn:subProcess id="EventSubProcess_1" triggeredByEvent="true" />
<bpmn:boundaryEvent id="BoundaryEvent_1" attachedToRef="Task_2">
<bpmn:compensateEventDefinition id="CompensateEventDefinition_0nwj1nd" />
</bpmn:boundaryEvent>
<bpmn:task id="CompensationTask_1" isForCompensation="true" />
<bpmn:association id="Association_1" associationDirection="One" sourceRef="BoundaryEvent_1" targetRef="CompensationTask_1" />
</bpmn:process>
<bpmndi:BPMNDiagram id="BPMNDiagram_1">
<bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="Process_1">
Expand All @@ -37,16 +41,23 @@
<bpmndi:BPMNShape id="Activity_1fw04nj_di" bpmnElement="Task_2">
<dc:Bounds x="430" y="137" width="100" height="80" />
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="Event_1yq3fxl_di" bpmnElement="EndEvent_1">
<dc:Bounds x="1002" y="159" width="36" height="36" />
<bpmndi:BPMNShape id="Activity_0ympzti_di" bpmnElement="CompensationTask_1">
<dc:Bounds x="430" y="290" width="100" height="80" />
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="Activity_0yso1l7_di" bpmnElement="SubProcess_1" isExpanded="true">
<dc:Bounds x="590" y="77" width="350" height="200" />
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="Event_1yq3fxl_di" bpmnElement="EndEvent_1">
<dc:Bounds x="1002" y="159" width="36" height="36" />
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="Activity_1d1op5q_di" bpmnElement="EventSubProcess_1" isExpanded="true">
<dc:Bounds x="590" y="330" width="350" height="200" />
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="Event_1r4d594_di" bpmnElement="BoundaryEvent_1">
<bpmndi:BPMNEdge id="Association_14uughz_di" bpmnElement="Association_1">
<di:waypoint x="480" y="235" />
<di:waypoint x="480" y="290" />
</bpmndi:BPMNEdge>
<bpmndi:BPMNShape id="Event_1epaakt_di" bpmnElement="BoundaryEvent_1">
<dc:Bounds x="462" y="199" width="36" height="36" />
</bpmndi:BPMNShape>
<bpmndi:BPMNEdge id="Flow_1itel7a_di" bpmnElement="SequenceFlow_1">
Expand Down
13 changes: 13 additions & 0 deletions test/spec/bpmn/attachCreatePad/AttachCreatePad.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,19 @@ describe('<AttachCreatePad>', function() {
}));


it('should return false if attach not allowed (compensation activity)', inject(function(attachCreatePad, elementRegistry) {

// given
const compensationTask = elementRegistry.get('CompensationTask_1');

// when
const canOpen = attachCreatePad.canOpen(compensationTask);

// then
expect(canOpen).to.be.false;
}));


it('should return false if attach not allowed (event subprocess)', inject(function(attachCreatePad, elementRegistry) {

// given
Expand Down

0 comments on commit 0e1aa08

Please sign in to comment.