camunda-bpmn-js 0.11.4 → 0.12.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (27) hide show
  1. package/CHANGELOG.md +22 -5
  2. package/dist/base-modeler.development.js +89 -1060
  3. package/dist/base-modeler.production.min.js +3 -3
  4. package/dist/camunda-cloud-modeler.development.js +734 -1570
  5. package/dist/camunda-cloud-modeler.production.min.js +3 -3
  6. package/dist/camunda-platform-modeler.development.js +291 -1354
  7. package/dist/camunda-platform-modeler.production.min.js +3 -3
  8. package/lib/camunda-cloud/features/modeling/behavior/CleanUpAssignmentDefinitionBehavior.js +78 -0
  9. package/lib/camunda-cloud/features/modeling/behavior/CleanUpBusinessRuleTaskBehavior.js +112 -0
  10. package/lib/camunda-cloud/features/modeling/behavior/CreateZeebeBoundaryEventBehavior.js +51 -55
  11. package/lib/camunda-cloud/features/modeling/behavior/CreateZeebeCallActivityBehavior.js +56 -59
  12. package/lib/camunda-cloud/features/modeling/behavior/FormDefinitionBehavior.js +69 -127
  13. package/lib/camunda-cloud/features/modeling/behavior/UpdatePropagateAllChildVariablesBehavior.js +76 -128
  14. package/lib/camunda-cloud/features/modeling/behavior/index.js +6 -0
  15. package/lib/camunda-cloud/features/properties-provider/parts/implementation/InputOutput.js +21 -7
  16. package/lib/camunda-cloud/features/rules/BpmnRules.js +1 -1
  17. package/lib/camunda-cloud/helper/CalledElementHelper.js +43 -41
  18. package/lib/camunda-cloud/helper/FormsHelper.js +38 -50
  19. package/lib/camunda-cloud/helper/InputOutputHelper.js +92 -106
  20. package/lib/camunda-platform/features/modeling/behavior/DeleteErrorEventDefinitionBehavior.js +24 -47
  21. package/lib/camunda-platform/features/modeling/behavior/DeleteRetryTimeCycleBehavior.js +39 -81
  22. package/lib/camunda-platform/features/modeling/behavior/UpdateCamundaExclusiveBehavior.js +31 -65
  23. package/lib/camunda-platform/features/modeling/behavior/UpdateInputOutputBehavior.js +42 -76
  24. package/lib/camunda-platform/features/modeling/behavior/UpdateResultVariableBehavior.js +21 -26
  25. package/lib/camunda-platform/features/modeling/behavior/UserTaskFormsBehavior.js +16 -10
  26. package/lib/camunda-platform/helper/InputOutputHelper.js +29 -0
  27. package/package.json +5 -5
@@ -1,6 +1,4 @@
1
1
 
2
- import inherits from 'inherits';
3
-
4
2
  import CommandInterceptor from 'diagram-js/lib/command/CommandInterceptor';
5
3
 
6
4
  import elementHelper from 'bpmn-js-properties-panel/lib/helper/ElementHelper';
@@ -10,11 +8,6 @@ import {
10
8
  is
11
9
  } from 'bpmn-js/lib/util/ModelUtil';
12
10
 
