Skip to content

Commit 2d0334f

Browse files
committed
feat: support ad-hoc subprocesses
Related to camunda/camunda-modeler#4739 deps: update to `[email protected]`
1 parent e2be2ea commit 2d0334f

File tree

8 files changed

+363
-11
lines changed

8 files changed

+363
-11
lines changed

package-lock.json

Lines changed: 8 additions & 9 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@
105105
"sinon": "^17.0.1",
106106
"sinon-chai": "^3.7.0",
107107
"webpack": "^5.95.0",
108-
"zeebe-bpmn-moddle": "^1.7.0"
108+
"zeebe-bpmn-moddle": "^1.9.0"
109109
},
110110
"peerDependencies": {
111111
"@bpmn-io/properties-panel": ">= 3.7",

src/contextProvider/zeebe/TooltipProvider.js

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -348,7 +348,19 @@ const TooltipProvider = {
348348
<p>{ translate('If unset, the default value is 50.') }</p>
349349
</div>
350350
);
351-
}
351+
},
352+
'group-activeElements': (element) => {
353+
const translate = useService('translate');
354+
355+
return (
356+
<div>
357+
{translate('Define a collection of elements which will be activated when the ad-hoc subprocess is reached. ')}
358+
<a href="https://docs.camunda.io/docs/components/modeler/bpmn/ad-hoc/#activate-an-element" target="_blank" rel="noopener noreferrer" title={ translate('Ad-hoc subprocess documentation') }>
359+
{ translate('Learn more.') }
360+
</a>
361+
</div>
362+
);
363+
},
352364
};
353365

354366
export default TooltipProvider;

src/provider/zeebe/ZeebePropertiesProvider.js

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { Group, ListGroup } from '@bpmn-io/properties-panel';
33
import { findIndex } from 'min-dash';
44

