camunda-bpmn-js 0.11.5 → 0.13.0-alpha.0

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 (62) hide show
  1. package/CHANGELOG.md +27 -0
  2. package/dist/assets/base-modeler.css +1 -1
  3. package/dist/assets/camunda-platform-modeler.css +2 -1
  4. package/dist/assets/diagram-js.css +2 -0
  5. package/dist/assets/element-templates.css +75 -0
  6. package/dist/assets/properties-panel.css +889 -0
  7. package/dist/base-modeler.development.js +8542 -12092
  8. package/dist/base-modeler.production.min.js +8 -3
  9. package/dist/camunda-cloud-modeler.development.js +12089 -14412
  10. package/dist/camunda-cloud-modeler.production.min.js +8 -3
  11. package/dist/camunda-platform-modeler.development.js +22532 -25950
  12. package/dist/camunda-platform-modeler.production.min.js +8 -3
  13. package/lib/base/Modeler.js +5 -3
  14. package/lib/camunda-cloud/Modeler.js +5 -3
  15. package/lib/camunda-cloud/features/modeling/behavior/CleanUpAssignmentDefinitionBehavior.js +78 -0
  16. package/lib/camunda-cloud/features/modeling/behavior/CleanUpBusinessRuleTaskBehavior.js +112 -0
  17. package/lib/camunda-cloud/features/modeling/behavior/CreateZeebeBoundaryEventBehavior.js +51 -55
  18. package/lib/camunda-cloud/features/modeling/behavior/CreateZeebeCallActivityBehavior.js +57 -60
  19. package/lib/camunda-cloud/features/modeling/behavior/FormDefinitionBehavior.js +70 -128
  20. package/lib/camunda-cloud/features/modeling/behavior/UpdatePropagateAllChildVariablesBehavior.js +76 -128
  21. package/lib/camunda-cloud/features/modeling/behavior/index.js +6 -0
  22. package/lib/camunda-cloud/features/rules/BpmnRules.js +1 -1
  23. package/lib/camunda-cloud/helper/CalledElementHelper.js +43 -41
  24. package/lib/camunda-cloud/helper/ElementHelper.js +18 -0
  25. package/lib/camunda-cloud/helper/ExtensionElementsHelper.js +17 -0
  26. package/lib/camunda-cloud/helper/FormsHelper.js +41 -53
  27. package/lib/camunda-cloud/helper/InputOutputHelper.js +93 -111
  28. package/lib/camunda-cloud/helper/Utils.js +10 -0
  29. package/lib/camunda-cloud/helper/ZeebeServiceTaskHelper.js +22 -5
  30. package/lib/camunda-platform/Modeler.js +7 -3
  31. package/lib/camunda-platform/features/modeling/behavior/DeleteErrorEventDefinitionBehavior.js +24 -47
  32. package/lib/camunda-platform/features/modeling/behavior/DeleteRetryTimeCycleBehavior.js +39 -81
  33. package/lib/camunda-platform/features/modeling/behavior/UpdateCamundaExclusiveBehavior.js +31 -65
  34. package/lib/camunda-platform/features/modeling/behavior/UpdateInputOutputBehavior.js +42 -76
  35. package/lib/camunda-platform/features/modeling/behavior/UpdateResultVariableBehavior.js +21 -26
  36. package/lib/camunda-platform/features/modeling/behavior/UserTaskFormsBehavior.js +16 -10
  37. package/lib/camunda-platform/helper/InputOutputHelper.js +29 -0
  38. package/package.json +6 -5
  39. package/styles/base-modeler.css +1 -1
  40. package/styles/camunda-platform-modeler.css +2 -1
  41. package/dist/assets/bpmn-js-properties-panel.css +0 -778
  42. package/lib/camunda-cloud/features/properties-provider/ZeebePropertiesProvider.js +0 -201
  43. package/lib/camunda-cloud/features/properties-provider/index.js +0 -11
  44. package/lib/camunda-cloud/features/properties-provider/parts/CallActivityProps.js +0 -90
  45. package/lib/camunda-cloud/features/properties-provider/parts/ErrorProps.js +0 -13
  46. package/lib/camunda-cloud/features/properties-provider/parts/FormProps.js +0 -14
  47. package/lib/camunda-cloud/features/properties-provider/parts/HeadersProps.js +0 -52
  48. package/lib/camunda-cloud/features/properties-provider/parts/InputOutputProps.js +0 -8
  49. package/lib/camunda-cloud/features/properties-provider/parts/MessageProps.js +0 -51
  50. package/lib/camunda-cloud/features/properties-provider/parts/MultiInstanceProps.js +0 -25
  51. package/lib/camunda-cloud/features/properties-provider/parts/SequenceFlowProps.js +0 -149
  52. package/lib/camunda-cloud/features/properties-provider/parts/TaskDefinitionProps.js +0 -135
  53. package/lib/camunda-cloud/features/properties-provider/parts/TimerEventProps.js +0 -77
  54. package/lib/camunda-cloud/features/properties-provider/parts/implementation/ElementReferenceExtensionElementProperty.js +0 -110
  55. package/lib/camunda-cloud/features/properties-provider/parts/implementation/FormDefinition.js +0 -207
  56. package/lib/camunda-cloud/features/properties-provider/parts/implementation/Headers.js +0 -208
  57. package/lib/camunda-cloud/features/properties-provider/parts/implementation/InputOutput.js +0 -260
  58. package/lib/camunda-cloud/features/properties-provider/parts/implementation/InputOutputParameter.js +0 -147
  59. package/lib/camunda-cloud/features/properties-provider/parts/implementation/MultiInstanceLoopCharacteristics.js +0 -176
  60. package/lib/camunda-cloud/features/properties-provider/parts/implementation/OutputParameterToggle.js +0 -97
  61. package/lib/camunda-cloud/features/properties-provider/parts/implementation/TimerDurationDefinition.js +0 -69
  62. package/lib/camunda-cloud/features/properties-provider/parts/implementation/TimerEventDefinition.js +0 -132
