Skip to content

Commit ec9f90f

Browse files
committed
fix: properly hide context pads based on scope filters
1 parent 5797471 commit ec9f90f

File tree

3 files changed

+150
-2
lines changed

3 files changed

+150
-2
lines changed

lib/features/context-pads/ContextPads.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ export default function ContextPads(
7272
eventBus.on(SCOPE_FILTER_CHANGED_EVENT, event => {
7373

7474
const showElements = domQueryAll(
75-
'.djs-overlay-ts-context-menu [data-scope-ids]',
75+
'.djs-overlay-bts-context-menu [data-scope-ids]',
7676
overlays._overlayRoot
7777
);
7878

@@ -86,7 +86,7 @@ export default function ContextPads(
8686
}
8787

8888
const hideElements = domQueryAll(
89-
'.djs-overlay-ts-context-menu [data-hide-scope-ids]',
89+
'.djs-overlay-bts-context-menu [data-hide-scope-ids]',
9090
overlays._overlayRoot
9191
);
9292

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<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:xsi="http://www.w3.org/2001/XMLSchema-instance" id="Definitions_1" targetNamespace="http://bpmn.io/schema/bpmn" exporter="bpmn-js-token-simulation" exporterVersion="0.36.3">
3+
<bpmn:process id="PROCESS" isExecutable="true">
4+
<bpmn:subProcess id="SUB_PROCESS" name="SUB_PROCESS">
5+
<bpmn:incoming>Flow_1etbflx</bpmn:incoming>
6+
<bpmn:task id="NESTED_TASK" name="NESTED_TASK" />
7+
</bpmn:subProcess>
8+
<bpmn:startEvent id="START" name="START">
9+
<bpmn:outgoing>Flow_1etbflx</bpmn:outgoing>
10+
</bpmn:startEvent>
11+
<bpmn:sequenceFlow id="Flow_1etbflx" sourceRef="START" targetRef="SUB_PROCESS" />
12+
</bpmn:process>
13+
<bpmndi:BPMNDiagram id="BPMNDiagram_1">
14+
<bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="PROCESS">
15+
<bpmndi:BPMNShape id="START_di" bpmnElement="START">
16+
<dc:Bounds x="-28" y="-38" width="36" height="36" />
17+
<bpmndi:BPMNLabel>
18+
<dc:Bounds x="-28" y="5" width="36" height="14" />
19+
</bpmndi:BPMNLabel>
20+
</bpmndi:BPMNShape>
21+
<bpmndi:BPMNShape id="SUB_PROCESS_di" bpmnElement="SUB_PROCESS" isExpanded="true">
22+
<dc:Bounds x="70" y="-120" width="350" height="200" />
23+
<bpmndi:BPMNLabel />
24+
</bpmndi:BPMNShape>
25+
<bpmndi:BPMNShape id="NESTED_TASK_di" bpmnElement="NESTED_TASK">
26+
<dc:Bounds x="180" y="-60" width="100" height="80" />
27+
<bpmndi:BPMNLabel />
28+
</bpmndi:BPMNShape>
29+
<bpmndi:BPMNEdge id="Flow_1etbflx_di" bpmnElement="Flow_1etbflx">
30+
<di:waypoint x="8" y="-20" />
31+
<di:waypoint x="70" y="-20" />
32+
</bpmndi:BPMNEdge>
33+
</bpmndi:BPMNPlane>
34+
</bpmndi:BPMNDiagram>
35+
</bpmn:definitions>
Lines changed: 113 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,113 @@
1+
import ModelerModule from 'lib/modeler';
2+
3+
import SimulationSupportModule from 'lib/simulation-support';
4+
5+
import {
6+
bootstrapModeler as _bootstrapModeler,
7+
inject,
8+
getBpmnJS,
9+
} from 'test/TestHelper';
10+
11+
12+
const TestModule = {
13+
__depends__: [
14+
SimulationSupportModule
15+
],
16+
__init__: [
17+
function(animation) {
18+
animation.setAnimationSpeed(100);
19+
}
20+
]
21+
};
22+
23+
function bootstrapModeler(diagram, config) {
24+
const {
25+
animation = {},
26+
...restConfig
27+
} = config;
28+
29+
return _bootstrapModeler(diagram, {
30+
...restConfig,
31+
animation: {
32+
randomize: false,
33+
...animation
34+
}
35+
});
36+
}
37+
38+
39+
describe('features/context-pads', function() {
40+
41+
const diagram = require('./ContextPads.scope-filter.bpmn');
42+
43+
beforeEach(bootstrapModeler(diagram, {
44+
additionalModules: [
45+
ModelerModule,
46+
TestModule
47+
]
48+
}));
49+
50+
beforeEach(inject(function(simulationSupport) {
51+
simulationSupport.toggleSimulation();
52+
}));
53+
54+
55+
it('should allow to start process', inject(
56+
async function() {
57+
58+
// then
59+
expect(canTriggerElement('START')).to.be.true;
60+
}
61+
));
62+
63+
64+
it('should allow to pause activities', inject(
65+
async function() {
66+
67+
// then
68+
expect(canTriggerElement('NESTED_TASK')).to.be.true;
69+
expect(canTriggerElement('SUB_PROCESS')).to.be.true;
70+
}
71+
));
72+
73+
74+
it('should filter scoped', inject(
75+
async function(scopeFilter) {
76+
77+
// given
78+
// toggle pause
79+
triggerElement('NESTED_TASK');
80+
81+
// start element
82+
triggerElement('START');
83+
84+
// when
85+
const { scope } = await elementEnter('NESTED_TASK');
86+
87+
scopeFilter.toggle(scope);
88+
89+
// then
90+
expect(canTriggerElement('START')).to.be.false;
91+
}
92+
));
93+
94+
});
95+
96+
97+
// helpers ////////////////////
98+
99+
function getSimulationSupport() {
100+
return getBpmnJS().get('simulationSupport');
101+
}
102+
103+
function canTriggerElement(...args) {
104+
return !!getSimulationSupport().getElementTrigger(...args);
105+
}
106+
107+
function triggerElement(...args) {
108+
return getSimulationSupport().triggerElement(...args);
109+
}
110+
111+
function elementEnter(...args) {
112+
return getSimulationSupport().elementEnter(...args);
113+
}

0 commit comments

Comments
 (0)