13
- import {
14
- remove as collectionRemove,
15
- add as collectionAdd
16
- } from 'diagram-js/lib/util/Collections';
17
-
18
11
  import {
19
12
  createFormDefinition,
20
13
  createFormId,
@@ -26,161 +19,110 @@ import {
26
19
 
27
20
 
28
21
  /**
29
- * Zeebe specific form definition behavior.
22
+ * Zeebe BPMN specific form definition behavior.
30
23
  */
31
- export default function FormDefinitionBehavior(
32
- eventBus, bpmnFactory) {
33
-
34
- CommandInterceptor.call(this, eventBus);
35
-
36
- /**
37
- * ensures a zeebe:userTaskForm is cleaned up when user task got removed
38
- */
39
- this.executed('shape.delete', function(context) {
40
- const {
41
- shape,
42
- oldParent
43
- } = context;
44
-
45
- const rootElement = getRootElement(oldParent);
24
+ export default class FormDefinitionBehavior extends CommandInterceptor {
25
+ constructor(bpmnFactory, eventBus, modeling) {
26
+ super(eventBus);
46
27
 
47
- const userTaskForm = getUserTaskForm(shape, rootElement);
28
+ /**
29
+ * Remove zeebe:UserTaskForm on user task removed.
30
+ */
31
+ this.postExecute('shape.delete', function(context) {
32
+ const {
33
+ oldParent,
34
+ shape
35
+ } = context;
48
36
 
49
- const rootExtensionElements = rootElement.get('extensionElements');
37
+ const rootElement = getRootElement(oldParent);
50
38
 
51
- if (!is(shape, 'bpmn:UserTask') || !userTaskForm) {
52
- return;
53
- }
39
+ const userTaskForm = getUserTaskForm(shape, rootElement);
54
40
 
55
- collectionRemove(rootExtensionElements.get('values'), userTaskForm);
41
+ if (!is(shape, 'bpmn:UserTask') || !userTaskForm) {
42
+ return;
43
+ }
56
44
 
57
- context.removedUserTaskForm = userTaskForm;
58
- }, true);
45
+ const rootExtensionElements = rootElement.get('extensionElements');
59
46
 
60
- this.revert('shape.delete', function(context) {
61
- const {
62
- removedUserTaskForm,
63
- oldParent
64
- } = context;
47
+ const values = rootExtensionElements.get('values').filter((element) => {
48
+ return element !== userTaskForm;
49
+ });
65
50
 
66
- const rootElement = getRootElement(oldParent);
51
+ modeling.updateModdleProperties(shape, rootExtensionElements, { values });
52
+ }, true);
67
53
 
68
- const rootExtensionElements = rootElement.get('extensionElements');
69
54
 
70
- if (!removedUserTaskForm) {
71
- return;
72
- }
55
+ /**
56
+ * Create new zeebe:FormDefinition and zeebe:UserTaskForm on user task created.
57
+ */
58
+ this.postExecute('shape.create', function(context) {
59
+ const { shape } = context;
73
60
 
74
- collectionAdd(rootExtensionElements.get('values'), removedUserTaskForm);
75
- }, true);
61
+ const oldFormDefinition = getFormDefinition(shape);
76
62
 
63
+ if (!is(shape, 'bpmn:UserTask') || !oldFormDefinition) {
64
+ return;
65
+ }
77
66
 
78
- /**
79
- * create fresh new copied form definition + user task form
80
- */
81
- this.executed('shape.create', function(context) {
82
- const {
83
- shape,
84
- } = context;
67
+ const oldUserTaskForm = getUserTaskForm(shape);
85
68
 
86
- const oldFormDefinition = getFormDefinition(shape);
69
+ const rootElement = getRootElement(shape);
87
70
 
88
- if (!is(shape, 'bpmn:UserTask') || !oldFormDefinition) {
89
- return;
90
- }
71
+ const businessObject = getBusinessObject(shape);
91
72
 
92
- const oldUserTaskForm = getUserTaskForm(shape);
73
+ const extensionElements = businessObject.get('extensionElements');
93
74
 
94
- const rootElement = getRootElement(shape);
75
+ let rootExtensionElements = rootElement.get('extensionElements');
95
76
 
96
- const businessObject = getBusinessObject(shape);
77
+ // (1) ensure extension elements exists
78
+ if (!rootExtensionElements) {
79
+ rootExtensionElements = elementHelper.createElement('bpmn:ExtensionElements', { values: [] }, rootElement, bpmnFactory);
97
80
 
98
- const extensionElements = businessObject.get('extensionElements');
81
+ modeling.updateModdleProperties(shape, rootElement, { extensionElements: rootExtensionElements });
82
+ }
99
83
 
100
- let rootExtensionElements = rootElement.get('extensionElements');
84
+ // (2) remove existing form definition
85
+ let values = extensionElements.get('values').filter((element) => {
86
+ return element !== oldFormDefinition;
87
+ });
101
88
 
102
- // (1) ensure extension elements in root
103
- if (!rootExtensionElements) {
89
+ // (3) create new form definition
90
+ const formId = createFormId();
104
91
 
105
- rootExtensionElements = elementHelper.createElement(
106
- 'bpmn:ExtensionElements',
107
- { values: [] },
108
- rootElement,
109
- bpmnFactory
110
- );
92
+ const newFormDefinition = createFormDefinition({ formKey: createFormKey(formId) }, extensionElements, bpmnFactory);
111
93
 
112
- rootElement.set('extensionElements', rootExtensionElements);
113
- }
94
+ values = [
95
+ ...values,
96
+ newFormDefinition
97
+ ];
114
98
 
115
- // (2) remove existing form definition
116
- context.oldFormDefinition = oldFormDefinition;
99
+ modeling.updateModdleProperties(shape, extensionElements, {
100
+ values
101
+ });
117
102
 
118
- collectionRemove(extensionElements.get('values'), oldFormDefinition);
119
-
120
- const formId = createFormId();
121
-
122
- // (3) create new form definition
123
- const formDefinition = createFormDefinition(
124
- {
125
- formKey: createFormKey(formId)
126
- },
127
- extensionElements,
128
- bpmnFactory
129
- );
130
-
131
- collectionAdd(extensionElements.get('values'), formDefinition);
132
-
133
- // (4) create new user task form
134
- const userTaskForm = createUserTaskForm(
135
- {
103
+ // (4) create new user task form
104
+ const userTaskForm = createUserTaskForm({
136
105
  id: formId,
137
106
  body: oldUserTaskForm ? oldUserTaskForm.get('body') : ''
138
- },
139
- rootExtensionElements,
140
- bpmnFactory
141
- );
142
-
143
- collectionAdd(rootExtensionElements.get('values'), userTaskForm);
144
- }, true);
107
+ }, rootExtensionElements, bpmnFactory);
145
108
 
146
- this.revert('shape.create', function(context) {
147
- const {
148
- shape,
149
- oldFormDefinition
150
- } = context;
151
-
152
- const businessObject = getBusinessObject(shape);
153
-
154
- const extensionElements = businessObject.get('extensionElements');
155
-
156
- const formDefinition = getFormDefinition(shape);
157
-
158
- const userTaskForm = getUserTaskForm(shape);
159
-
160
- const rootElement = getRootElement(shape);
161
-
162
- const rootExtensionElements = rootElement.get('extensionElements');
163
-
164
- if (!is(shape, 'bpmn:UserTask') || !userTaskForm) {
165
- return;
166
- }
167
-
168
- // we need to cover the old form definition to make <redo> possible
169
- collectionRemove(extensionElements.get('values'), formDefinition);
170
- collectionAdd(extensionElements.get('values'), oldFormDefinition);
171
-
172
- collectionRemove(rootExtensionElements.get('values'), userTaskForm);
173
- }, true);
109
+ modeling.updateModdleProperties(shape, rootExtensionElements, {
110
+ values: [
111
+ ...(rootExtensionElements.get('values') || []),
112
+ userTaskForm
113
+ ]
114
+ });
115
+ }, true);
174
116
 
117
+ }
175
118
  }
176
119
 
177
120
  FormDefinitionBehavior.$inject = [
121
+ 'bpmnFactory',
178
122
  'eventBus',
179
- 'bpmnFactory'
123
+ 'modeling'
180
124
  ];
181
125
 
182
- inherits(FormDefinitionBehavior, CommandInterceptor);
183
-
184
126
 
185
127
  // helpers //////////////
186
128
 
@@ -1,11 +1,8 @@
1
1
  import {
2
- getBusinessObject
2
+ getBusinessObject,
3
+ is
3
4
  } from 'bpmn-js/lib/util/ModelUtil';
4
5
 
5
- import inherits from 'inherits';
6
-
7
- import { is } from 'bpmn-js/lib/util/ModelUtil';
8
-
9
6
  import {
10
7
  getCalledElement,
11
8
  isPropagateAllChildVariables
@@ -14,148 +11,99 @@ import {
14
11
  import {
15
12
  getInputParameters,
16
13
  getOutputParameters,
17
- getInputOutput
14
+ getIoMapping
18
15
  } from '../../../helper/InputOutputHelper';
19
16
 
20
17
  import CommandInterceptor from 'diagram-js/lib/command/CommandInterceptor';
21
18
 
22
- const HIGH_PRIORITY = 15000;
19
+ const HIGH_PRIORITY = 5000;
23
20
 
24
21
 
25
22
  /**
26
- * UpdatePropagateAllChildVariablesBehavior reacts to either (1) toggling on propagateAllChildVariables
27
- * when there are outputParameters present or (2) to adding outputParameters when
28
- * propagateAllChildVariables is set to true.
29
- * It will ensure that the propagateAllChildVariables attribute on calledElement
30
- * extensionElements for callActivities is always consistent with outputParameter mappings
23
+ * Zeebe BPMN behavior for updating zeebe:propagateAllChildVariables.
31
24
  */
32
- export default function UpdatePropagateAllChildVariablesBehavior(
33
- eventBus) {
34
-
35
- CommandInterceptor.call(this, eventBus);
36
-
37
- // Behavior when toggling propagateAllChildVariables /////////////////////////
38
- /**
39
- * remove outputParameters from zeebe:IoMapping when setting propgateAlLChildVariables
40
- * to true in the proeprties panel
41
- */
42
- this.executed('properties-panel.update-businessobject' , HIGH_PRIORITY, function(context) {
43
- const {
44
- element,
45
- properties
46
- } = context;
47
-
48
- // (1) Don't execute this behavior if we are not in a call activity or not
49
- // have properties to update or not update the propagateAllChildVariables
50
- // to false
51
- if (!is(element, 'bpmn:CallActivity') ||
52
- !properties ||
53
- !!properties.propagateAllChildVariables === false) {
54
- return;
55
- }
56
-
57
- // (2) Check whether we have outputParameters
58
- const outputParameters = getOutputParameters(element),
59
- inputParameters = getInputParameters(element);
60
-
61
- if (!outputParameters ||
62
- outputParameters.length === 0) {
63
- return;
64
- }
65
-
66
- // (3) Store old outputParameters and remove them
67
- context.oldOutputParameters = outputParameters;
68
-
69
- const inputOutput = getInputOutput(element);
70
- inputOutput.outputParameters = [];
71
-
72
- // (4) if we also have no inputParameters, store IOMapping and remove it
73
- if (!inputParameters || inputParameters.length === 0) {
74
- const extensionElements = getBusinessObject(element).extensionElements;
75
- context.oldExtensionElements = extensionElements.values;
76
-
77
- extensionElements.values = extensionElements.values.filter(ele => ele.$type !== 'zeebe:IoMapping');
78
- }
79
- }, true);
80
-
81
- // Revert behavior when toggling propagateAllChildVariables //////////////////
82
- this.reverted('properties-panel.update-businessobject', HIGH_PRIORITY, function(context) {
83
- const {
84
- element,
85
- oldOutputParameters,
86
- oldExtensionElements
87
- } = context;
88
-
89
- // (1) Only intercept the revert, if the behavior became active
90
- if (oldOutputParameters) {
91
-
92
- // (2) If we removed the IOMapping, bring it back first
93
- if (oldExtensionElements) {
94
- const extensionElements = getBusinessObject(element).extensionElements;
95
-
96
- extensionElements.values = oldExtensionElements;
25
+ export default class UpdatePropagateAllChildVariablesBehavior extends CommandInterceptor {
26
+ constructor(eventBus, modeling) {
27
+ super(eventBus);
28
+
29
+ /**
30
+ * Remove zeebe:OutputParameters when zeebe:propagateAllChildVariables is set to true.
31
+ */
32
+ this.postExecute('properties-panel.update-businessobject' , HIGH_PRIORITY, function(context) {
33
+ const {
34
+ element,
35
+ properties
36
+ } = context;
37
+
38
+ if (
39
+ !is(element, 'bpmn:CallActivity')
40
+ || !properties
41
+ || !!properties.propagateAllChildVariables === false
42
+ ) {
43
+ return;
97
44
  }
98
45
 
99
- // (3) Bring back the outputParameters
100
- const inputOutput = getInputOutput(element);
101
- inputOutput.outputParameters = oldOutputParameters;
102
- }
103
- }, true);
104
-
46
+ const inputParameters = getInputParameters(element),
47
+ outputParameters = getOutputParameters(element);
105
48
 
106
- // Behavior when adding outputParameters ////////////////////////////////////
107
- /**
108
- * un-toggle propgateAlLChildVariables when adding output parameters
109
- */
110
- this.executed('properties-panel.update-businessobject-list' , HIGH_PRIORITY, function(context) {
111
- const {
112
- element,
113
- objectsToAdd
114
- } = context;
115
-
116
-
117
- // (1) Exit if we are not in a CallActivity, not adding an OutputParameter or not
118
- // having set propagateAllChildVariables to false
119
- if (!is(element, 'bpmn:CallActivity') ||
120
- !objectsToAdd ||
121
- objectsToAdd.length === 0 ||
122
- objectsToAdd.filter(obj => is(obj, 'zeebe:Output')).length === 0 ||
123
- isPropagateAllChildVariables(element) === false) {
124
- return;
125
- }
49
+ if (!outputParameters || !outputParameters.length) {
50
+ return;
51
+ }
126
52
 
127
- // (2) Store the old propAllChildVariables value and update it then
128
- const bo = getBusinessObject(element),
129
- calledElement = getCalledElement(bo);
53
+ const ioMapping = getIoMapping(element);
130
54
 
131
- context.oldPropagateAllChildVariables = true;
55
+ modeling.updateModdleProperties(element, ioMapping, {
56
+ 'zeebe:outputParameters': []
57
+ });
132
58
 
133
- calledElement.propagateAllChildVariables = false;
134
- }, true);
59
+ if (!inputParameters || !inputParameters.length) {
60
+ const businessObject = getBusinessObject(element),
61
+ extensionElements = businessObject.get('extensionElements');
135
62
 
136
- // Revert behavior when adding outputParmaeters ////////////////////////////////////
137
- this.reverted('properties-panel.update-businessobject-list' , HIGH_PRIORITY, function(context) {
138
- const {
139
- element,
140
- oldPropagateAllChildVariables
141
- } = context;
63
+ const values = extensionElements.get('values').filter((element) => {
64
+ return !is(element, 'zeebe:IoMapping');
65
+ });
142
66
 
143
- // (1) Only intercept the revert, if the behavior became active
144
- if (oldPropagateAllChildVariables) {
145
- const bo = getBusinessObject(element),
146
- calledElement = getCalledElement(bo);
67
+ modeling.updateModdleProperties(element, extensionElements, {
68
+ values
69
+ });
70
+ }
71
+ }, true);
72
+
73
+
74
+ /**
75
+ * Set zeebe:propagateAllChildVariables to false on zeebe:Output added.
76
+ */
77
+ this.postExecute('properties-panel.update-businessobject-list' , HIGH_PRIORITY, function(context) {
78
+ const {
79
+ currentObject,
80
+ element,
81
+ objectsToAdd,
82
+ propertyName
83
+ } = context;
84
+
85
+ if (!is(element, 'bpmn:CallActivity')
86
+ || !is(currentObject, 'zeebe:IoMapping')
87
+ || (propertyName !== 'outputParameters' && propertyName !== 'zeebe:outputParameters')
88
+ || !objectsToAdd
89
+ || !objectsToAdd.length
90
+ || !objectsToAdd.find((object) => is(object, 'zeebe:Output'))
91
+ || !isPropagateAllChildVariables(element)) {
92
+ return;
93
+ }
147
94
 
148
- calledElement.propagateAllChildVariables = oldPropagateAllChildVariables;
149
- }
150
- }, true);
95
+ const businessObject = getBusinessObject(element),
96
+ calledElement = getCalledElement(businessObject);
151
97
 
98
+ modeling.updateModdleProperties(element, calledElement, {
99
+ 'zeebe:propagateAllChildVariables': false
100
+ });
101
+ }, true);
152
102
 
103
+ }
153
104
  }
154
105
 
155
-
156
106
  UpdatePropagateAllChildVariablesBehavior.$inject = [
157
- 'eventBus'
158
- ];
159
-
160
-
161
- inherits(UpdatePropagateAllChildVariablesBehavior, CommandInterceptor);
107
+ 'eventBus',
108
+ 'modeling'
109
+ ];
@@ -1,3 +1,5 @@
1
+ import CleanUpAssignmentDefinitionBehavior from './CleanUpAssignmentDefinitionBehavior';
2
+ import CleanUpBusinessRuleTaskBehavior from './CleanUpBusinessRuleTaskBehavior';
1
3
  import CreateZeebeBoundaryEventBehavior from './CreateZeebeBoundaryEventBehavior';
2
4
  import CreateZeebeCallActivityBehavior from './CreateZeebeCallActivityBehavior';
3
5
  import UpdatePropagateAllChildVariablesBehavior from './UpdatePropagateAllChildVariablesBehavior';
@@ -6,11 +8,15 @@ import FormDefinitionBehavior from './FormDefinitionBehavior';
6
8
 
7
9
  export default {
8
10
  __init__: [
11
+ 'cleanUpAssignmentDefinitionBehavior',
12
+ 'cleanUpBusinessRuleTaskBehavior',
9
13
  'createZeebeBoundaryEventBehavior',
10
14
  'createZeebeCallActivityBehavior',
11
15
  'updatePropagateAllChildVariablesBehavior',
12
16
  'formDefinitionBehavior'
13
17
  ],
18
+ cleanUpAssignmentDefinitionBehavior: [ 'type', CleanUpAssignmentDefinitionBehavior ],
19
+ cleanUpBusinessRuleTaskBehavior: [ 'type', CleanUpBusinessRuleTaskBehavior ],
14
20
  createZeebeBoundaryEventBehavior: [ 'type', CreateZeebeBoundaryEventBehavior ],
15
21
  createZeebeCallActivityBehavior: [ 'type', CreateZeebeCallActivityBehavior ],
16
22
  updatePropagateAllChildVariablesBehavior: [ 'type', UpdatePropagateAllChildVariablesBehavior ],
@@ -15,11 +15,12 @@ import entryFieldDescription from 'bpmn-js-properties-panel/lib/factory/EntryFie
15
15
  import {
16
16
  areOutputParametersSupported,
17
17
  areInputParametersSupported,
18
- createIOMapping,
18
+ createIoMapping,
19
19
  createElement as createParameter,
20
- determineParamGetFunc,
21
- getInputOutput,
22
- isInputOutputSupported
20
+ getIoMapping,
21
+ isInputOutputSupported,
22
+ getInputParameters,
23
+ getOutputParameters
23
24
  } from '../../../../helper/InputOutputHelper';
24
25
 
25
26
  import InputOutputParameter from './InputOutputParameter';
@@ -130,12 +131,12 @@ function getParametersHeadingEntry(element, bpmnFactory, options) {
130
131
  }
131
132
 
132
133
  // Get the IOMapping
133
- let inputOutput = getInputOutput(element);
134
+ let inputOutput = getIoMapping(element);
134
135
 
135
136
  if (!inputOutput) {
136
137
  const parent = extensionElements;
137
138
 
138
- inputOutput = createIOMapping(parent, bpmnFactory, {
139
+ inputOutput = createIoMapping(parent, bpmnFactory, {
139
140
  inputParameters: [],
140
141
  outputParameters: []
141
142
  });
@@ -190,7 +191,7 @@ function getParametersHeadingEntry(element, bpmnFactory, options) {
190
191
  function getIOMappingEntries(element, bpmnFactory, translate, options) {
191
192
 
192
193
  // Get the IOMapping and determine whether we are dealing with input or output parameters
193
- const inputOutput = getInputOutput(element, false),
194
+ const inputOutput = getIoMapping(element),
194
195
  params = determineParamGetFunc(options.prop)(element, false);
195
196
 
196
197
  if (!params.length) {
@@ -258,3 +259,16 @@ function getIOMappingEntries(element, bpmnFactory, translate, options) {
258
259
  });
259
260
  }
260
261
  }
262
+
263
+
264
+ // helpers //////////
265
+
266
+ function determineParamGetFunc(property) {
267
+ if (property == 'inputParameters') {
268
+ return getInputParameters;
269
+ }
270
+
271
+ if (property == 'outputParameters') {
272
+ return getOutputParameters;
273
+ }
274
+ }
@@ -22,7 +22,7 @@ import {
22
22
  getBoundaryAttachment as isBoundaryAttachment
23
23
  } from 'bpmn-js/lib/features/snapping/BpmnSnappingUtil';
24
24
 
25
- const HIGH_PRIORITY = 15000;
25
+ const HIGH_PRIORITY = 5000;
26
26
 
27
27
  /**
28
28
  * Zeebe rule provider that allows to create boundary events with catch events