@@ -1,20 +1,13 @@
1
1
 
2
- import inherits from 'inherits';
3
-
4
2
  import CommandInterceptor from 'diagram-js/lib/command/CommandInterceptor';
5
3
 
6
- import elementHelper from 'bpmn-js-properties-panel/lib/helper/ElementHelper';
4
+ import { createElement } from '../../../helper/ElementHelper';
7
5
 
8
6
  import {
9
7
  getBusinessObject,
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 = 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 ],
@@ -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
@@ -1,70 +1,72 @@
1
- import {
2
- has
3
- } from 'min-dash';
1
+ import { has } from 'min-dash';
4
2
 
5
- import {
6
- getOutputParameters
7
- } from './InputOutputHelper';
3
+ import { getOutputParameters } from './InputOutputHelper';
8
4
 
9
- import {
10
- getExtensionElements
11
- } from 'bpmn-js-properties-panel/lib/helper/ExtensionElementsHelper';
12
-
13
- import {
14
- getBusinessObject
15
- } from 'bpmn-js/lib/util/ModelUtil';
5
+ import { getExtensionElements } from './ExtensionElementsHelper';
16
6
 
17
7
  import {
8
+ getBusinessObject,
18
9
  is
19
10
  } from 'bpmn-js/lib/util/ModelUtil';
20
11
 