55
import {
6+
ActiveElementsProps,
67
AssignmentDefinitionProps,
78
BusinessRuleImplementationProps,
89
CalledDecisionProps,
@@ -49,6 +50,7 @@ const ZEEBE_GROUPS = [
4950
UserTaskImplementationGroup,
5051
TaskDefinitionGroup,
5152
AssignmentDefinitionGroup,
53+
ActiveElementsGroup,
5254
FormGroup,
5355
ConditionGroup,
5456
TargetGroup,
@@ -309,6 +311,20 @@ function AssignmentDefinitionGroup(element, injector) {
309311
return group.entries.length ? group : null;
310312
}
311313

314+
function ActiveElementsGroup(element, injector) {
315+
const translate = injector.get('translate');
316+
const group = {
317+
id: 'activeElements',
318+
label: translate('Active elements'),
319+
entries: [
320+
...ActiveElementsProps({ element })
321+
],
322+
component: Group
323+
};
324+
325+
return group.entries.length ? group : null;
326+
}
327+
312328
function ExecutionListenersGroup(element, injector) {
313329
const translate = injector.get('translate');
314330
const group = {
Lines changed: 110 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,110 @@
1+
import {
2+
is,
3+
getBusinessObject
4+
} from 'bpmn-js/lib/util/ModelUtil';
5+
6+
import { isFeelEntryEdited } from '@bpmn-io/properties-panel';
7+
8+
import { useService } from 'src/hooks';
9+
10+
import { FeelEntryWithVariableContext } from 'src/entries/FeelEntryWithContext';
11+
12+
import {
13+
getExtensionElementsList,
14+
addExtensionElements
15+
} from 'src/utils/ExtensionElementsUtil';
16+
17+
import { createElement } from 'src/utils/ElementUtil';
18+
19+
export function ActiveElementsProps(props) {
20+
const {
21+
element
22+
} = props;
23+
24+
if (!is(element, 'bpmn:AdHocSubProcess')) {
25+
return [];
26+
}
27+
28+
const entries = [
29+
{
30+
id: 'activeElementsCollection',
31+
component: ActiveElementsCollection,
32+
isEdited: isFeelEntryEdited
33+
}
34+
];
35+
36+
return entries;
37+
}
38+
39+
function ActiveElementsCollection(props) {
40+
const {
41+
element
42+
} = props;
43+
44+
const commandStack = useService('commandStack');
45+
const bpmnFactory = useService('bpmnFactory');
46+
const translate = useService('translate');
47+
const debounce = useService('debounceInput');
48+
49+
const getValue = () => {
50+
return getProperty(element);
51+
};
52+
53+
const setValue = (value) => {
54+
return setProperty(element, value, commandStack, bpmnFactory);
55+
};
56+
57+
return FeelEntryWithVariableContext({
58+
element,
59+
id: 'activeElements-activeElementsCollection',
60+
label: translate('Active elements collection'),
61+
feel: 'required',
62+
getValue,
63+
setValue,
64+
debounce
65+
});
66+
}
67+
68+
function getProperty(element) {
69+
const extensionElement = getExtensionElement(element);
70+
return extensionElement && extensionElement.get('activeElementsCollection');
71+
}
72+
73+
function setProperty(element, value, commandStack, bpmnFactory) {
74+
75+
const extensionElement = getExtensionElement(element);
76+
77+
if (!extensionElement) {
78+
79+
// (1) create extension element
80+
const adHoc = createElement(
81+
'zeebe:AdHoc',
82+
{
83+
activeElementsCollection: value
84+
},
85+
undefined,
86+
bpmnFactory
87+
);
88+
89+
const businessObject = getBusinessObject(element);
90+
addExtensionElements(element, businessObject, adHoc, bpmnFactory, commandStack);
91+
92+
} else {
93+
94+
// (2) update extension element's property
95+
commandStack.execute('element.updateModdleProperties', {
96+
element,
97+
moddleElement: extensionElement,
98+
properties: {
99+
activeElementsCollection: value
100+
}
101+
});
102+
}
103+
}
104+
105+
function getExtensionElement(element) {
106+
const businessObject = getBusinessObject(element);
107+
const extensions = getExtensionElementsList(businessObject, 'zeebe:AdHoc');
108+
return extensions[0];
109+
}
110+

src/provider/zeebe/properties/index.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
export { ActiveElementsProps } from './ActiveElementsProps';
12
export { AssignmentDefinitionProps } from './AssignmentDefinitionProps';
23
export { BusinessRuleImplementationProps } from './BusinessRuleImplementationProps';
34
export { CalledDecisionProps } from './CalledDecisionProps';
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
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:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:modeler="http://camunda.org/schema/modeler/1.0" id="Definitions_1rk4hoy" targetNamespace="http://bpmn.io/schema/bpmn" exporter="Camunda Modeler" exporterVersion="5.30.0" modeler:executionPlatform="Camunda Cloud" modeler:executionPlatformVersion="8.6.0">
3+
<bpmn:process id="Process_1sk4u1k" isExecutable="true">
4+
<bpmn:adHocSubProcess id="Subprocess_1">
5+
<bpmn:task id="Activity_167ttdt" />
6+
<bpmn:task id="Activity_0cxw94m" />
7+
</bpmn:adHocSubProcess>
8+
<bpmn:adHocSubProcess id="Subprocess_2">
9+
<bpmn:extensionElements>
10+
<zeebe:adHoc activeElementsCollection="=activeElements" />
11+
</bpmn:extensionElements>
12+
<bpmn:task id="Activity_1qb8yya" />
13+
<bpmn:task id="Activity_1i2ek76" />
14+
</bpmn:adHocSubProcess>
15+
</bpmn:process>
16+
<bpmndi:BPMNDiagram id="BPMNDiagram_1">
17+
<bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="Process_1sk4u1k">
18+
<bpmndi:BPMNShape id="Activity_1hitopu_di" bpmnElement="Subprocess_1" isExpanded="true">
19+
<dc:Bounds x="160" y="70" width="350" height="200" />
20+
</bpmndi:BPMNShape>
21+
<bpmndi:BPMNShape id="Activity_167ttdt_di" bpmnElement="Activity_167ttdt">
22+
<dc:Bounds x="210" y="130" width="100" height="80" />
23+
</bpmndi:BPMNShape>
24+
<bpmndi:BPMNShape id="Activity_0cxw94m_di" bpmnElement="Activity_0cxw94m">
25+
<dc:Bounds x="360" y="130" width="100" height="80" />
26+
</bpmndi:BPMNShape>
27+
<bpmndi:BPMNShape id="BPMNShape_06ihycz" bpmnElement="Subprocess_2" isExpanded="true">
28+
<dc:Bounds x="540" y="70" width="350" height="200" />
29+
</bpmndi:BPMNShape>
30+
<bpmndi:BPMNShape id="BPMNShape_0c1eh57" bpmnElement="Activity_1qb8yya">
31+
<dc:Bounds x="590" y="130" width="100" height="80" />
32+
</bpmndi:BPMNShape>
33+
<bpmndi:BPMNShape id="BPMNShape_1g9skdj" bpmnElement="Activity_1i2ek76">
34+
<dc:Bounds x="740" y="130" width="100" height="80" />
35+
</bpmndi:BPMNShape>
36+
</bpmndi:BPMNPlane>
37+
</bpmndi:BPMNDiagram>
38+
</bpmn:definitions>

0 commit comments

Comments
 (0)