camunda-bpmn-js 0.11.3 → 0.12.1

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 +25 -0
  2. package/dist/assets/properties-panel.css +780 -0
  3. package/dist/base-modeler.development.js +383 -104
  4. package/dist/base-modeler.production.min.js +3 -3
  5. package/dist/camunda-cloud-modeler.development.js +952 -609
  6. package/dist/camunda-cloud-modeler.production.min.js +3 -3
  7. package/dist/camunda-platform-modeler.development.js +561 -374
  8. package/dist/camunda-platform-modeler.production.min.js +3 -3
  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 +3 -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 +6 -6
@@ -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,4 @@
1
+ import CleanUpBusinessRuleTaskBehavior from './CleanUpBusinessRuleTaskBehavior';
1
2
  import CreateZeebeBoundaryEventBehavior from './CreateZeebeBoundaryEventBehavior';
2
3
  import CreateZeebeCallActivityBehavior from './CreateZeebeCallActivityBehavior';
3
4
  import UpdatePropagateAllChildVariablesBehavior from './UpdatePropagateAllChildVariablesBehavior';
@@ -6,11 +7,13 @@ import FormDefinitionBehavior from './FormDefinitionBehavior';
6
7
 
7
8
  export default {
8
9
  __init__: [
10
+ 'cleanUpBusinessRuleTaskBehavior',
9
11
  'createZeebeBoundaryEventBehavior',
10
12
  'createZeebeCallActivityBehavior',
11
13
  'updatePropagateAllChildVariablesBehavior',
12
14
  'formDefinitionBehavior'
13
15
  ],
16
+ cleanUpBusinessRuleTaskBehavior: [ 'type', CleanUpBusinessRuleTaskBehavior ],
14
17
  createZeebeBoundaryEventBehavior: [ 'type', CreateZeebeBoundaryEventBehavior ],
15
18
  createZeebeCallActivityBehavior: [ 'type', CreateZeebeCallActivityBehavior ],
16
19
  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
@@ -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 'bpmn-js-properties-panel/lib/helper/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
  }
@@ -1,6 +1,4 @@
1
- import {
2
- getExtensionElements
3
- } from 'bpmn-js-properties-panel/lib/helper/ExtensionElementsHelper';
1
+ import { getExtensionElements } from 'bpmn-js-properties-panel/lib/helper/ExtensionElementsHelper';
4
2
 
5
3
  import elementHelper from 'bpmn-js-properties-panel/lib/helper/ElementHelper';
6
4
 
@@ -9,47 +7,12 @@ import {
9
7
  is
10
8
  } from 'bpmn-js/lib/util/ModelUtil';
11
9
 
12
- import {
13
- nextId
14
- } from 'bpmn-js-properties-panel/lib/Utils';
15
-
16
- import {
17
- find
18
- } from 'min-dash';
19
-
20
- const USER_TASK_FORM_PREFIX = 'userTaskForm_';
21
-
22
-
23
- export function getUserTaskForm(element, parent) {
10
+ import { nextId } from 'bpmn-js-properties-panel/lib/Utils';
24
11
 
25
- const rootElement = parent || getRootElement(element);
26
-
27
- // (1) get form definition from user task
28
- const formDefinition = getFormDefinition(element);
29
-
30
- if (!formDefinition) {
31
- return;
32
- }
12
+ import { find } from 'min-dash';
33
13
 
34
- const formKey = formDefinition.get('formKey');
14
+ const USER_TASK_FORM_PREFIX = 'UserTaskForm_';
35
15
 
36
- // (2) retrieve user task form via form key
37
- const userTaskForm = findUserTaskForm(formKey, rootElement);
38
-
39
- return userTaskForm;
40
- }
41
-
42
- export function getFormDefinition(element) {
43
- const businessObject = getBusinessObject(element);
44
-
45
- const formDefinitions = getExtensionElements(businessObject, 'zeebe:FormDefinition');
46
-
47
- return formDefinitions[0];
48
- }
49
-
50
- export function createFormKey(formId) {
51
- return 'camunda-forms:bpmn:' + formId;
52
- }
53
16
 
54
17
  export function createFormDefinition(properties, extensionElements, bpmnFactory) {
55
18
  return elementHelper.createElement(
@@ -60,6 +23,14 @@ export function createFormDefinition(properties, extensionElements, bpmnFactory)
60
23
  );
61
24
  }
62
25
 
26
+ export function createFormId() {
27
+ return nextId(USER_TASK_FORM_PREFIX);
28
+ }
29
+
30
+ export function createFormKey(formId) {
31
+ return `camunda-forms:bpmn:${ formId }`;
32
+ }
33
+
63
34
  export function createUserTaskForm(properties, extensionElements, bpmnFactory) {
64
35
  return elementHelper.createElement(
65
36
  'zeebe:UserTaskForm',
@@ -69,19 +40,22 @@ export function createUserTaskForm(properties, extensionElements, bpmnFactory) {
69
40
  );
70
41
  }
71
42
 
72
- export function createFormId() {
73
- return nextId(USER_TASK_FORM_PREFIX);
74
- }
43
+ function findUserTaskForm(formKey, rootElement) {
44
+ const userTaskForms = getExtensionElements(rootElement, 'zeebe:UserTaskForm');
75
45
 
46
+ return find(userTaskForms, function(userTaskForm) {
47
+ const id = userTaskForm.get('zeebe:id');
76
48
 
77
- // helpers /////////////////////
49
+ return createFormKey(id) === formKey;
50
+ });
51
+ }
78
52
 
79
- function findUserTaskForm(formKey, rootElement) {
80
- const forms = getExtensionElements(rootElement, 'zeebe:UserTaskForm');
53
+ export function getFormDefinition(element) {
54
+ const businessObject = getBusinessObject(element);
81
55
 
82
- return find(forms, function(userTaskForm) {
83
- return createFormKey(userTaskForm.id) === formKey;
84
- });
56
+ const formDefinitions = getExtensionElements(businessObject, 'zeebe:FormDefinition');
57
+
58
+ return formDefinitions[ 0 ];
85
59
  }
86
60
 
87
61
  function getRootElement(element) {
@@ -93,4 +67,18 @@ function getRootElement(element) {
93
67
  }
94
68
 
95
69
  return parent;
70
+ }
71
+
72
+ export function getUserTaskForm(element, parent) {
73
+ const rootElement = parent || getRootElement(element);
74
+
75
+ const formDefinition = getFormDefinition(element);
76
+
77
+ if (!formDefinition) {
78
+ return;
79
+ }
80
+
81
+ const formKey = formDefinition.get('zeebe:formKey');
82
+
83
+ return findUserTaskForm(formKey, rootElement);
96
84
  }