12
+
21
13
  /**
22
- * Determine default value for propagateAllChildVariables attribute
23
- * @param {Object} element representing a bpmn:CallActivity
24
- *
25
- * @returns {boolean}
26
- */
27
- function determinePropAllChildVariablesDefault(element) {
14
+ * Get default value for zeebe:propagateAllChildVariables.
15
+ *
16
+ * @param {djs.model.Base|ModdleElement} element
17
+ *
18
+ * @returns {boolean}
19
+ */
20
+ function getPropagateAllChildVariablesDefault(element) {
21
+ if (!is(element, 'bpmn:CallActivity')) {
22
+ return;
23
+ }
24
+
28
25
  const outputParameters = getOutputParameters(element);
29
26
 
30
27
  if (outputParameters) {
31
- return (outputParameters.length > 0) ? false : true;
28
+ return !outputParameters.length;
32
29
  }
33
30
  }
34
31
 
35
32
  /**
36
- * Get the 'zeebe:CalledElement' extension element for a given business Object
37
- * @param {Object} bo businessObject
38
- *
39
- * @returns {Object} the calledElement Moddle Object or undefined if zeebe:CalledElement does not exist
40
- */
33
+ * Get zeebe:CalledElement of an element.
34
+ *
35
+ * @param {djs.model.Base|ModdleElement} element
36
+ *
37
+ * @returns {ModdleElement}
38
+ */
41
39
  export function getCalledElement(element) {
42
40
  const calledElements = getCalledElements(element);
43
- return calledElements[0];
41
+
42
+ return calledElements[ 0 ];
44
43
  }
45
44
 
46
45
  export function getCalledElements(element) {
47
- const bo = getBusinessObject(element);
48
- const extElements = getExtensionElements(bo, 'zeebe:CalledElement');
49
- return extElements;
46
+ const businessObject = getBusinessObject(element);
47
+
48
+ return getExtensionElements(businessObject, 'zeebe:CalledElement');
50
49
  }
51
50
 
52
51
  /**
53
- * Check whether the propagateAllChildVariables attribute is set on an element.
54
- * Note that a default logic will be determine if it is not explicitly set.
55
- * @param {Object} element
56
- *
57
- * @returns {boolean}
58
- */
52
+ * Check whether zeebe:propagateAllChildVariables is set on an element.
53
+ * Fall back to default if zeebe:propagateAllChildVariables not set.
54
+ *
55
+ * @param {djs.model.Base|ModdleElement} element
56
+ *
57
+ * @returns {boolean}
58
+ */
59
59
  export function isPropagateAllChildVariables(element) {
60
60
  if (!is(element, 'bpmn:CallActivity')) {
61
- return undefined;
61
+ return;
62
62
  }
63
63
 
64
- const bo = getBusinessObject(element),
65
- calledElement = getCalledElement(bo);
64
+ const businessObject = getBusinessObject(element),
65
+ calledElement = getCalledElement(businessObject);
66
66
 
67
- return calledElement && has(calledElement, 'propagateAllChildVariables') ?
68
- calledElement.get('propagateAllChildVariables') :
69
- determinePropAllChildVariablesDefault(element);
67
+ if (calledElement && has(calledElement, 'propagateAllChildVariables')) {
68
+ return calledElement.get('propagateAllChildVariables');
69
+ } else {
70
+ return getPropagateAllChildVariablesDefault(element);
71
+ }
70
72
  }
@@ -0,0 +1,18 @@
1
+ /**
2
+ * Creates a new element and set the parent to it
3
+ *
4
+ * @method ElementHelper#createElement
5
+ *
6
+ * @param {String} elementType of the new element
7
+ * @param {Object} properties of the new element in key-value pairs
8
+ * @param {moddle.object} parent of the new element
9
+ * @param {BpmnFactory} factory which creates the new element
10
+ *
11
+ * @returns {djs.model.Base} element which is created
12
+ */
13
+ export function createElement(elementType, properties, parent, factory) {
14
+ var element = factory.create(elementType, properties);
15
+ element.$parent = parent;
16
+
17
+ return element;
18
+ }
@@ -0,0 +1,17 @@
1
+ import { is } from 'bpmn-js/lib/util/ModelUtil';
2
+
3
+ export function getExtensionElements(bo, type) {
4
+ let elements = [];
5
+ const extensionElements = bo.get('extensionElements');
6
+
7
+ if (typeof extensionElements !== 'undefined') {
8
+ const extensionValues = extensionElements.get('values');
9
+ if (typeof extensionValues !== 'undefined') {
10
+ elements = extensionValues.filter(function(value) {
11
+ return is(value, type);
12
+ });
13
+ }
14
+ }
15
+
16
+ return elements;
17
+ }