Skip to content

Commit

Permalink
feat(context-pads): trigger events on all elements
Browse files Browse the repository at this point in the history
  • Loading branch information
nikku committed Dec 16, 2023
1 parent 4de93b9 commit 91952dd
Show file tree
Hide file tree
Showing 5 changed files with 230 additions and 4 deletions.
5 changes: 2 additions & 3 deletions lib/features/context-pads/ContextPads.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,8 @@ export default function ContextPads(

this.registerHandler('bpmn:Activity', PauseHandler);

this.registerHandler('bpmn:StartEvent', TriggerHandler);
this.registerHandler('bpmn:IntermediateCatchEvent', TriggerHandler);
this.registerHandler('bpmn:BoundaryEvent', TriggerHandler);
this.registerHandler('bpmn:Event', TriggerHandler);
this.registerHandler('bpmn:Gateway', TriggerHandler);
this.registerHandler('bpmn:Activity', TriggerHandler);

eventBus.on(TOGGLE_MODE_EVENT, LOW_PRIORITY, context => {
Expand Down
8 changes: 7 additions & 1 deletion lib/features/context-pads/handler/TriggerHandler.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,15 @@ TriggerHandler.prototype.createContextPads = function(element) {
TriggerHandler.prototype.createTriggerContextPad = function(element) {

const contexts = () => {
return this._findSubscriptions({
const subscriptions = this._findSubscriptions({
element
});

const sortedSubscriptions = subscriptions.slice().sort((a, b) => {
return a.event.type === 'none' ? 1 : -1;
});

return sortedSubscriptions;
};

const html = `
Expand Down
88 changes: 88 additions & 0 deletions test/spec/SimulationSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -1485,6 +1485,94 @@ describe('simulation', function() {
});
});


describe('process', function() {

describe('implicit-start', function() {

const diagram = require('./implicit-start.bpmn');

beforeEach(bootstrapModeler(diagram, {
additionalModules: [
ModelerModule,
TestModule
]
}));

beforeEach(inject(function(simulationSupport, simulationTrace) {
simulationSupport.toggleSimulation(true);

simulationTrace.start();
}));


it('should trigger typed event', async function() {

// when
triggerElement('MESSAGE_START');

// then
expectHistory([
'GATEWAY',
'TASK',
'END',
'ESCALATION_THROW',
'MESSAGE_START'
]);
});


it('should trigger none event independently', async function() {

// when
triggerElement('NONE_START');

// then
expectHistory([
'GATEWAY',
'TASK',
'END',
'ESCALATION_THROW',
'NONE_START'
]);
});

});


describe('implicit-start-no-event', function() {

const diagram = require('./implicit-start-no-event.bpmn');

beforeEach(bootstrapModeler(diagram, {
additionalModules: [
ModelerModule,
TestModule
]
}));

beforeEach(inject(function(simulationSupport, simulationTrace) {
simulationSupport.toggleSimulation(true);

simulationTrace.start();
}));


it('should trigger task', async function() {

// when
triggerElement('TASK');

// then
expectHistory([
'TASK',
'OTHER_TASK'
]);
});
});

});

});


Expand Down
25 changes: 25 additions & 0 deletions test/spec/implicit-start-no-event.bpmn
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" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" id="Definitions_1" targetNamespace="http://bpmn.io/schema/bpmn" exporter="Camunda Modeler" exporterVersion="5.18.0">
<bpmn:process id="Process_1" isExecutable="true">
<bpmn:task id="TASK" name="TASK" />
<bpmn:boundaryEvent id="BOUNDARY_EVENT" name="BOUNDARY_EVENT" attachedToRef="TASK" />
<bpmn:task id="OTHER_TASK" name="OTHER_TASK" />
</bpmn:process>
<bpmndi:BPMNDiagram id="BPMNDiagram_1">
<bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="Process_1">
<bpmndi:BPMNShape id="TASK_di" bpmnElement="TASK">
<dc:Bounds x="160" y="220" width="100" height="80" />
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="OTHER_TASK_di" bpmnElement="OTHER_TASK">
<dc:Bounds x="160" y="80" width="100" height="80" />
<bpmndi:BPMNLabel />
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="Event_1f9q90w_di" bpmnElement="BOUNDARY_EVENT">
<dc:Bounds x="202" y="282" width="36" height="36" />
<bpmndi:BPMNLabel>
<dc:Bounds x="178" y="325" width="84" height="27" />
</bpmndi:BPMNLabel>
</bpmndi:BPMNShape>
</bpmndi:BPMNPlane>
</bpmndi:BPMNDiagram>
</bpmn:definitions>
108 changes: 108 additions & 0 deletions test/spec/implicit-start.bpmn
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
<?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:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" id="Definitions_1" targetNamespace="http://bpmn.io/schema/bpmn" exporter="Camunda Modeler" exporterVersion="5.18.0">
<bpmn:process id="Process_1" isExecutable="true">
<bpmn:startEvent id="OTHER_NONE_START" name="OTHER_NONE_START" />
<bpmn:startEvent id="MESSAGE_START" name="MESSAGE_START">
<bpmn:messageEventDefinition id="MessageEventDefinition_14fvqpn" />
</bpmn:startEvent>
<bpmn:exclusiveGateway id="GATEWAY" name="GATEWAY" />
<bpmn:task id="TASK" name="TASK" />
<bpmn:endEvent id="END" name="END" />
<bpmn:startEvent id="NONE_START" name="NONE_START" />
<bpmn:dataObjectReference id="DATA_OBJECT" name="DATA_OBJECT" dataObjectRef="DataObject_1ctuzy5" />
<bpmn:dataObject id="DataObject_1ctuzy5" />
<bpmn:dataStoreReference id="DATA_STORE" name="DATA_STORE" />
<bpmn:intermediateCatchEvent id="LINK_CATCH" name="LINK_CATCH">
<bpmn:linkEventDefinition id="LinkEventDefinition_0klzcqk" name="" />
</bpmn:intermediateCatchEvent>
<bpmn:intermediateThrowEvent id="ESCALATION_THROW" name="ESCALATION_THROW">
<bpmn:escalationEventDefinition id="EscalationEventDefinition_0azvpsn" />
</bpmn:intermediateThrowEvent>
<bpmn:boundaryEvent id="BOUNDARY_EVENT" name="BOUNDARY_EVENT" attachedToRef="TASK">
<bpmn:compensateEventDefinition id="CompensateEventDefinition_0in260r" />
</bpmn:boundaryEvent>
<bpmn:task id="COMPENSATE_TASK" name="COMPENSATE_TASK" isForCompensation="true" />
<bpmn:subProcess id="EVENT_SUB_PROCESS" name="EVENT_SUB_PROCESS" triggeredByEvent="true" />
<bpmn:association id="Association_1" associationDirection="One" sourceRef="BOUNDARY_EVENT" targetRef="COMPENSATE_TASK" />
</bpmn:process>
<bpmndi:BPMNDiagram id="BPMNDiagram_1">
<bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="Process_1">
<bpmndi:BPMNShape id="OTHER_NONE_START_di" bpmnElement="OTHER_NONE_START">
<dc:Bounds x="312" y="82" width="36" height="36" />
<bpmndi:BPMNLabel>
<dc:Bounds x="288" y="125" width="84" height="27" />
</bpmndi:BPMNLabel>
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="MESSAGE_START_di" bpmnElement="MESSAGE_START">
<dc:Bounds x="192" y="202" width="36" height="36" />
<bpmndi:BPMNLabel>
<dc:Bounds x="169" y="245" width="82" height="27" />
</bpmndi:BPMNLabel>
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="GATEWAY_di" bpmnElement="GATEWAY" isMarkerVisible="true">
<dc:Bounds x="305" y="445" width="50" height="50" />
<bpmndi:BPMNLabel>
<dc:Bounds x="303" y="502" width="54" height="14" />
</bpmndi:BPMNLabel>
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="TASK_di" bpmnElement="TASK">
<dc:Bounds x="160" y="430" width="100" height="80" />
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="END_di" bpmnElement="END">
<dc:Bounds x="312" y="202" width="36" height="36" />
<bpmndi:BPMNLabel>
<dc:Bounds x="318" y="245" width="24" height="14" />
</bpmndi:BPMNLabel>
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="NONE_START_di" bpmnElement="NONE_START">
<dc:Bounds x="192" y="82" width="36" height="36" />
<bpmndi:BPMNLabel>
<dc:Bounds x="173" y="125" width="74" height="14" />
</bpmndi:BPMNLabel>
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="DATA_OBJECT_di" bpmnElement="DATA_OBJECT">
<dc:Bounds x="402" y="445" width="36" height="50" />
<bpmndi:BPMNLabel>
<dc:Bounds x="381" y="502" width="78" height="14" />
</bpmndi:BPMNLabel>
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="DATA_STORE_di" bpmnElement="DATA_STORE">
<dc:Bounds x="495" y="445" width="50" height="50" />
<bpmndi:BPMNLabel>
<dc:Bounds x="484" y="502" width="72" height="14" />
</bpmndi:BPMNLabel>
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="LINK_CATCH_di" bpmnElement="LINK_CATCH">
<dc:Bounds x="432" y="82" width="36" height="36" />
<bpmndi:BPMNLabel>
<dc:Bounds x="416" y="125" width="68" height="14" />
</bpmndi:BPMNLabel>
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="ESCALATION_THROW_di" bpmnElement="ESCALATION_THROW">
<dc:Bounds x="432" y="202" width="36" height="36" />
<bpmndi:BPMNLabel>
<dc:Bounds x="412" y="245" width="76" height="27" />
</bpmndi:BPMNLabel>
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="COMPENSATE_TASK_di" bpmnElement="COMPENSATE_TASK">
<dc:Bounds x="290" y="550" width="100" height="80" />
<bpmndi:BPMNLabel />
</bpmndi:BPMNShape>
<bpmndi:BPMNEdge id="Association_1_di" bpmnElement="Association_1">
<di:waypoint x="220" y="528" />
<di:waypoint x="220" y="590" />
<di:waypoint x="290" y="590" />
</bpmndi:BPMNEdge>
<bpmndi:BPMNShape id="Activity_11a204z_di" bpmnElement="EVENT_SUB_PROCESS" isExpanded="true">
<dc:Bounds x="610" y="70" width="350" height="200" />
<bpmndi:BPMNLabel />
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="Event_0yqkkgm_di" bpmnElement="BOUNDARY_EVENT">
<dc:Bounds x="202" y="492" width="36" height="36" />
<bpmndi:BPMNLabel>
<dc:Bounds x="179" y="535" width="83" height="27" />
</bpmndi:BPMNLabel>
</bpmndi:BPMNShape>
</bpmndi:BPMNPlane>
</bpmndi:BPMNDiagram>
</bpmn:definitions>

0 comments on commit 91952dd

Please sign in to comment.