camunda-bpmn-js 5.1.0 → 5.2.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.
- package/dist/assets/diagram-js.css +1 -1
- package/dist/base-modeler.development.js +10 -3
- package/dist/base-modeler.production.min.js +2 -2
- package/dist/base-navigated-viewer.development.js +9 -2
- package/dist/base-navigated-viewer.production.min.js +1 -1
- package/dist/base-viewer.development.js +1 -1
- package/dist/base-viewer.production.min.js +1 -1
- package/dist/camunda-cloud-modeler.development.js +1433 -1409
- package/dist/camunda-cloud-modeler.production.min.js +2 -2
- package/dist/camunda-cloud-navigated-viewer.development.js +9 -2
- package/dist/camunda-cloud-navigated-viewer.production.min.js +1 -1
- package/dist/camunda-cloud-viewer.development.js +1 -1
- package/dist/camunda-cloud-viewer.production.min.js +1 -1
- package/dist/camunda-platform-modeler.development.js +1011 -1004
- package/dist/camunda-platform-modeler.production.min.js +2 -2
- package/dist/camunda-platform-navigated-viewer.development.js +9 -2
- package/dist/camunda-platform-navigated-viewer.production.min.js +1 -1
- package/dist/camunda-platform-viewer.development.js +1 -1
- package/dist/camunda-platform-viewer.production.min.js +1 -1
- package/package.json +5 -5
|
@@ -2755,7 +2755,7 @@
|
|
|
2755
2755
|
* @return {string}
|
|
2756
2756
|
*/
|
|
2757
2757
|
function componentsToPath(elements) {
|
|
2758
|
-
return elements.flat().join(',').replace(/,?([A-z]),?/g, '$1');
|
|
2758
|
+
return elements.flat().join(',').replace(/,?([A-Za-z]),?/g, '$1');
|
|
2759
2759
|
}
|
|
2760
2760
|
|
|
2761
2761
|
/**
|
|
@@ -25387,7 +25387,7 @@
|
|
|
25387
25387
|
* `keyboard.bind=true|false` configuration option.
|
|
25388
25388
|
*
|
|
25389
25389
|
* @param {Object} config
|
|
25390
|
-
* @param {
|
|
25390
|
+
* @param {boolean} [config.bind]
|
|
25391
25391
|
* @param {EventBus} eventBus
|
|
25392
25392
|
*/
|
|
25393
25393
|
function Keyboard(config, eventBus) {
|
|
@@ -25463,10 +25463,17 @@
|
|
|
25463
25463
|
/**
|
|
25464
25464
|
* Bind keyboard events to the given DOM node.
|
|
25465
25465
|
*
|
|
25466
|
+
* @overlord
|
|
25467
|
+
* @deprecated No longer in use since version 15.0.0.
|
|
25468
|
+
*
|
|
25466
25469
|
* @param {EventTarget} node
|
|
25467
25470
|
*/
|
|
25471
|
+
/**
|
|
25472
|
+
* Bind keyboard events to the canvas node.
|
|
25473
|
+
*/
|
|
25468
25474
|
Keyboard.prototype.bind = function(node) {
|
|
25469
25475
|
|
|
25476
|
+
// legacy <node> argument provided
|
|
25470
25477
|
if (node) {
|
|
25471
25478
|
console.error('unsupported argument <node>', new Error(compatMessage));
|
|
25472
25479
|
}
|
|
@@ -114579,7 +114586,7 @@
|
|
|
114579
114586
|
this._tooltipConfig = tooltipConfig;
|
|
114580
114587
|
this._feelPopupContainer = feelPopupContainer;
|
|
114581
114588
|
this._getFeelPopupLinks = getFeelPopupLinks;
|
|
114582
|
-
this._container = domify$1('<div style="height: 100%" class="bio-properties-panel-container"></div>');
|
|
114589
|
+
this._container = domify$1('<div style="height: 100%" tabindex="-1" class="bio-properties-panel-container"></div>');
|
|
114583
114590
|
var commandStack = injector.get('commandStack', false);
|
|
114584
114591
|
commandStack && setupKeyboard(this._container, eventBus, commandStack);
|
|
114585
114592
|
eventBus.on('diagram.init', () => {
|
|
@@ -122987,1450 +122994,1467 @@
|
|
|
122987
122994
|
Modeler$1.prototype._extensionModules
|
|
122988
122995
|
);
|
|
122989
122996
|
|
|
122990
|
-
/**
|
|
122991
|
-
* Get extension elements of business object. Optionally filter by type.
|
|
122992
|
-
*
|
|
122993
|
-
* @param {djs.model.Base|ModdleElement} element
|
|
122994
|
-
* @param {String} [type=undefined]
|
|
122995
|
-
* @returns {Array<ModdleElement>}
|
|
122996
|
-
*/
|
|
122997
|
-
function getExtensionElementsList$1(element, type = undefined) {
|
|
122998
|
-
const businessObject = getBusinessObject$2(element),
|
|
122999
|
-
extensionElements = businessObject.get('extensionElements');
|
|
123000
|
-
|
|
123001
|
-
if (!extensionElements) {
|
|
123002
|
-
return [];
|
|
123003
|
-
}
|
|
123004
|
-
|
|
123005
|
-
const values = extensionElements.get('values');
|
|
123006
|
-
|
|
123007
|
-
if (!values || !values.length) {
|
|
123008
|
-
return [];
|
|
123009
|
-
}
|
|
123010
|
-
|
|
123011
|
-
if (type) {
|
|
123012
|
-
return values.filter(value => is$5(value, type));
|
|
123013
|
-
}
|
|
123014
|
-
|
|
123015
|
-
return values;
|
|
122997
|
+
/**
|
|
122998
|
+
* Get extension elements of business object. Optionally filter by type.
|
|
122999
|
+
*
|
|
123000
|
+
* @param {djs.model.Base|ModdleElement} element
|
|
123001
|
+
* @param {String} [type=undefined]
|
|
123002
|
+
* @returns {Array<ModdleElement>}
|
|
123003
|
+
*/
|
|
123004
|
+
function getExtensionElementsList$1(element, type = undefined) {
|
|
123005
|
+
const businessObject = getBusinessObject$2(element),
|
|
123006
|
+
extensionElements = businessObject.get('extensionElements');
|
|
123007
|
+
|
|
123008
|
+
if (!extensionElements) {
|
|
123009
|
+
return [];
|
|
123010
|
+
}
|
|
123011
|
+
|
|
123012
|
+
const values = extensionElements.get('values');
|
|
123013
|
+
|
|
123014
|
+
if (!values || !values.length) {
|
|
123015
|
+
return [];
|
|
123016
|
+
}
|
|
123017
|
+
|
|
123018
|
+
if (type) {
|
|
123019
|
+
return values.filter(value => is$5(value, type));
|
|
123020
|
+
}
|
|
123021
|
+
|
|
123022
|
+
return values;
|
|
123023
|
+
}
|
|
123024
|
+
|
|
123025
|
+
/**
|
|
123026
|
+
* Remove one or more extension elements. Remove bpmn:ExtensionElements afterwards if it's empty.
|
|
123027
|
+
*
|
|
123028
|
+
* @param {ModdleElement} element
|
|
123029
|
+
* @param {ModdleElement} businessObject
|
|
123030
|
+
* @param {ModdleElement|Array<ModdleElement>} extensionElementsToRemove
|
|
123031
|
+
* @param {CommandStack} commandStack
|
|
123032
|
+
*/
|
|
123033
|
+
function removeExtensionElements(element, businessObject, extensionElementsToRemove, commandStack) {
|
|
123034
|
+
if (!isArray$5(extensionElementsToRemove)) {
|
|
123035
|
+
extensionElementsToRemove = [ extensionElementsToRemove ];
|
|
123036
|
+
}
|
|
123037
|
+
|
|
123038
|
+
const extensionElements = businessObject.get('extensionElements'),
|
|
123039
|
+
values = extensionElements.get('values').filter(value => !extensionElementsToRemove.includes(value));
|
|
123040
|
+
|
|
123041
|
+
commandStack.execute('element.updateModdleProperties', {
|
|
123042
|
+
element,
|
|
123043
|
+
moddleElement: extensionElements,
|
|
123044
|
+
properties: {
|
|
123045
|
+
values
|
|
123046
|
+
}
|
|
123047
|
+
});
|
|
123016
123048
|
}
|
|
123017
123049
|
|
|
123018
|
-
|
|
123019
|
-
|
|
123020
|
-
|
|
123021
|
-
|
|
123022
|
-
*
|
|
123023
|
-
*
|
|
123024
|
-
*
|
|
123025
|
-
|
|
123026
|
-
|
|
123027
|
-
|
|
123028
|
-
|
|
123029
|
-
|
|
123030
|
-
|
|
123031
|
-
|
|
123032
|
-
|
|
123033
|
-
|
|
123034
|
-
|
|
123035
|
-
|
|
123036
|
-
|
|
123037
|
-
|
|
123038
|
-
|
|
123039
|
-
|
|
123040
|
-
|
|
123050
|
+
const HIGH_PRIORITY$5 = 5000;
|
|
123051
|
+
|
|
123052
|
+
|
|
123053
|
+
/**
|
|
123054
|
+
* Zeebe BPMN behavior ensuring that bpmn:BusinessRuleTask only has one of the following:
|
|
123055
|
+
*
|
|
123056
|
+
* (1) zeebe:CalledDecision
|
|
123057
|
+
* (2) zeebe:TaskDefinition and zeebe:TaskHeaders
|
|
123058
|
+
*/
|
|
123059
|
+
class CleanUpBusinessRuleTaskBehavior extends CommandInterceptor$1 {
|
|
123060
|
+
constructor(commandStack, eventBus) {
|
|
123061
|
+
super(eventBus);
|
|
123062
|
+
|
|
123063
|
+
/**
|
|
123064
|
+
* Remove zeebe:CalledDecision if zeebe:TaskDefinition is about to be added.
|
|
123065
|
+
*/
|
|
123066
|
+
this.preExecute('element.updateModdleProperties' , HIGH_PRIORITY$5, function(context) {
|
|
123067
|
+
const {
|
|
123068
|
+
element,
|
|
123069
|
+
moddleElement,
|
|
123070
|
+
properties
|
|
123071
|
+
} = context;
|
|
123072
|
+
|
|
123073
|
+
if (
|
|
123074
|
+
!is$5(element, 'bpmn:BusinessRuleTask')
|
|
123075
|
+
|| !is$5(moddleElement, 'bpmn:ExtensionElements')
|
|
123076
|
+
|| !properties.values
|
|
123077
|
+
) {
|
|
123078
|
+
return;
|
|
123079
|
+
}
|
|
123080
|
+
|
|
123081
|
+
const calledDecision = getCalledDecision(element),
|
|
123082
|
+
taskDefinition = getTaskDefinition(element);
|
|
123083
|
+
|
|
123084
|
+
if (
|
|
123085
|
+
calledDecision
|
|
123086
|
+
&& !taskDefinition
|
|
123087
|
+
&& properties.values.find(value => is$5(value, 'zeebe:CalledDecision'))
|
|
123088
|
+
&& properties.values.find(value => is$5(value, 'zeebe:TaskDefinition'))
|
|
123089
|
+
) {
|
|
123090
|
+
properties.values = without(properties.values, calledDecision);
|
|
123091
|
+
}
|
|
123092
|
+
}, true);
|
|
123093
|
+
|
|
123094
|
+
/**
|
|
123095
|
+
* Remove zeebe:TaskDefinition and zeebe:TaskHeaders if zeebe:CalledDecision is about to be added.
|
|
123096
|
+
*/
|
|
123097
|
+
this.preExecute('element.updateModdleProperties', HIGH_PRIORITY$5, function(context) {
|
|
123098
|
+
const {
|
|
123099
|
+
element,
|
|
123100
|
+
moddleElement,
|
|
123101
|
+
properties
|
|
123102
|
+
} = context;
|
|
123103
|
+
|
|
123104
|
+
if (
|
|
123105
|
+
!is$5(element, 'bpmn:BusinessRuleTask')
|
|
123106
|
+
|| !is$5(moddleElement, 'bpmn:ExtensionElements')
|
|
123107
|
+
|| !properties.values
|
|
123108
|
+
) {
|
|
123109
|
+
return;
|
|
123110
|
+
}
|
|
123111
|
+
|
|
123112
|
+
const calledDecision = getCalledDecision(element),
|
|
123113
|
+
taskDefinition = getTaskDefinition(element),
|
|
123114
|
+
taskHeaders = getTaskHeaders(element);
|
|
123115
|
+
|
|
123116
|
+
if (
|
|
123117
|
+
!calledDecision
|
|
123118
|
+
&& (taskDefinition || taskHeaders)
|
|
123119
|
+
&& properties.values.find(value => is$5(value, 'zeebe:CalledDecision'))
|
|
123120
|
+
&& properties.values.find(value => is$5(value, 'zeebe:TaskDefinition') || is$5(value, 'zeebe:TaskHeaders'))
|
|
123121
|
+
) {
|
|
123122
|
+
properties.values = without(properties.values, (value) => value === taskDefinition || value === taskHeaders);
|
|
123123
|
+
}
|
|
123124
|
+
}, true);
|
|
123125
|
+
|
|
123126
|
+
}
|
|
123127
|
+
}
|
|
123128
|
+
|
|
123129
|
+
CleanUpBusinessRuleTaskBehavior.$inject = [
|
|
123130
|
+
'commandStack',
|
|
123131
|
+
'eventBus'
|
|
123132
|
+
];
|
|
123133
|
+
|
|
123134
|
+
|
|
123135
|
+
// helpers //////////
|
|
123136
|
+
|
|
123137
|
+
function getCalledDecision(element) {
|
|
123138
|
+
const businessObject = getBusinessObject$2(element);
|
|
123139
|
+
|
|
123140
|
+
return getExtensionElementsList$1(businessObject, 'zeebe:CalledDecision')[ 0 ];
|
|
123141
|
+
}
|
|
123142
|
+
|
|
123143
|
+
function getTaskDefinition(element) {
|
|
123144
|
+
const businessObject = getBusinessObject$2(element);
|
|
123145
|
+
|
|
123146
|
+
return getExtensionElementsList$1(businessObject, 'zeebe:TaskDefinition')[ 0 ];
|
|
123147
|
+
}
|
|
123148
|
+
|
|
123149
|
+
function getTaskHeaders(element) {
|
|
123150
|
+
const businessObject = getBusinessObject$2(element);
|
|
123151
|
+
|
|
123152
|
+
return getExtensionElementsList$1(businessObject, 'zeebe:TaskHeaders')[ 0 ];
|
|
123041
123153
|
}
|
|
123042
123154
|
|
|
123043
|
-
|
|
123044
|
-
|
|
123045
|
-
|
|
123046
|
-
|
|
123047
|
-
|
|
123048
|
-
|
|
123049
|
-
|
|
123050
|
-
|
|
123051
|
-
|
|
123052
|
-
|
|
123053
|
-
|
|
123054
|
-
|
|
123055
|
-
|
|
123056
|
-
|
|
123057
|
-
|
|
123058
|
-
|
|
123059
|
-
|
|
123060
|
-
|
|
123061
|
-
|
|
123062
|
-
|
|
123063
|
-
|
|
123064
|
-
|
|
123065
|
-
|
|
123066
|
-
|
|
123067
|
-
|
|
123068
|
-
|
|
123069
|
-
|
|
123070
|
-
|
|
123071
|
-
|
|
123072
|
-
|
|
123073
|
-
|
|
123074
|
-
|
|
123075
|
-
|
|
123076
|
-
|
|
123077
|
-
|
|
123078
|
-
|
|
123079
|
-
|
|
123080
|
-
|
|
123081
|
-
|
|
123082
|
-
|
|
123083
|
-
|
|
123084
|
-
|
|
123085
|
-
|
|
123086
|
-
|
|
123087
|
-
|
|
123088
|
-
|
|
123089
|
-
|
|
123090
|
-
|
|
123091
|
-
|
|
123092
|
-
|
|
123093
|
-
|
|
123094
|
-
|
|
123095
|
-
|
|
123096
|
-
|
|
123097
|
-
|
|
123098
|
-
|
|
123099
|
-
|
|
123100
|
-
|
|
123101
|
-
|
|
123102
|
-
|
|
123103
|
-
|
|
123104
|
-
|
|
123105
|
-
|
|
123106
|
-
|
|
123107
|
-
|
|
123108
|
-
|
|
123109
|
-
if (
|
|
123110
|
-
!calledDecision
|
|
123111
|
-
&& (taskDefinition || taskHeaders)
|
|
123112
|
-
&& properties.values.find(value => is$5(value, 'zeebe:CalledDecision'))
|
|
123113
|
-
&& properties.values.find(value => is$5(value, 'zeebe:TaskDefinition') || is$5(value, 'zeebe:TaskHeaders'))
|
|
123114
|
-
) {
|
|
123115
|
-
properties.values = without(properties.values, (value) => value === taskDefinition || value === taskHeaders);
|
|
123116
|
-
}
|
|
123117
|
-
}, true);
|
|
123118
|
-
|
|
123119
|
-
}
|
|
123155
|
+
class CleanUpEndEventBehavior extends CommandInterceptor$1 {
|
|
123156
|
+
constructor(eventBus, modeling) {
|
|
123157
|
+
super(eventBus);
|
|
123158
|
+
|
|
123159
|
+
this.postExecuted('shape.replace', function(event) {
|
|
123160
|
+
|
|
123161
|
+
const {
|
|
123162
|
+
context
|
|
123163
|
+
} = event;
|
|
123164
|
+
|
|
123165
|
+
const {
|
|
123166
|
+
newShape
|
|
123167
|
+
} = context;
|
|
123168
|
+
|
|
123169
|
+
if (!is$5(newShape, 'bpmn:EndEvent') || !getErrorEventDefinition(newShape)) {
|
|
123170
|
+
return;
|
|
123171
|
+
}
|
|
123172
|
+
|
|
123173
|
+
const ioMapping = getIoMapping(newShape);
|
|
123174
|
+
|
|
123175
|
+
if (!ioMapping) {
|
|
123176
|
+
return;
|
|
123177
|
+
}
|
|
123178
|
+
|
|
123179
|
+
const businessObject = getBusinessObject$2(newShape),
|
|
123180
|
+
extensionElements = businessObject.get('extensionElements'),
|
|
123181
|
+
values = without(extensionElements.get('values'), ioMapping);
|
|
123182
|
+
|
|
123183
|
+
modeling.updateModdleProperties(newShape, extensionElements, { values });
|
|
123184
|
+
});
|
|
123185
|
+
}
|
|
123186
|
+
}
|
|
123187
|
+
|
|
123188
|
+
CleanUpEndEventBehavior.$inject = [
|
|
123189
|
+
'eventBus',
|
|
123190
|
+
'modeling'
|
|
123191
|
+
];
|
|
123192
|
+
|
|
123193
|
+
// helpers //////////
|
|
123194
|
+
|
|
123195
|
+
function getErrorEventDefinition(element) {
|
|
123196
|
+
const businessObject = getBusinessObject$2(element);
|
|
123197
|
+
|
|
123198
|
+
const eventDefinitions = businessObject.get('eventDefinitions') || [];
|
|
123199
|
+
|
|
123200
|
+
return find$2(eventDefinitions, function(definition) {
|
|
123201
|
+
return is$5(definition, 'bpmn:ErrorEventDefinition');
|
|
123202
|
+
});
|
|
123203
|
+
}
|
|
123204
|
+
|
|
123205
|
+
function getIoMapping(element) {
|
|
123206
|
+
const bo = getBusinessObject$2(element);
|
|
123207
|
+
|
|
123208
|
+
const extensionElements = bo.get('extensionElements');
|
|
123209
|
+
|
|
123210
|
+
if (!extensionElements) {
|
|
123211
|
+
return null;
|
|
123212
|
+
}
|
|
123213
|
+
|
|
123214
|
+
const values = extensionElements.get('values');
|
|
123215
|
+
|
|
123216
|
+
if (!values) {
|
|
123217
|
+
return null;
|
|
123218
|
+
}
|
|
123219
|
+
|
|
123220
|
+
return find$2(values, value => is$5(value, 'zeebe:IoMapping'));
|
|
123120
123221
|
}
|
|
123121
123222
|
|
|
123122
|
-
|
|
123123
|
-
'
|
|
123124
|
-
'
|
|
123125
|
-
];
|
|
123126
|
-
|
|
123127
|
-
|
|
123128
|
-
|
|
123129
|
-
|
|
123130
|
-
|
|
123131
|
-
|
|
123132
|
-
|
|
123133
|
-
|
|
123223
|
+
const DISALLOWED_START_LISTENER_TYPES = [
|
|
123224
|
+
'bpmn:StartEvent',
|
|
123225
|
+
'bpmn:BoundaryEvent'
|
|
123226
|
+
];
|
|
123227
|
+
|
|
123228
|
+
class CleanUpExecutionListenersBehavior extends CommandInterceptor$1 {
|
|
123229
|
+
constructor(eventBus, modeling) {
|
|
123230
|
+
super(eventBus);
|
|
123231
|
+
|
|
123232
|
+
// remove execution listeners of disallowed type
|
|
123233
|
+
this.postExecuted('shape.replace', function(event) {
|
|
123234
|
+
const element = event.context.newShape;
|
|
123235
|
+
|
|
123236
|
+
const executionListenersContainer = getExecutionListenersContainer(element);
|
|
123237
|
+
if (!executionListenersContainer) {
|
|
123238
|
+
return;
|
|
123239
|
+
}
|
|
123240
|
+
|
|
123241
|
+
const listeners = executionListenersContainer.get('listeners');
|
|
123242
|
+
const newListeners = withoutDisallowedListeners$1(element, listeners);
|
|
123243
|
+
|
|
123244
|
+
if (newListeners.length !== listeners.length) {
|
|
123245
|
+
modeling.updateModdleProperties(element, executionListenersContainer, { listeners: newListeners });
|
|
123246
|
+
}
|
|
123247
|
+
});
|
|
123248
|
+
|
|
123249
|
+
// remove empty execution listener container
|
|
123250
|
+
this.postExecuted('element.updateModdleProperties', function(event) {
|
|
123251
|
+
const {
|
|
123252
|
+
element,
|
|
123253
|
+
moddleElement
|
|
123254
|
+
} = event.context;
|
|
123255
|
+
|
|
123256
|
+
if (!is$5(moddleElement, 'zeebe:ExecutionListeners')) {
|
|
123257
|
+
return;
|
|
123258
|
+
}
|
|
123259
|
+
|
|
123260
|
+
const listeners = moddleElement.get('listeners');
|
|
123261
|
+
if (listeners.length) {
|
|
123262
|
+
return;
|
|
123263
|
+
}
|
|
123264
|
+
|
|
123265
|
+
const extensionElements = moddleElement.$parent;
|
|
123266
|
+
modeling.updateModdleProperties(element, extensionElements, { values: without(extensionElements.get('values'), moddleElement) });
|
|
123267
|
+
});
|
|
123268
|
+
}
|
|
123269
|
+
}
|
|
123270
|
+
|
|
123271
|
+
CleanUpExecutionListenersBehavior.$inject = [
|
|
123272
|
+
'eventBus',
|
|
123273
|
+
'modeling'
|
|
123274
|
+
];
|
|
123275
|
+
|
|
123276
|
+
// helpers //////////
|
|
123277
|
+
function withoutDisallowedListeners$1(element, listeners) {
|
|
123278
|
+
listeners = withoutDisallowedStartListeners(element, listeners);
|
|
123279
|
+
listeners = withoutDisallowedEndListeners(element, listeners);
|
|
123280
|
+
|
|
123281
|
+
return listeners;
|
|
123282
|
+
}
|
|
123283
|
+
|
|
123284
|
+
function withoutDisallowedStartListeners(element, listeners) {
|
|
123285
|
+
if (isAny$1(element, DISALLOWED_START_LISTENER_TYPES)) {
|
|
123286
|
+
return listeners.filter(listener => listener.eventType !== 'start');
|
|
123287
|
+
}
|
|
123288
|
+
|
|
123289
|
+
return listeners;
|
|
123290
|
+
}
|
|
123291
|
+
|
|
123292
|
+
function withoutDisallowedEndListeners(element, listeners) {
|
|
123293
|
+
if (shouldRemoveEndListeners(element)) {
|
|
123294
|
+
return listeners.filter(listener => listener.eventType !== 'end');
|
|
123295
|
+
}
|
|
123296
|
+
|
|
123297
|
+
return listeners;
|
|
123298
|
+
}
|
|
123299
|
+
|
|
123300
|
+
function shouldRemoveEndListeners(element) {
|
|
123301
|
+
if (
|
|
123302
|
+
is$5(element, 'bpmn:BoundaryEvent') && isCompensationEvent(element) ||
|
|
123303
|
+
is$5(element, 'bpmn:EndEvent') && isErrorEvent(element) ||
|
|
123304
|
+
is$5(element, 'bpmn:Gateway')
|
|
123305
|
+
) {
|
|
123306
|
+
return true;
|
|
123307
|
+
}
|
|
123308
|
+
}
|
|
123309
|
+
|
|
123310
|
+
function isCompensationEvent(element) {
|
|
123311
|
+
const eventDefinitions = getEventDefinitions(element);
|
|
123312
|
+
|
|
123313
|
+
return find$2(eventDefinitions, function(definition) {
|
|
123314
|
+
return is$5(definition, 'bpmn:CompensateEventDefinition');
|
|
123315
|
+
});
|
|
123316
|
+
}
|
|
123317
|
+
|
|
123318
|
+
function isErrorEvent(element) {
|
|
123319
|
+
const eventDefinitions = getEventDefinitions(element);
|
|
123320
|
+
|
|
123321
|
+
return find$2(eventDefinitions, function(definition) {
|
|
123322
|
+
return is$5(definition, 'bpmn:ErrorEventDefinition');
|
|
123323
|
+
});
|
|
123324
|
+
}
|
|
123325
|
+
|
|
123326
|
+
function getEventDefinitions(element) {
|
|
123327
|
+
const businessObject = getBusinessObject$2(element);
|
|
123328
|
+
return businessObject.get('eventDefinitions') || [];
|
|
123329
|
+
}
|
|
123330
|
+
|
|
123331
|
+
function getExecutionListenersContainer(element) {
|
|
123332
|
+
return getExtensionElementsList$1(element, 'zeebe:ExecutionListeners')[0];
|
|
123134
123333
|
}
|
|
123135
123334
|
|
|
123136
|
-
|
|
123137
|
-
|
|
123138
|
-
|
|
123139
|
-
|
|
123335
|
+
const ALLOWED_EVENT_TYPES = [ 'complete', 'assignment' ];
|
|
123336
|
+
|
|
123337
|
+
class CleanUpTaskListenersBehavior extends CommandInterceptor$1 {
|
|
123338
|
+
constructor(eventBus, modeling) {
|
|
123339
|
+
super(eventBus);
|
|
123340
|
+
|
|
123341
|
+
// remove task listeners of disallowed type on shape replace
|
|
123342
|
+
this.postExecuted('shape.replace', function(event) {
|
|
123343
|
+
const element = event.context.newShape;
|
|
123344
|
+
|
|
123345
|
+
updateListeners(element, modeling);
|
|
123346
|
+
});
|
|
123347
|
+
|
|
123348
|
+
// remove task listeners of disallowed type on user task properties update
|
|
123349
|
+
this.postExecuted('element.updateModdleProperties', function(event) {
|
|
123350
|
+
const element = event.context.element;
|
|
123351
|
+
|
|
123352
|
+
if (!is$5(element, 'bpmn:UserTask')) {
|
|
123353
|
+
return;
|
|
123354
|
+
}
|
|
123355
|
+
|
|
123356
|
+
updateListeners(element, modeling);
|
|
123357
|
+
});
|
|
123358
|
+
|
|
123359
|
+
// remove empty task listener container
|
|
123360
|
+
this.postExecuted('element.updateModdleProperties', function(event) {
|
|
123361
|
+
const {
|
|
123362
|
+
element,
|
|
123363
|
+
moddleElement
|
|
123364
|
+
} = event.context;
|
|
123365
|
+
|
|
123366
|
+
if (!is$5(moddleElement, 'zeebe:TaskListeners')) {
|
|
123367
|
+
return;
|
|
123368
|
+
}
|
|
123369
|
+
|
|
123370
|
+
const listeners = moddleElement.get('listeners');
|
|
123371
|
+
if (listeners.length) {
|
|
123372
|
+
return;
|
|
123373
|
+
}
|
|
123374
|
+
|
|
123375
|
+
const extensionElements = moddleElement.$parent;
|
|
123376
|
+
modeling.updateModdleProperties(element, extensionElements, { values: without(extensionElements.get('values'), moddleElement) });
|
|
123377
|
+
});
|
|
123378
|
+
}
|
|
123379
|
+
}
|
|
123380
|
+
|
|
123381
|
+
CleanUpTaskListenersBehavior.$inject = [
|
|
123382
|
+
'eventBus',
|
|
123383
|
+
'modeling'
|
|
123384
|
+
];
|
|
123385
|
+
|
|
123386
|
+
// helpers //////////
|
|
123387
|
+
function updateListeners(element, modeling) {
|
|
123388
|
+
const taskListenersContainer = getTaskListenersContainer(element);
|
|
123389
|
+
if (!taskListenersContainer) {
|
|
123390
|
+
return;
|
|
123391
|
+
}
|
|
123392
|
+
|
|
123393
|
+
const listeners = taskListenersContainer.get('listeners');
|
|
123394
|
+
const newListeners = withoutDisallowedListeners(element, listeners);
|
|
123395
|
+
|
|
123396
|
+
if (newListeners.length !== listeners.length) {
|
|
123397
|
+
modeling.updateModdleProperties(element, taskListenersContainer, { listeners: newListeners });
|
|
123398
|
+
}
|
|
123399
|
+
}
|
|
123400
|
+
|
|
123401
|
+
function withoutDisallowedListeners(element, listeners) {
|
|
123402
|
+
return listeners.filter(listener => {
|
|
123403
|
+
if (
|
|
123404
|
+
!is$5(element, 'bpmn:UserTask') ||
|
|
123405
|
+
!ALLOWED_EVENT_TYPES.includes(listener.eventType) ||
|
|
123406
|
+
!hasZeebeTaskExtensionElement(element)
|
|
123407
|
+
) {
|
|
123408
|
+
return false;
|
|
123409
|
+
}
|
|
123410
|
+
return true;
|
|
123411
|
+
});
|
|
123412
|
+
}
|
|
123413
|
+
|
|
123414
|
+
function getTaskListenersContainer(element) {
|
|
123415
|
+
return getExtensionElementsList$1(element, 'zeebe:TaskListeners')[0];
|
|
123416
|
+
}
|
|
123417
|
+
|
|
123418
|
+
function hasZeebeTaskExtensionElement(element) {
|
|
123419
|
+
return getExtensionElementsList$1(element, 'zeebe:UserTask').length > 0;
|
|
123140
123420
|
}
|
|
123141
123421
|
|
|
123142
|
-
|
|
123143
|
-
|
|
123144
|
-
|
|
123145
|
-
|
|
123422
|
+
/**
|
|
123423
|
+
* Zeebe BPMN behavior ensuring that zeebe:subscription is removed from bpmn:Message
|
|
123424
|
+
* when it has no properties anymore.
|
|
123425
|
+
*/
|
|
123426
|
+
class CleanUpSubscriptionBehavior extends CommandInterceptor$1 {
|
|
123427
|
+
constructor(eventBus, commandStack) {
|
|
123428
|
+
super(eventBus);
|
|
123429
|
+
|
|
123430
|
+
this.postExecuted([
|
|
123431
|
+
'element.updateProperties',
|
|
123432
|
+
'element.updateModdleProperties'
|
|
123433
|
+
], context => {
|
|
123434
|
+
const element = context.shape || context.newShape || context.element;
|
|
123435
|
+
|
|
123436
|
+
if (element.labelTarget) {
|
|
123437
|
+
return;
|
|
123438
|
+
}
|
|
123439
|
+
|
|
123440
|
+
if (!is$5(element, 'bpmn:Event')) {
|
|
123441
|
+
return;
|
|
123442
|
+
}
|
|
123443
|
+
|
|
123444
|
+
const messageEventDefinition = getMessageEventDefinition$1(element);
|
|
123445
|
+
|
|
123446
|
+
if (!messageEventDefinition) {
|
|
123447
|
+
return;
|
|
123448
|
+
}
|
|
123449
|
+
|
|
123450
|
+
const message = messageEventDefinition.get('messageRef');
|
|
123451
|
+
|
|
123452
|
+
if (!message) {
|
|
123453
|
+
return;
|
|
123454
|
+
}
|
|
123455
|
+
|
|
123456
|
+
const subscription = getSubscription(message);
|
|
123457
|
+
|
|
123458
|
+
if (!subscription) {
|
|
123459
|
+
return;
|
|
123460
|
+
}
|
|
123461
|
+
|
|
123462
|
+
if (!hasNoProperties(subscription)) {
|
|
123463
|
+
return;
|
|
123464
|
+
}
|
|
123465
|
+
|
|
123466
|
+
removeExtensionElements(element, message, subscription, commandStack);
|
|
123467
|
+
}, true);
|
|
123468
|
+
}
|
|
123469
|
+
}
|
|
123470
|
+
|
|
123471
|
+
CleanUpSubscriptionBehavior.$inject = [
|
|
123472
|
+
'eventBus',
|
|
123473
|
+
'commandStack'
|
|
123474
|
+
];
|
|
123475
|
+
|
|
123476
|
+
|
|
123477
|
+
// helpers //////////
|
|
123478
|
+
|
|
123479
|
+
function getMessageEventDefinition$1(event) {
|
|
123480
|
+
const businessObject = getBusinessObject$2(event);
|
|
123481
|
+
|
|
123482
|
+
return businessObject.get('eventDefinitions').find(eventDefinition => {
|
|
123483
|
+
return is$5(eventDefinition, 'bpmn:MessageEventDefinition');
|
|
123484
|
+
});
|
|
123485
|
+
}
|
|
123486
|
+
|
|
123487
|
+
function getSubscription(message) {
|
|
123488
|
+
return getExtensionElementsList$1(message, 'zeebe:Subscription')[ 0 ];
|
|
123489
|
+
}
|
|
123490
|
+
|
|
123491
|
+
function hasNoProperties(element) {
|
|
123492
|
+
const descriptor = element.$descriptor;
|
|
123493
|
+
|
|
123494
|
+
return descriptor.properties.every(property => {
|
|
123495
|
+
return element.get(property.name) === undefined;
|
|
123496
|
+
});
|
|
123146
123497
|
}
|
|
123147
123498
|
|
|
123148
|
-
|
|
123149
|
-
|
|
123150
|
-
|
|
123151
|
-
|
|
123152
|
-
|
|
123153
|
-
|
|
123154
|
-
|
|
123155
|
-
|
|
123156
|
-
|
|
123157
|
-
|
|
123158
|
-
|
|
123159
|
-
|
|
123160
|
-
|
|
123161
|
-
|
|
123162
|
-
|
|
123163
|
-
|
|
123164
|
-
|
|
123165
|
-
|
|
123166
|
-
|
|
123167
|
-
|
|
123168
|
-
|
|
123169
|
-
|
|
123170
|
-
|
|
123171
|
-
|
|
123172
|
-
|
|
123173
|
-
|
|
123174
|
-
|
|
123175
|
-
|
|
123176
|
-
|
|
123177
|
-
|
|
123178
|
-
|
|
123499
|
+
function getTimerEventDefinition(element) {
|
|
123500
|
+
const businessObject = getBusinessObject$2(element);
|
|
123501
|
+
|
|
123502
|
+
return businessObject.get('eventDefinitions').find(eventDefinition => {
|
|
123503
|
+
return is$5(eventDefinition, 'bpmn:TimerEventDefinition');
|
|
123504
|
+
});
|
|
123505
|
+
}
|
|
123506
|
+
|
|
123507
|
+
/**
|
|
123508
|
+
* Check whether a given timer expression type is supported for a given element.
|
|
123509
|
+
*
|
|
123510
|
+
* @param {string} type
|
|
123511
|
+
* @param {Element|ModdleElement} element
|
|
123512
|
+
*
|
|
123513
|
+
* @return {boolean}
|
|
123514
|
+
*/
|
|
123515
|
+
function isTimerExpressionTypeSupported(type, element) {
|
|
123516
|
+
const businessObject = getBusinessObject$2(element);
|
|
123517
|
+
|
|
123518
|
+
switch (type) {
|
|
123519
|
+
case 'timeDate':
|
|
123520
|
+
return isAny$1(element, [
|
|
123521
|
+
'bpmn:BoundaryEvent',
|
|
123522
|
+
'bpmn:IntermediateCatchEvent',
|
|
123523
|
+
'bpmn:StartEvent'
|
|
123524
|
+
]);
|
|
123525
|
+
|
|
123526
|
+
case 'timeCycle':
|
|
123527
|
+
if (is$5(element, 'bpmn:StartEvent') && (!hasParentEventSubProcess(businessObject)) || !isInterrupting(businessObject)) {
|
|
123528
|
+
return true;
|
|
123529
|
+
}
|
|
123530
|
+
|
|
123531
|
+
if (is$5(element, 'bpmn:BoundaryEvent') && !isInterrupting(businessObject)) {
|
|
123532
|
+
return true;
|
|
123533
|
+
}
|
|
123534
|
+
|
|
123535
|
+
return false;
|
|
123536
|
+
|
|
123537
|
+
case 'timeDuration':
|
|
123538
|
+
if (isAny$1(element, [
|
|
123539
|
+
'bpmn:BoundaryEvent',
|
|
123540
|
+
'bpmn:IntermediateCatchEvent'
|
|
123541
|
+
])) {
|
|
123542
|
+
return true;
|
|
123543
|
+
}
|
|
123544
|
+
|
|
123545
|
+
if (is$5(element, 'bpmn:StartEvent') && hasParentEventSubProcess(businessObject)) {
|
|
123546
|
+
return true;
|
|
123547
|
+
}
|
|
123548
|
+
|
|
123549
|
+
return false;
|
|
123550
|
+
|
|
123551
|
+
default:
|
|
123552
|
+
return false;
|
|
123553
|
+
}
|
|
123554
|
+
}
|
|
123555
|
+
|
|
123556
|
+
function isInterrupting(businessObject) {
|
|
123557
|
+
if (is$5(businessObject, 'bpmn:BoundaryEvent')) {
|
|
123558
|
+
return businessObject.get('cancelActivity') !== false;
|
|
123559
|
+
}
|
|
123560
|
+
|
|
123561
|
+
return businessObject.get('isInterrupting') !== false;
|
|
123562
|
+
}
|
|
123563
|
+
|
|
123564
|
+
function hasParentEventSubProcess(businessObject) {
|
|
123565
|
+
const parent = businessObject.$parent;
|
|
123566
|
+
|
|
123567
|
+
return parent && is$5(parent, 'bpmn:SubProcess') && parent.get('triggeredByEvent');
|
|
123179
123568
|
}
|
|
123180
123569
|
|
|
123181
|
-
|
|
123182
|
-
|
|
123183
|
-
|
|
123570
|
+
/**
|
|
123571
|
+
* Zeebe BPMN behavior ensuring that bpmn:TimerEventDefinition has only allowed time properties of:
|
|
123572
|
+
* - timeCycle
|
|
123573
|
+
* - timeDate
|
|
123574
|
+
* - timeDuration
|
|
123575
|
+
*/
|
|
123576
|
+
class CleanUpTimerExpressionBehavior extends CommandInterceptor$1 {
|
|
123577
|
+
constructor(eventBus, modeling) {
|
|
123578
|
+
super(eventBus);
|
|
123579
|
+
|
|
123580
|
+
/**
|
|
123581
|
+
* Remove unsupported timer expressions.
|
|
123582
|
+
*/
|
|
123583
|
+
this.postExecuted([
|
|
123584
|
+
'shape.move',
|
|
123585
|
+
'shape.replace',
|
|
123586
|
+
'element.updateProperties',
|
|
123587
|
+
'element.updateModdleProperties'
|
|
123588
|
+
], context => {
|
|
123589
|
+
const element = context.shape || context.newShape || context.element;
|
|
123590
|
+
|
|
123591
|
+
if (element.labelTarget) {
|
|
123592
|
+
return;
|
|
123593
|
+
}
|
|
123594
|
+
|
|
123595
|
+
if (!is$5(element, 'bpmn:Event')) {
|
|
123596
|
+
return;
|
|
123597
|
+
}
|
|
123598
|
+
|
|
123599
|
+
const timerEventDefinition = getTimerEventDefinition(element);
|
|
123600
|
+
|
|
123601
|
+
if (!timerEventDefinition) {
|
|
123602
|
+
return;
|
|
123603
|
+
}
|
|
123604
|
+
|
|
123605
|
+
const propertiesUpdate = {};
|
|
123606
|
+
|
|
123607
|
+
[
|
|
123608
|
+
'timeCycle',
|
|
123609
|
+
'timeDate',
|
|
123610
|
+
'timeDuration'
|
|
123611
|
+
].forEach((type) => {
|
|
123612
|
+
if (timerEventDefinition.get(type) && !isTimerExpressionTypeSupported(type, element)) {
|
|
123613
|
+
propertiesUpdate[ type ] = undefined;
|
|
123614
|
+
}
|
|
123615
|
+
});
|
|
123616
|
+
|
|
123617
|
+
if (!Object.keys(propertiesUpdate).length) {
|
|
123618
|
+
return;
|
|
123619
|
+
}
|
|
123620
|
+
|
|
123621
|
+
modeling.updateModdleProperties(element, timerEventDefinition, propertiesUpdate);
|
|
123622
|
+
}, true);
|
|
123623
|
+
}
|
|
123624
|
+
}
|
|
123625
|
+
|
|
123626
|
+
CleanUpTimerExpressionBehavior.$inject = [
|
|
123627
|
+
'eventBus',
|
|
123628
|
+
'modeling'
|
|
123184
123629
|
];
|
|
123185
123630
|
|
|
123186
|
-
|
|
123187
|
-
|
|
123188
|
-
|
|
123189
|
-
|
|
123190
|
-
|
|
123191
|
-
|
|
123192
|
-
|
|
123193
|
-
|
|
123194
|
-
|
|
123195
|
-
|
|
123631
|
+
const WILDCARD = '*';
|
|
123632
|
+
|
|
123633
|
+
const TIMER_PROPERTIES = [
|
|
123634
|
+
'timeCycle',
|
|
123635
|
+
'timeDate',
|
|
123636
|
+
'timeDuration'
|
|
123637
|
+
];
|
|
123638
|
+
|
|
123639
|
+
const zeebeServiceTaskProperties = [
|
|
123640
|
+
'zeebe:Input',
|
|
123641
|
+
'zeebe:LoopCharacteristics',
|
|
123642
|
+
'zeebe:TaskDefinition',
|
|
123643
|
+
'zeebe:TaskHeaders',
|
|
123644
|
+
'zeebe:Subscription'
|
|
123645
|
+
];
|
|
123646
|
+
|
|
123647
|
+
class ZeebeModdleExtension {
|
|
123648
|
+
constructor(eventBus) {
|
|
123649
|
+
eventBus.on('moddleCopy.canCopyProperty', (context) => {
|
|
123650
|
+
const {
|
|
123651
|
+
parent,
|
|
123652
|
+
property,
|
|
123653
|
+
propertyName
|
|
123654
|
+
} = context;
|
|
123655
|
+
|
|
123656
|
+
return this.canCopyProperty(property, parent, propertyName);
|
|
123657
|
+
});
|
|
123658
|
+
}
|
|
123659
|
+
|
|
123660
|
+
canCopyProperty(property, parent, propertyName) {
|
|
123661
|
+
|
|
123662
|
+
// (1) check if property is allowed in parent
|
|
123663
|
+
if (isObject$1(property) && !isAllowedInParent(property, parent)) {
|
|
123664
|
+
return false;
|
|
123665
|
+
}
|
|
123666
|
+
|
|
123667
|
+
// (2) check for specific scenarios
|
|
123668
|
+
if (!this.canHostServiceTaskLikeProperties(property, parent)) {
|
|
123669
|
+
return false;
|
|
123670
|
+
}
|
|
123671
|
+
|
|
123672
|
+
if (!this.canHostTimerExpression(property, parent, propertyName)) {
|
|
123673
|
+
return false;
|
|
123674
|
+
}
|
|
123675
|
+
}
|
|
123676
|
+
|
|
123677
|
+
canHostServiceTaskLikeProperties(property, parent) {
|
|
123678
|
+
if (isAllowedInZeebeServiceTask(property)) {
|
|
123679
|
+
const serviceTaskLike = getParent(parent, 'bpmn:IntermediateThrowEvent') || getParent(parent, 'bpmn:EndEvent');
|
|
123680
|
+
|
|
123681
|
+
if (serviceTaskLike) {
|
|
123682
|
+
return isMessageEvent(serviceTaskLike);
|
|
123683
|
+
}
|
|
123684
|
+
}
|
|
123685
|
+
|
|
123686
|
+
return true;
|
|
123687
|
+
}
|
|
123688
|
+
|
|
123689
|
+
canHostTimerExpression(property, parent, propertyName) {
|
|
123690
|
+
if (!is$5(parent, 'bpmn:TimerEventDefinition') || !TIMER_PROPERTIES.includes(propertyName)) {
|
|
123691
|
+
return true;
|
|
123692
|
+
}
|
|
123693
|
+
|
|
123694
|
+
return isTimerExpressionTypeSupported(propertyName, parent.$parent);
|
|
123695
|
+
}
|
|
123696
|
+
}
|
|
123697
|
+
|
|
123698
|
+
ZeebeModdleExtension.$inject = [ 'eventBus' ];
|
|
123699
|
+
|
|
123700
|
+
|
|
123701
|
+
// helpers //////////
|
|
123702
|
+
|
|
123703
|
+
function getParent(element, type) {
|
|
123704
|
+
if (!type) {
|
|
123705
|
+
return element.$parent;
|
|
123706
|
+
}
|
|
123707
|
+
|
|
123708
|
+
if (is$5(element, type)) {
|
|
123709
|
+
return element;
|
|
123710
|
+
}
|
|
123711
|
+
|
|
123712
|
+
if (!element.$parent) {
|
|
123713
|
+
return;
|
|
123714
|
+
}
|
|
123715
|
+
|
|
123716
|
+
return getParent(element.$parent, type);
|
|
123717
|
+
}
|
|
123718
|
+
|
|
123719
|
+
function isAllowedInParent(property, parent) {
|
|
123720
|
+
|
|
123721
|
+
// (1) find property descriptor
|
|
123722
|
+
const descriptor = property.$type && property.$model.getTypeDescriptor(property.$type);
|
|
123723
|
+
|
|
123724
|
+
const allowedIn = descriptor && descriptor.meta && descriptor.meta.allowedIn;
|
|
123725
|
+
|
|
123726
|
+
if (!allowedIn || isWildcard(allowedIn)) {
|
|
123727
|
+
return true;
|
|
123728
|
+
}
|
|
123729
|
+
|
|
123730
|
+
// (2) check if property has parent of allowed type
|
|
123731
|
+
return some$1(allowedIn, function(type) {
|
|
123732
|
+
return getParent(parent, type);
|
|
123733
|
+
});
|
|
123734
|
+
}
|
|
123735
|
+
|
|
123736
|
+
function isWildcard(allowedIn) {
|
|
123737
|
+
return allowedIn.indexOf(WILDCARD) !== -1;
|
|
123738
|
+
}
|
|
123739
|
+
|
|
123740
|
+
function isMessageEvent(event) {
|
|
123741
|
+
const eventDefinitions = event.get('eventDefinitions');
|
|
123742
|
+
|
|
123743
|
+
return eventDefinitions.some((eventDefinition) => {
|
|
123744
|
+
return is$5(eventDefinition, 'bpmn:MessageEventDefinition');
|
|
123745
|
+
});
|
|
123746
|
+
}
|
|
123747
|
+
|
|
123748
|
+
// check if property is allowed in zeebe:ZeebeServiceTask but not for none events
|
|
123749
|
+
function isAllowedInZeebeServiceTask(property) {
|
|
123750
|
+
return zeebeServiceTaskProperties.some((propertyType) => {
|
|
123751
|
+
return is$5(property, propertyType);
|
|
123752
|
+
});
|
|
123196
123753
|
}
|
|
123197
123754
|
|
|
123198
|
-
|
|
123199
|
-
|
|
123200
|
-
|
|
123201
|
-
|
|
123202
|
-
|
|
123203
|
-
|
|
123204
|
-
|
|
123205
|
-
|
|
123206
|
-
|
|
123207
|
-
|
|
123208
|
-
|
|
123209
|
-
|
|
123210
|
-
|
|
123211
|
-
|
|
123212
|
-
|
|
123213
|
-
|
|
123755
|
+
/**
|
|
123756
|
+
* Creates a new element and set the parent to it
|
|
123757
|
+
*
|
|
123758
|
+
* @method ElementHelper#createElement
|
|
123759
|
+
*
|
|
123760
|
+
* @param {String} elementType of the new element
|
|
123761
|
+
* @param {Object} properties of the new element in key-value pairs
|
|
123762
|
+
* @param {moddle.object} parent of the new element
|
|
123763
|
+
* @param {BpmnFactory} factory which creates the new element
|
|
123764
|
+
*
|
|
123765
|
+
* @returns {djs.model.Base} element which is created
|
|
123766
|
+
*/
|
|
123767
|
+
function createElement$2(elementType, properties, parent, factory) {
|
|
123768
|
+
var element = factory.create(elementType, properties);
|
|
123769
|
+
element.$parent = parent;
|
|
123770
|
+
|
|
123771
|
+
return element;
|
|
123214
123772
|
}
|
|
123215
123773
|
|
|
123216
|
-
|
|
123217
|
-
|
|
123218
|
-
|
|
123219
|
-
|
|
123220
|
-
|
|
123221
|
-
|
|
123222
|
-
|
|
123223
|
-
|
|
123224
|
-
|
|
123225
|
-
|
|
123226
|
-
|
|
123227
|
-
|
|
123228
|
-
|
|
123229
|
-
|
|
123230
|
-
|
|
123231
|
-
|
|
123232
|
-
|
|
123233
|
-
|
|
123234
|
-
const listeners = executionListenersContainer.get('listeners');
|
|
123235
|
-
const newListeners = withoutDisallowedListeners$1(element, listeners);
|
|
123236
|
-
|
|
123237
|
-
if (newListeners.length !== listeners.length) {
|
|
123238
|
-
modeling.updateModdleProperties(element, executionListenersContainer, { listeners: newListeners });
|
|
123239
|
-
}
|
|
123240
|
-
});
|
|
123241
|
-
|
|
123242
|
-
// remove empty execution listener container
|
|
123243
|
-
this.postExecuted('element.updateModdleProperties', function(event) {
|
|
123244
|
-
const {
|
|
123245
|
-
element,
|
|
123246
|
-
moddleElement
|
|
123247
|
-
} = event.context;
|
|
123248
|
-
|
|
123249
|
-
if (!is$5(moddleElement, 'zeebe:ExecutionListeners')) {
|
|
123250
|
-
return;
|
|
123251
|
-
}
|
|
123252
|
-
|
|
123253
|
-
const listeners = moddleElement.get('listeners');
|
|
123254
|
-
if (listeners.length) {
|
|
123255
|
-
return;
|
|
123256
|
-
}
|
|
123257
|
-
|
|
123258
|
-
const extensionElements = moddleElement.$parent;
|
|
123259
|
-
modeling.updateModdleProperties(element, extensionElements, { values: without(extensionElements.get('values'), moddleElement) });
|
|
123260
|
-
});
|
|
123261
|
-
}
|
|
123262
|
-
}
|
|
123263
|
-
|
|
123264
|
-
CleanUpExecutionListenersBehavior.$inject = [
|
|
123265
|
-
'eventBus',
|
|
123266
|
-
'modeling'
|
|
123267
|
-
];
|
|
123268
|
-
|
|
123269
|
-
// helpers //////////
|
|
123270
|
-
function withoutDisallowedListeners$1(element, listeners) {
|
|
123271
|
-
listeners = withoutDisallowedStartListeners(element, listeners);
|
|
123272
|
-
listeners = withoutDisallowedEndListeners(element, listeners);
|
|
123273
|
-
|
|
123274
|
-
return listeners;
|
|
123275
|
-
}
|
|
123276
|
-
|
|
123277
|
-
function withoutDisallowedStartListeners(element, listeners) {
|
|
123278
|
-
if (isAny$1(element, DISALLOWED_START_LISTENER_TYPES)) {
|
|
123279
|
-
return listeners.filter(listener => listener.eventType !== 'start');
|
|
123280
|
-
}
|
|
123281
|
-
|
|
123282
|
-
return listeners;
|
|
123283
|
-
}
|
|
123284
|
-
|
|
123285
|
-
function withoutDisallowedEndListeners(element, listeners) {
|
|
123286
|
-
if (shouldRemoveEndListeners(element)) {
|
|
123287
|
-
return listeners.filter(listener => listener.eventType !== 'end');
|
|
123288
|
-
}
|
|
123289
|
-
|
|
123290
|
-
return listeners;
|
|
123291
|
-
}
|
|
123292
|
-
|
|
123293
|
-
function shouldRemoveEndListeners(element) {
|
|
123294
|
-
if (
|
|
123295
|
-
is$5(element, 'bpmn:BoundaryEvent') && isCompensationEvent(element) ||
|
|
123296
|
-
is$5(element, 'bpmn:EndEvent') && isErrorEvent(element) ||
|
|
123297
|
-
is$5(element, 'bpmn:Gateway')
|
|
123298
|
-
) {
|
|
123299
|
-
return true;
|
|
123300
|
-
}
|
|
123301
|
-
}
|
|
123302
|
-
|
|
123303
|
-
function isCompensationEvent(element) {
|
|
123304
|
-
const eventDefinitions = getEventDefinitions(element);
|
|
123305
|
-
|
|
123306
|
-
return find$2(eventDefinitions, function(definition) {
|
|
123307
|
-
return is$5(definition, 'bpmn:CompensateEventDefinition');
|
|
123308
|
-
});
|
|
123309
|
-
}
|
|
123310
|
-
|
|
123311
|
-
function isErrorEvent(element) {
|
|
123312
|
-
const eventDefinitions = getEventDefinitions(element);
|
|
123313
|
-
|
|
123314
|
-
return find$2(eventDefinitions, function(definition) {
|
|
123315
|
-
return is$5(definition, 'bpmn:ErrorEventDefinition');
|
|
123316
|
-
});
|
|
123317
|
-
}
|
|
123318
|
-
|
|
123319
|
-
function getEventDefinitions(element) {
|
|
123320
|
-
const businessObject = getBusinessObject$2(element);
|
|
123321
|
-
return businessObject.get('eventDefinitions') || [];
|
|
123322
|
-
}
|
|
123323
|
-
|
|
123324
|
-
function getExecutionListenersContainer(element) {
|
|
123325
|
-
return getExtensionElementsList$1(element, 'zeebe:ExecutionListeners')[0];
|
|
123326
|
-
}
|
|
123327
|
-
|
|
123328
|
-
const ALLOWED_EVENT_TYPES = [ 'complete', 'assignment' ];
|
|
123329
|
-
|
|
123330
|
-
class CleanUpTaskListenersBehavior extends CommandInterceptor$1 {
|
|
123331
|
-
constructor(eventBus, modeling) {
|
|
123332
|
-
super(eventBus);
|
|
123333
|
-
|
|
123334
|
-
// remove task listeners of disallowed type on shape replace
|
|
123335
|
-
this.postExecuted('shape.replace', function(event) {
|
|
123336
|
-
const element = event.context.newShape;
|
|
123337
|
-
|
|
123338
|
-
updateListeners(element, modeling);
|
|
123339
|
-
});
|
|
123340
|
-
|
|
123341
|
-
// remove task listeners of disallowed type on user task properties update
|
|
123342
|
-
this.postExecuted('element.updateModdleProperties', function(event) {
|
|
123343
|
-
const element = event.context.element;
|
|
123344
|
-
|
|
123345
|
-
if (!is$5(element, 'bpmn:UserTask')) {
|
|
123346
|
-
return;
|
|
123347
|
-
}
|
|
123348
|
-
|
|
123349
|
-
updateListeners(element, modeling);
|
|
123350
|
-
});
|
|
123351
|
-
|
|
123352
|
-
// remove empty task listener container
|
|
123353
|
-
this.postExecuted('element.updateModdleProperties', function(event) {
|
|
123354
|
-
const {
|
|
123355
|
-
element,
|
|
123356
|
-
moddleElement
|
|
123357
|
-
} = event.context;
|
|
123358
|
-
|
|
123359
|
-
if (!is$5(moddleElement, 'zeebe:TaskListeners')) {
|
|
123360
|
-
return;
|
|
123361
|
-
}
|
|
123362
|
-
|
|
123363
|
-
const listeners = moddleElement.get('listeners');
|
|
123364
|
-
if (listeners.length) {
|
|
123365
|
-
return;
|
|
123366
|
-
}
|
|
123367
|
-
|
|
123368
|
-
const extensionElements = moddleElement.$parent;
|
|
123369
|
-
modeling.updateModdleProperties(element, extensionElements, { values: without(extensionElements.get('values'), moddleElement) });
|
|
123370
|
-
});
|
|
123371
|
-
}
|
|
123372
|
-
}
|
|
123373
|
-
|
|
123374
|
-
CleanUpTaskListenersBehavior.$inject = [
|
|
123375
|
-
'eventBus',
|
|
123376
|
-
'modeling'
|
|
123377
|
-
];
|
|
123378
|
-
|
|
123379
|
-
// helpers //////////
|
|
123380
|
-
function updateListeners(element, modeling) {
|
|
123381
|
-
const taskListenersContainer = getTaskListenersContainer(element);
|
|
123382
|
-
if (!taskListenersContainer) {
|
|
123383
|
-
return;
|
|
123384
|
-
}
|
|
123385
|
-
|
|
123386
|
-
const listeners = taskListenersContainer.get('listeners');
|
|
123387
|
-
const newListeners = withoutDisallowedListeners(element, listeners);
|
|
123388
|
-
|
|
123389
|
-
if (newListeners.length !== listeners.length) {
|
|
123390
|
-
modeling.updateModdleProperties(element, taskListenersContainer, { listeners: newListeners });
|
|
123391
|
-
}
|
|
123392
|
-
}
|
|
123393
|
-
|
|
123394
|
-
function withoutDisallowedListeners(element, listeners) {
|
|
123395
|
-
return listeners.filter(listener => {
|
|
123396
|
-
if (
|
|
123397
|
-
!is$5(element, 'bpmn:UserTask') ||
|
|
123398
|
-
!ALLOWED_EVENT_TYPES.includes(listener.eventType) ||
|
|
123399
|
-
!hasZeebeTaskExtensionElement(element)
|
|
123400
|
-
) {
|
|
123401
|
-
return false;
|
|
123402
|
-
}
|
|
123403
|
-
return true;
|
|
123404
|
-
});
|
|
123405
|
-
}
|
|
123406
|
-
|
|
123407
|
-
function getTaskListenersContainer(element) {
|
|
123408
|
-
return getExtensionElementsList$1(element, 'zeebe:TaskListeners')[0];
|
|
123409
|
-
}
|
|
123410
|
-
|
|
123411
|
-
function hasZeebeTaskExtensionElement(element) {
|
|
123412
|
-
return getExtensionElementsList$1(element, 'zeebe:UserTask').length > 0;
|
|
123413
|
-
}
|
|
123414
|
-
|
|
123415
|
-
/**
|
|
123416
|
-
* Zeebe BPMN behavior ensuring that zeebe:subscription is removed from bpmn:Message
|
|
123417
|
-
* when it has no properties anymore.
|
|
123418
|
-
*/
|
|
123419
|
-
class CleanUpSubscriptionBehavior extends CommandInterceptor$1 {
|
|
123420
|
-
constructor(eventBus, commandStack) {
|
|
123421
|
-
super(eventBus);
|
|
123422
|
-
|
|
123423
|
-
this.postExecuted([
|
|
123424
|
-
'element.updateProperties',
|
|
123425
|
-
'element.updateModdleProperties'
|
|
123426
|
-
], context => {
|
|
123427
|
-
const element = context.shape || context.newShape || context.element;
|
|
123428
|
-
|
|
123429
|
-
if (element.labelTarget) {
|
|
123430
|
-
return;
|
|
123431
|
-
}
|
|
123432
|
-
|
|
123433
|
-
if (!is$5(element, 'bpmn:Event')) {
|
|
123434
|
-
return;
|
|
123435
|
-
}
|
|
123436
|
-
|
|
123437
|
-
const messageEventDefinition = getMessageEventDefinition$1(element);
|
|
123438
|
-
|
|
123439
|
-
if (!messageEventDefinition) {
|
|
123440
|
-
return;
|
|
123441
|
-
}
|
|
123442
|
-
|
|
123443
|
-
const message = messageEventDefinition.get('messageRef');
|
|
123444
|
-
|
|
123445
|
-
if (!message) {
|
|
123446
|
-
return;
|
|
123447
|
-
}
|
|
123448
|
-
|
|
123449
|
-
const subscription = getSubscription(message);
|
|
123450
|
-
|
|
123451
|
-
if (!subscription) {
|
|
123452
|
-
return;
|
|
123453
|
-
}
|
|
123454
|
-
|
|
123455
|
-
if (!hasNoProperties(subscription)) {
|
|
123456
|
-
return;
|
|
123457
|
-
}
|
|
123458
|
-
|
|
123459
|
-
removeExtensionElements(element, message, subscription, commandStack);
|
|
123460
|
-
}, true);
|
|
123461
|
-
}
|
|
123462
|
-
}
|
|
123463
|
-
|
|
123464
|
-
CleanUpSubscriptionBehavior.$inject = [
|
|
123465
|
-
'eventBus',
|
|
123466
|
-
'commandStack'
|
|
123467
|
-
];
|
|
123468
|
-
|
|
123469
|
-
|
|
123470
|
-
// helpers //////////
|
|
123471
|
-
|
|
123472
|
-
function getMessageEventDefinition$1(event) {
|
|
123473
|
-
const businessObject = getBusinessObject$2(event);
|
|
123474
|
-
|
|
123475
|
-
return businessObject.get('eventDefinitions').find(eventDefinition => {
|
|
123476
|
-
return is$5(eventDefinition, 'bpmn:MessageEventDefinition');
|
|
123477
|
-
});
|
|
123478
|
-
}
|
|
123479
|
-
|
|
123480
|
-
function getSubscription(message) {
|
|
123481
|
-
return getExtensionElementsList$1(message, 'zeebe:Subscription')[ 0 ];
|
|
123482
|
-
}
|
|
123483
|
-
|
|
123484
|
-
function hasNoProperties(element) {
|
|
123485
|
-
const descriptor = element.$descriptor;
|
|
123486
|
-
|
|
123487
|
-
return descriptor.properties.every(property => {
|
|
123488
|
-
return element.get(property.name) === undefined;
|
|
123489
|
-
});
|
|
123490
|
-
}
|
|
123491
|
-
|
|
123492
|
-
function getTimerEventDefinition(element) {
|
|
123493
|
-
const businessObject = getBusinessObject$2(element);
|
|
123494
|
-
|
|
123495
|
-
return businessObject.get('eventDefinitions').find(eventDefinition => {
|
|
123496
|
-
return is$5(eventDefinition, 'bpmn:TimerEventDefinition');
|
|
123497
|
-
});
|
|
123498
|
-
}
|
|
123499
|
-
|
|
123500
|
-
/**
|
|
123501
|
-
* Check whether a given timer expression type is supported for a given element.
|
|
123502
|
-
*
|
|
123503
|
-
* @param {string} type
|
|
123504
|
-
* @param {Element|ModdleElement} element
|
|
123505
|
-
*
|
|
123506
|
-
* @return {boolean}
|
|
123507
|
-
*/
|
|
123508
|
-
function isTimerExpressionTypeSupported(type, element) {
|
|
123509
|
-
const businessObject = getBusinessObject$2(element);
|
|
123510
|
-
|
|
123511
|
-
switch (type) {
|
|
123512
|
-
case 'timeDate':
|
|
123513
|
-
return isAny$1(element, [
|
|
123514
|
-
'bpmn:BoundaryEvent',
|
|
123515
|
-
'bpmn:IntermediateCatchEvent',
|
|
123516
|
-
'bpmn:StartEvent'
|
|
123517
|
-
]);
|
|
123518
|
-
|
|
123519
|
-
case 'timeCycle':
|
|
123520
|
-
if (is$5(element, 'bpmn:StartEvent') && (!hasParentEventSubProcess(businessObject)) || !isInterrupting(businessObject)) {
|
|
123521
|
-
return true;
|
|
123522
|
-
}
|
|
123523
|
-
|
|
123524
|
-
if (is$5(element, 'bpmn:BoundaryEvent') && !isInterrupting(businessObject)) {
|
|
123525
|
-
return true;
|
|
123526
|
-
}
|
|
123527
|
-
|
|
123528
|
-
return false;
|
|
123529
|
-
|
|
123530
|
-
case 'timeDuration':
|
|
123531
|
-
if (isAny$1(element, [
|
|
123532
|
-
'bpmn:BoundaryEvent',
|
|
123533
|
-
'bpmn:IntermediateCatchEvent'
|
|
123534
|
-
])) {
|
|
123535
|
-
return true;
|
|
123536
|
-
}
|
|
123537
|
-
|
|
123538
|
-
if (is$5(element, 'bpmn:StartEvent') && hasParentEventSubProcess(businessObject)) {
|
|
123539
|
-
return true;
|
|
123540
|
-
}
|
|
123541
|
-
|
|
123542
|
-
return false;
|
|
123543
|
-
|
|
123544
|
-
default:
|
|
123545
|
-
return false;
|
|
123546
|
-
}
|
|
123547
|
-
}
|
|
123548
|
-
|
|
123549
|
-
function isInterrupting(businessObject) {
|
|
123550
|
-
if (is$5(businessObject, 'bpmn:BoundaryEvent')) {
|
|
123551
|
-
return businessObject.get('cancelActivity') !== false;
|
|
123552
|
-
}
|
|
123553
|
-
|
|
123554
|
-
return businessObject.get('isInterrupting') !== false;
|
|
123555
|
-
}
|
|
123556
|
-
|
|
123557
|
-
function hasParentEventSubProcess(businessObject) {
|
|
123558
|
-
const parent = businessObject.$parent;
|
|
123559
|
-
|
|
123560
|
-
return parent && is$5(parent, 'bpmn:SubProcess') && parent.get('triggeredByEvent');
|
|
123561
|
-
}
|
|
123562
|
-
|
|
123563
|
-
/**
|
|
123564
|
-
* Zeebe BPMN behavior ensuring that bpmn:TimerEventDefinition has only allowed time properties of:
|
|
123565
|
-
* - timeCycle
|
|
123566
|
-
* - timeDate
|
|
123567
|
-
* - timeDuration
|
|
123568
|
-
*/
|
|
123569
|
-
class CleanUpTimerExpressionBehavior extends CommandInterceptor$1 {
|
|
123570
|
-
constructor(eventBus, modeling) {
|
|
123571
|
-
super(eventBus);
|
|
123572
|
-
|
|
123573
|
-
/**
|
|
123574
|
-
* Remove unsupported timer expressions.
|
|
123575
|
-
*/
|
|
123576
|
-
this.postExecuted([
|
|
123577
|
-
'shape.move',
|
|
123578
|
-
'shape.replace',
|
|
123579
|
-
'element.updateProperties',
|
|
123580
|
-
'element.updateModdleProperties'
|
|
123581
|
-
], context => {
|
|
123582
|
-
const element = context.shape || context.newShape || context.element;
|
|
123583
|
-
|
|
123584
|
-
if (element.labelTarget) {
|
|
123585
|
-
return;
|
|
123586
|
-
}
|
|
123587
|
-
|
|
123588
|
-
if (!is$5(element, 'bpmn:Event')) {
|
|
123589
|
-
return;
|
|
123590
|
-
}
|
|
123591
|
-
|
|
123592
|
-
const timerEventDefinition = getTimerEventDefinition(element);
|
|
123593
|
-
|
|
123594
|
-
if (!timerEventDefinition) {
|
|
123595
|
-
return;
|
|
123596
|
-
}
|
|
123597
|
-
|
|
123598
|
-
const propertiesUpdate = {};
|
|
123599
|
-
|
|
123600
|
-
[
|
|
123601
|
-
'timeCycle',
|
|
123602
|
-
'timeDate',
|
|
123603
|
-
'timeDuration'
|
|
123604
|
-
].forEach((type) => {
|
|
123605
|
-
if (timerEventDefinition.get(type) && !isTimerExpressionTypeSupported(type, element)) {
|
|
123606
|
-
propertiesUpdate[ type ] = undefined;
|
|
123607
|
-
}
|
|
123608
|
-
});
|
|
123609
|
-
|
|
123610
|
-
if (!Object.keys(propertiesUpdate).length) {
|
|
123611
|
-
return;
|
|
123612
|
-
}
|
|
123613
|
-
|
|
123614
|
-
modeling.updateModdleProperties(element, timerEventDefinition, propertiesUpdate);
|
|
123615
|
-
}, true);
|
|
123616
|
-
}
|
|
123617
|
-
}
|
|
123618
|
-
|
|
123619
|
-
CleanUpTimerExpressionBehavior.$inject = [
|
|
123620
|
-
'eventBus',
|
|
123621
|
-
'modeling'
|
|
123622
|
-
];
|
|
123623
|
-
|
|
123624
|
-
const WILDCARD = '*';
|
|
123625
|
-
|
|
123626
|
-
const TIMER_PROPERTIES = [
|
|
123627
|
-
'timeCycle',
|
|
123628
|
-
'timeDate',
|
|
123629
|
-
'timeDuration'
|
|
123630
|
-
];
|
|
123631
|
-
|
|
123632
|
-
const zeebeServiceTaskProperties = [
|
|
123633
|
-
'zeebe:Input',
|
|
123634
|
-
'zeebe:LoopCharacteristics',
|
|
123635
|
-
'zeebe:TaskDefinition',
|
|
123636
|
-
'zeebe:TaskHeaders',
|
|
123637
|
-
'zeebe:Subscription'
|
|
123638
|
-
];
|
|
123639
|
-
|
|
123640
|
-
class ZeebeModdleExtension {
|
|
123641
|
-
constructor(eventBus) {
|
|
123642
|
-
eventBus.on('moddleCopy.canCopyProperty', (context) => {
|
|
123643
|
-
const {
|
|
123644
|
-
parent,
|
|
123645
|
-
property,
|
|
123646
|
-
propertyName
|
|
123647
|
-
} = context;
|
|
123648
|
-
|
|
123649
|
-
return this.canCopyProperty(property, parent, propertyName);
|
|
123650
|
-
});
|
|
123651
|
-
}
|
|
123652
|
-
|
|
123653
|
-
canCopyProperty(property, parent, propertyName) {
|
|
123654
|
-
|
|
123655
|
-
// (1) check if property is allowed in parent
|
|
123656
|
-
if (isObject$1(property) && !isAllowedInParent(property, parent)) {
|
|
123657
|
-
return false;
|
|
123658
|
-
}
|
|
123659
|
-
|
|
123660
|
-
// (2) check for specific scenarios
|
|
123661
|
-
if (!this.canHostServiceTaskLikeProperties(property, parent)) {
|
|
123662
|
-
return false;
|
|
123663
|
-
}
|
|
123664
|
-
|
|
123665
|
-
if (!this.canHostTimerExpression(property, parent, propertyName)) {
|
|
123666
|
-
return false;
|
|
123667
|
-
}
|
|
123668
|
-
}
|
|
123669
|
-
|
|
123670
|
-
canHostServiceTaskLikeProperties(property, parent) {
|
|
123671
|
-
if (isAllowedInZeebeServiceTask(property)) {
|
|
123672
|
-
const serviceTaskLike = getParent(parent, 'bpmn:IntermediateThrowEvent') || getParent(parent, 'bpmn:EndEvent');
|
|
123673
|
-
|
|
123674
|
-
if (serviceTaskLike) {
|
|
123675
|
-
return isMessageEvent(serviceTaskLike);
|
|
123676
|
-
}
|
|
123677
|
-
}
|
|
123678
|
-
|
|
123679
|
-
return true;
|
|
123680
|
-
}
|
|
123681
|
-
|
|
123682
|
-
canHostTimerExpression(property, parent, propertyName) {
|
|
123683
|
-
if (!is$5(parent, 'bpmn:TimerEventDefinition') || !TIMER_PROPERTIES.includes(propertyName)) {
|
|
123684
|
-
return true;
|
|
123685
|
-
}
|
|
123686
|
-
|
|
123687
|
-
return isTimerExpressionTypeSupported(propertyName, parent.$parent);
|
|
123688
|
-
}
|
|
123689
|
-
}
|
|
123690
|
-
|
|
123691
|
-
ZeebeModdleExtension.$inject = [ 'eventBus' ];
|
|
123692
|
-
|
|
123693
|
-
|
|
123694
|
-
// helpers //////////
|
|
123695
|
-
|
|
123696
|
-
function getParent(element, type) {
|
|
123697
|
-
if (!type) {
|
|
123698
|
-
return element.$parent;
|
|
123699
|
-
}
|
|
123700
|
-
|
|
123701
|
-
if (is$5(element, type)) {
|
|
123702
|
-
return element;
|
|
123703
|
-
}
|
|
123704
|
-
|
|
123705
|
-
if (!element.$parent) {
|
|
123706
|
-
return;
|
|
123707
|
-
}
|
|
123708
|
-
|
|
123709
|
-
return getParent(element.$parent, type);
|
|
123710
|
-
}
|
|
123711
|
-
|
|
123712
|
-
function isAllowedInParent(property, parent) {
|
|
123713
|
-
|
|
123714
|
-
// (1) find property descriptor
|
|
123715
|
-
const descriptor = property.$type && property.$model.getTypeDescriptor(property.$type);
|
|
123716
|
-
|
|
123717
|
-
const allowedIn = descriptor && descriptor.meta && descriptor.meta.allowedIn;
|
|
123718
|
-
|
|
123719
|
-
if (!allowedIn || isWildcard(allowedIn)) {
|
|
123720
|
-
return true;
|
|
123721
|
-
}
|
|
123722
|
-
|
|
123723
|
-
// (2) check if property has parent of allowed type
|
|
123724
|
-
return some$1(allowedIn, function(type) {
|
|
123725
|
-
return getParent(parent, type);
|
|
123726
|
-
});
|
|
123727
|
-
}
|
|
123728
|
-
|
|
123729
|
-
function isWildcard(allowedIn) {
|
|
123730
|
-
return allowedIn.indexOf(WILDCARD) !== -1;
|
|
123731
|
-
}
|
|
123732
|
-
|
|
123733
|
-
function isMessageEvent(event) {
|
|
123734
|
-
const eventDefinitions = event.get('eventDefinitions');
|
|
123735
|
-
|
|
123736
|
-
return eventDefinitions.some((eventDefinition) => {
|
|
123737
|
-
return is$5(eventDefinition, 'bpmn:MessageEventDefinition');
|
|
123738
|
-
});
|
|
123739
|
-
}
|
|
123740
|
-
|
|
123741
|
-
// check if property is allowed in zeebe:ZeebeServiceTask but not for none events
|
|
123742
|
-
function isAllowedInZeebeServiceTask(property) {
|
|
123743
|
-
return zeebeServiceTaskProperties.some((propertyType) => {
|
|
123744
|
-
return is$5(property, propertyType);
|
|
123745
|
-
});
|
|
123746
|
-
}
|
|
123747
|
-
|
|
123748
|
-
/**
|
|
123749
|
-
* Creates a new element and set the parent to it
|
|
123750
|
-
*
|
|
123751
|
-
* @method ElementHelper#createElement
|
|
123752
|
-
*
|
|
123753
|
-
* @param {String} elementType of the new element
|
|
123754
|
-
* @param {Object} properties of the new element in key-value pairs
|
|
123755
|
-
* @param {moddle.object} parent of the new element
|
|
123756
|
-
* @param {BpmnFactory} factory which creates the new element
|
|
123757
|
-
*
|
|
123758
|
-
* @returns {djs.model.Base} element which is created
|
|
123759
|
-
*/
|
|
123760
|
-
function createElement$2(elementType, properties, parent, factory) {
|
|
123761
|
-
var element = factory.create(elementType, properties);
|
|
123762
|
-
element.$parent = parent;
|
|
123763
|
-
|
|
123764
|
-
return element;
|
|
123765
|
-
}
|
|
123766
|
-
|
|
123767
|
-
/**
|
|
123768
|
-
* Get zeebe:CalledElement of an element.
|
|
123769
|
-
*
|
|
123770
|
-
* @param {djs.model.Base|ModdleElement} element
|
|
123771
|
-
*
|
|
123772
|
-
* @returns {ModdleElement}
|
|
123773
|
-
*/
|
|
123774
|
-
function getCalledElement(element) {
|
|
123775
|
-
const calledElements = getCalledElements(element);
|
|
123776
|
-
|
|
123777
|
-
return calledElements[ 0 ];
|
|
123778
|
-
}
|
|
123779
|
-
|
|
123780
|
-
function getCalledElements(element) {
|
|
123781
|
-
const businessObject = getBusinessObject$2(element);
|
|
123782
|
-
|
|
123783
|
-
return getExtensionElementsList$1(businessObject, 'zeebe:CalledElement');
|
|
123784
|
-
}
|
|
123785
|
-
|
|
123786
|
-
const HIGH_PRIORITY$4 = 5000;
|
|
123787
|
-
|
|
123788
|
-
|
|
123789
|
-
/**
|
|
123790
|
-
* Zeebe BPMN specific behavior for creating call activities.
|
|
123791
|
-
*/
|
|
123792
|
-
class CreateZeebeCallActivityBehavior extends CommandInterceptor$1 {
|
|
123793
|
-
constructor(bpmnFactory, eventBus, modeling) {
|
|
123794
|
-
super(eventBus);
|
|
123795
|
-
|
|
123796
|
-
/**
|
|
123797
|
-
* Add zeebe:CalledElement extension element with zeebe:propagateAllChildVariables attribute = false
|
|
123798
|
-
* when creating bpmn:CallActivity.
|
|
123799
|
-
*/
|
|
123800
|
-
this.postExecuted('shape.create', HIGH_PRIORITY$4, function(context) {
|
|
123801
|
-
const { shape } = context;
|
|
123802
|
-
|
|
123803
|
-
if (!is$5(shape, 'bpmn:CallActivity')) {
|
|
123804
|
-
return;
|
|
123805
|
-
}
|
|
123806
|
-
|
|
123807
|
-
const businessObject = getBusinessObject$2(shape);
|
|
123808
|
-
|
|
123809
|
-
let calledElement = getCalledElement(businessObject);
|
|
123810
|
-
|
|
123811
|
-
if (!calledElement) {
|
|
123812
|
-
let extensionElements = businessObject.get('extensionElements');
|
|
123813
|
-
|
|
123814
|
-
if (!extensionElements) {
|
|
123815
|
-
extensionElements = createElement$2(
|
|
123816
|
-
'bpmn:ExtensionElements',
|
|
123817
|
-
{
|
|
123818
|
-
values: []
|
|
123819
|
-
},
|
|
123820
|
-
businessObject,
|
|
123821
|
-
bpmnFactory
|
|
123822
|
-
);
|
|
123823
|
-
|
|
123824
|
-
modeling.updateProperties(shape, { extensionElements });
|
|
123825
|
-
}
|
|
123826
|
-
|
|
123827
|
-
calledElement = createElement$2(
|
|
123828
|
-
'zeebe:CalledElement',
|
|
123829
|
-
{
|
|
123830
|
-
propagateAllChildVariables: false
|
|
123831
|
-
},
|
|
123832
|
-
extensionElements,
|
|
123833
|
-
bpmnFactory
|
|
123834
|
-
);
|
|
123835
|
-
|
|
123836
|
-
modeling.updateModdleProperties(shape, extensionElements, {
|
|
123837
|
-
values: [
|
|
123838
|
-
...(extensionElements.values || []),
|
|
123839
|
-
calledElement
|
|
123840
|
-
]
|
|
123841
|
-
});
|
|
123842
|
-
} else if (!has$2(calledElement, 'propagateAllChildVariables')) {
|
|
123843
|
-
|
|
123844
|
-
// set zeebe:propagateAllChildVariables to false if zeebe:CalledElement exists
|
|
123845
|
-
modeling.updateModdleProperties(shape, calledElement, {
|
|
123846
|
-
propagateAllChildVariables: false
|
|
123847
|
-
});
|
|
123848
|
-
}
|
|
123849
|
-
}, true);
|
|
123850
|
-
|
|
123851
|
-
}
|
|
123852
|
-
}
|
|
123853
|
-
|
|
123854
|
-
CreateZeebeCallActivityBehavior.$inject = [
|
|
123855
|
-
'bpmnFactory',
|
|
123856
|
-
'eventBus',
|
|
123857
|
-
'modeling'
|
|
123858
|
-
];
|
|
123859
|
-
|
|
123860
|
-
const LOW_PRIORITY$1 = 250;
|
|
123861
|
-
|
|
123862
|
-
/**
|
|
123863
|
-
* Camunda-specific behavior ensuring `isExecutable` is kept after deleting
|
|
123864
|
-
* the last participant.
|
|
123865
|
-
*/
|
|
123866
|
-
class DeleteParticipantBehaviour extends CommandInterceptor$1 {
|
|
123867
|
-
constructor(eventBus, canvas, modeling) {
|
|
123868
|
-
super(eventBus);
|
|
123869
|
-
|
|
123870
|
-
this.postExecuted('shape.delete', LOW_PRIORITY$1, function(context) {
|
|
123871
|
-
const {
|
|
123872
|
-
collaborationRoot,
|
|
123873
|
-
shape
|
|
123874
|
-
} = context;
|
|
123875
|
-
|
|
123876
|
-
const newRoot = canvas.getRootElement();
|
|
123877
|
-
|
|
123878
|
-
if (is$5(shape, 'bpmn:Participant') &&
|
|
123879
|
-
collaborationRoot &&
|
|
123880
|
-
!collaborationRoot.businessObject.get('participants').length &&
|
|
123881
|
-
is$5(newRoot, 'bpmn:Process')) {
|
|
123882
|
-
|
|
123883
|
-
const oldProcessBusinessObject = shape.businessObject.get('processRef');
|
|
123884
|
-
|
|
123885
|
-
if (!oldProcessBusinessObject) {
|
|
123886
|
-
return;
|
|
123887
|
-
}
|
|
123888
|
-
|
|
123889
|
-
modeling.updateProperties(newRoot, { isExecutable: oldProcessBusinessObject.get('isExecutable') });
|
|
123890
|
-
}
|
|
123891
|
-
|
|
123892
|
-
}, true);
|
|
123893
|
-
}
|
|
123774
|
+
/**
|
|
123775
|
+
* Get zeebe:CalledElement of an element.
|
|
123776
|
+
*
|
|
123777
|
+
* @param {djs.model.Base|ModdleElement} element
|
|
123778
|
+
*
|
|
123779
|
+
* @returns {ModdleElement}
|
|
123780
|
+
*/
|
|
123781
|
+
function getCalledElement(element) {
|
|
123782
|
+
const calledElements = getCalledElements(element);
|
|
123783
|
+
|
|
123784
|
+
return calledElements[ 0 ];
|
|
123785
|
+
}
|
|
123786
|
+
|
|
123787
|
+
function getCalledElements(element) {
|
|
123788
|
+
const businessObject = getBusinessObject$2(element);
|
|
123789
|
+
|
|
123790
|
+
return getExtensionElementsList$1(businessObject, 'zeebe:CalledElement');
|
|
123894
123791
|
}
|
|
123895
123792
|
|
|
123896
|
-
|
|
123897
|
-
|
|
123898
|
-
|
|
123899
|
-
|
|
123793
|
+
const HIGH_PRIORITY$4 = 5000;
|
|
123794
|
+
|
|
123795
|
+
|
|
123796
|
+
/**
|
|
123797
|
+
* Zeebe BPMN specific behavior for creating call activities.
|
|
123798
|
+
*/
|
|
123799
|
+
class CreateZeebeCallActivityBehavior extends CommandInterceptor$1 {
|
|
123800
|
+
constructor(bpmnFactory, eventBus, modeling) {
|
|
123801
|
+
super(eventBus);
|
|
123802
|
+
|
|
123803
|
+
/**
|
|
123804
|
+
* Add zeebe:CalledElement extension element with zeebe:propagateAllChildVariables attribute = false
|
|
123805
|
+
* when creating bpmn:CallActivity.
|
|
123806
|
+
*/
|
|
123807
|
+
this.postExecuted('shape.create', HIGH_PRIORITY$4, function(context) {
|
|
123808
|
+
const { shape } = context;
|
|
123809
|
+
|
|
123810
|
+
if (!is$5(shape, 'bpmn:CallActivity')) {
|
|
123811
|
+
return;
|
|
123812
|
+
}
|
|
123813
|
+
|
|
123814
|
+
const businessObject = getBusinessObject$2(shape);
|
|
123815
|
+
|
|
123816
|
+
let calledElement = getCalledElement(businessObject);
|
|
123817
|
+
|
|
123818
|
+
if (!calledElement) {
|
|
123819
|
+
let extensionElements = businessObject.get('extensionElements');
|
|
123820
|
+
|
|
123821
|
+
if (!extensionElements) {
|
|
123822
|
+
extensionElements = createElement$2(
|
|
123823
|
+
'bpmn:ExtensionElements',
|
|
123824
|
+
{
|
|
123825
|
+
values: []
|
|
123826
|
+
},
|
|
123827
|
+
businessObject,
|
|
123828
|
+
bpmnFactory
|
|
123829
|
+
);
|
|
123830
|
+
|
|
123831
|
+
modeling.updateProperties(shape, { extensionElements });
|
|
123832
|
+
}
|
|
123833
|
+
|
|
123834
|
+
calledElement = createElement$2(
|
|
123835
|
+
'zeebe:CalledElement',
|
|
123836
|
+
{
|
|
123837
|
+
propagateAllChildVariables: false
|
|
123838
|
+
},
|
|
123839
|
+
extensionElements,
|
|
123840
|
+
bpmnFactory
|
|
123841
|
+
);
|
|
123842
|
+
|
|
123843
|
+
modeling.updateModdleProperties(shape, extensionElements, {
|
|
123844
|
+
values: [
|
|
123845
|
+
...(extensionElements.values || []),
|
|
123846
|
+
calledElement
|
|
123847
|
+
]
|
|
123848
|
+
});
|
|
123849
|
+
} else if (!has$2(calledElement, 'propagateAllChildVariables')) {
|
|
123850
|
+
|
|
123851
|
+
// set zeebe:propagateAllChildVariables to false if zeebe:CalledElement exists
|
|
123852
|
+
modeling.updateModdleProperties(shape, calledElement, {
|
|
123853
|
+
propagateAllChildVariables: false
|
|
123854
|
+
});
|
|
123855
|
+
}
|
|
123856
|
+
}, true);
|
|
123857
|
+
|
|
123858
|
+
}
|
|
123859
|
+
}
|
|
123860
|
+
|
|
123861
|
+
CreateZeebeCallActivityBehavior.$inject = [
|
|
123862
|
+
'bpmnFactory',
|
|
123863
|
+
'eventBus',
|
|
123864
|
+
'modeling'
|
|
123900
123865
|
];
|
|
123901
123866
|
|
|
123902
|
-
const
|
|
123903
|
-
|
|
123904
|
-
/**
|
|
123905
|
-
*
|
|
123906
|
-
|
|
123907
|
-
|
|
123908
|
-
|
|
123909
|
-
|
|
123910
|
-
|
|
123911
|
-
|
|
123912
|
-
|
|
123913
|
-
|
|
123914
|
-
|
|
123915
|
-
|
|
123916
|
-
|
|
123917
|
-
|
|
123918
|
-
|
|
123919
|
-
|
|
123920
|
-
|
|
123921
|
-
|
|
123922
|
-
|
|
123923
|
-
|
|
123924
|
-
|
|
123925
|
-
|
|
123926
|
-
|
|
123927
|
-
|
|
123928
|
-
|
|
123929
|
-
|
|
123930
|
-
|
|
123931
|
-
|
|
123932
|
-
|
|
123933
|
-
|
|
123934
|
-
|
|
123935
|
-
|
|
123936
|
-
|
|
123937
|
-
|
|
123938
|
-
|
|
123939
|
-
|
|
123940
|
-
|
|
123941
|
-
|
|
123942
|
-
return userTaskForms.find(userTaskForm => {
|
|
123943
|
-
return userTaskFormIdToFormKey(userTaskForm.get('id')) === formKey;
|
|
123944
|
-
});
|
|
123945
|
-
}
|
|
123946
|
-
|
|
123947
|
-
function userTaskFormIdToFormKey(userTaskFormId) {
|
|
123948
|
-
return `${ FORM_KEY_PREFIX }${ userTaskFormId }`;
|
|
123949
|
-
}
|
|
123950
|
-
|
|
123951
|
-
function isUserTaskFormKey(formKey) {
|
|
123952
|
-
return formKey && formKey.startsWith(FORM_KEY_PREFIX);
|
|
123953
|
-
}
|
|
123954
|
-
|
|
123955
|
-
function createUserTaskFormId() {
|
|
123956
|
-
return getPrefixedId(USER_TASK_FORM_ID_PREFIX);
|
|
123957
|
-
}
|
|
123958
|
-
|
|
123959
|
-
function getRootElement$1(element) {
|
|
123960
|
-
const businessObject = getBusinessObject$2(element);
|
|
123961
|
-
|
|
123962
|
-
let parent = businessObject;
|
|
123963
|
-
|
|
123964
|
-
while (parent.$parent && !is$5(parent, 'bpmn:Process')) {
|
|
123965
|
-
parent = parent.$parent;
|
|
123966
|
-
}
|
|
123967
|
-
|
|
123968
|
-
return parent;
|
|
123969
|
-
}
|
|
123970
|
-
|
|
123971
|
-
/**
|
|
123972
|
-
* Zeebe BPMN specific forms behavior.
|
|
123973
|
-
*/
|
|
123974
|
-
class FormsBehavior extends CommandInterceptor$1 {
|
|
123975
|
-
constructor(bpmnFactory, eventBus, modeling) {
|
|
123976
|
-
super(eventBus);
|
|
123977
|
-
|
|
123978
|
-
this._modeling = modeling;
|
|
123979
|
-
|
|
123980
|
-
function removeUserTaskForm(element, moddleElement, userTaskForm) {
|
|
123981
|
-
const extensionElements = moddleElement.get('extensionElements');
|
|
123982
|
-
|
|
123983
|
-
const values = without(extensionElements.get('values'), userTaskForm);
|
|
123984
|
-
|
|
123985
|
-
modeling.updateModdleProperties(element, extensionElements, {
|
|
123986
|
-
values
|
|
123987
|
-
});
|
|
123988
|
-
|
|
123989
|
-
if (!values.length) {
|
|
123990
|
-
modeling.updateModdleProperties(element, moddleElement, {
|
|
123991
|
-
extensionElements: undefined
|
|
123992
|
-
});
|
|
123993
|
-
}
|
|
123994
|
-
}
|
|
123995
|
-
|
|
123996
|
-
/**
|
|
123997
|
-
* Remove zeebe:UserTaskForm on user task removed.
|
|
123998
|
-
*/
|
|
123999
|
-
this.postExecute('shape.delete', function(context) {
|
|
124000
|
-
const {
|
|
124001
|
-
oldParent,
|
|
124002
|
-
shape
|
|
124003
|
-
} = context;
|
|
124004
|
-
|
|
124005
|
-
const rootElement = getRootElement$1(oldParent);
|
|
124006
|
-
|
|
124007
|
-
const userTaskForm = getUserTaskForm(shape, { rootElement });
|
|
124008
|
-
|
|
124009
|
-
if (!is$5(shape, 'bpmn:UserTask') || !userTaskForm) {
|
|
124010
|
-
return;
|
|
124011
|
-
}
|
|
124012
|
-
|
|
124013
|
-
removeUserTaskForm(shape, rootElement, userTaskForm);
|
|
124014
|
-
}, true);
|
|
124015
|
-
|
|
124016
|
-
|
|
124017
|
-
/**
|
|
124018
|
-
* Create new zeebe:FormDefinition and zeebe:UserTaskForm on user task created.
|
|
124019
|
-
*/
|
|
124020
|
-
this.postExecute('shape.create', function(context) {
|
|
124021
|
-
const { shape } = context;
|
|
124022
|
-
|
|
124023
|
-
const oldFormDefinition = getFormDefinition(shape);
|
|
124024
|
-
|
|
124025
|
-
if (!is$5(shape, 'bpmn:UserTask') || !oldFormDefinition) {
|
|
124026
|
-
return;
|
|
124027
|
-
}
|
|
124028
|
-
|
|
124029
|
-
const oldUserTaskForm = getUserTaskForm(shape);
|
|
124030
|
-
|
|
124031
|
-
const rootElement = getRootElement$1(shape);
|
|
124032
|
-
|
|
124033
|
-
const businessObject = getBusinessObject$2(shape);
|
|
124034
|
-
|
|
124035
|
-
const extensionElements = businessObject.get('extensionElements');
|
|
124036
|
-
|
|
124037
|
-
let rootExtensionElements = rootElement.get('extensionElements');
|
|
124038
|
-
|
|
124039
|
-
// (1) ensure extension elements exists
|
|
124040
|
-
if (!rootExtensionElements) {
|
|
124041
|
-
rootExtensionElements = createElement$2('bpmn:ExtensionElements', { values: [] }, rootElement, bpmnFactory);
|
|
124042
|
-
|
|
124043
|
-
modeling.updateModdleProperties(shape, rootElement, { extensionElements: rootExtensionElements });
|
|
124044
|
-
}
|
|
124045
|
-
|
|
124046
|
-
// (2) remove existing form definition
|
|
124047
|
-
let values = extensionElements.get('values').filter((element) => {
|
|
124048
|
-
return element !== oldFormDefinition;
|
|
124049
|
-
});
|
|
124050
|
-
|
|
124051
|
-
// (3) create new form definition
|
|
124052
|
-
const userTaskFormId = createUserTaskFormId();
|
|
124053
|
-
|
|
124054
|
-
const newFormDefinition = createElement$2('zeebe:FormDefinition', {
|
|
124055
|
-
formKey: userTaskFormIdToFormKey(userTaskFormId)
|
|
124056
|
-
}, extensionElements, bpmnFactory);
|
|
124057
|
-
|
|
124058
|
-
values = [
|
|
124059
|
-
...values,
|
|
124060
|
-
newFormDefinition
|
|
124061
|
-
];
|
|
124062
|
-
|
|
124063
|
-
modeling.updateModdleProperties(shape, extensionElements, {
|
|
124064
|
-
values
|
|
124065
|
-
});
|
|
124066
|
-
|
|
124067
|
-
// (4) create new user task form
|
|
124068
|
-
const userTaskForm = createElement$2('zeebe:UserTaskForm', {
|
|
124069
|
-
id: userTaskFormId,
|
|
124070
|
-
body: oldUserTaskForm ? oldUserTaskForm.get('body') : ''
|
|
124071
|
-
}, rootExtensionElements, bpmnFactory);
|
|
124072
|
-
|
|
124073
|
-
modeling.updateModdleProperties(shape, rootExtensionElements, {
|
|
124074
|
-
values: [
|
|
124075
|
-
...(rootExtensionElements.get('values') || []),
|
|
124076
|
-
userTaskForm
|
|
124077
|
-
]
|
|
124078
|
-
});
|
|
124079
|
-
}, true);
|
|
124080
|
-
|
|
124081
|
-
|
|
124082
|
-
/**
|
|
124083
|
-
* Ensure that a user task only has one of the following:
|
|
124084
|
-
*
|
|
124085
|
-
* 1. zeebe:FormDefinition with zeebe:formId (linked Camunda form)
|
|
124086
|
-
* 2. zeebe:FormDefinition with zeebe:formKey in the format of camunda-forms:bpmn:UserTaskForm_1 (embedded Camunda form)
|
|
124087
|
-
* 3. zeebe:FormDefinition with zeebe:formKey (custom form)
|
|
124088
|
-
* 4. zeebe:FormDefinition with zeebe:externalReference (external form)
|
|
124089
|
-
*
|
|
124090
|
-
* Furthermore, ensure that:
|
|
124091
|
-
*
|
|
124092
|
-
* 1. zeebe:bindingType only exists if zeebe:formId is set (linked Camunda form)
|
|
124093
|
-
*/
|
|
124094
|
-
this.preExecute('element.updateModdleProperties', function(context) {
|
|
124095
|
-
const {
|
|
124096
|
-
moddleElement,
|
|
124097
|
-
properties
|
|
124098
|
-
} = context;
|
|
124099
|
-
|
|
124100
|
-
if (is$5(moddleElement, 'zeebe:FormDefinition')) {
|
|
124101
|
-
if ('formId' in properties) {
|
|
124102
|
-
properties.formKey = undefined;
|
|
124103
|
-
properties.externalReference = undefined;
|
|
124104
|
-
} else if ('formKey' in properties) {
|
|
124105
|
-
properties.formId = undefined;
|
|
124106
|
-
properties.externalReference = undefined;
|
|
124107
|
-
properties.bindingType = undefined;
|
|
124108
|
-
} else if ('externalReference' in properties) {
|
|
124109
|
-
properties.formId = undefined;
|
|
124110
|
-
properties.formKey = undefined;
|
|
124111
|
-
properties.bindingType = undefined;
|
|
124112
|
-
}
|
|
124113
|
-
|
|
124114
|
-
if ('bindingType' in properties && !('formId' in properties) && !moddleElement.get('formId')) {
|
|
124115
|
-
properties.externalReference = undefined;
|
|
124116
|
-
properties.formId = '';
|
|
124117
|
-
properties.formKey = undefined;
|
|
124118
|
-
}
|
|
124119
|
-
}
|
|
124120
|
-
}, true);
|
|
124121
|
-
|
|
124122
|
-
/**
|
|
124123
|
-
* Clean up user task form after form key or definition is removed. Clean up
|
|
124124
|
-
* empty extension elements after form definition is removed.
|
|
124125
|
-
*/
|
|
124126
|
-
this.postExecute('element.updateModdleProperties', function(context) {
|
|
124127
|
-
const {
|
|
124128
|
-
element,
|
|
124129
|
-
moddleElement,
|
|
124130
|
-
oldProperties
|
|
124131
|
-
} = context;
|
|
124132
|
-
|
|
124133
|
-
if (is$5(moddleElement, 'zeebe:FormDefinition')) {
|
|
124134
|
-
const formKey = moddleElement.get('formKey');
|
|
124135
|
-
|
|
124136
|
-
if (!formKey || !isUserTaskFormKey(formKey)) {
|
|
124137
|
-
const userTaskForm = getUserTaskForm(element, { formKey: oldProperties.formKey });
|
|
124138
|
-
|
|
124139
|
-
if (userTaskForm) {
|
|
124140
|
-
removeUserTaskForm(element, getRootElement$1(element), userTaskForm);
|
|
124141
|
-
}
|
|
124142
|
-
}
|
|
124143
|
-
} else if (isExtensionElementRemoved(context, 'zeebe:FormDefinition')) {
|
|
124144
|
-
const formDefinition = oldProperties.values.find(value => is$5(value, 'zeebe:FormDefinition'));
|
|
124145
|
-
|
|
124146
|
-
const userTaskForm = getUserTaskForm(element, { formKey: formDefinition.get('formKey') });
|
|
124147
|
-
|
|
124148
|
-
if (userTaskForm) {
|
|
124149
|
-
removeUserTaskForm(element, getRootElement$1(element), userTaskForm);
|
|
124150
|
-
}
|
|
124151
|
-
|
|
124152
|
-
if (!moddleElement.get('values').length) {
|
|
124153
|
-
modeling.updateProperties(element, {
|
|
124154
|
-
extensionElements: undefined
|
|
124155
|
-
});
|
|
124156
|
-
}
|
|
124157
|
-
}
|
|
124158
|
-
}, true);
|
|
124159
|
-
|
|
124160
|
-
this._registerZeebeUserTaskSupport();
|
|
124161
|
-
}
|
|
124162
|
-
|
|
124163
|
-
_registerZeebeUserTaskSupport() {
|
|
124164
|
-
|
|
124165
|
-
/**
|
|
124166
|
-
* Handle `formKey` for `zeebe:UserTask`.
|
|
124167
|
-
* 1. Remove if embedded form is used.
|
|
124168
|
-
* 2. Convert to externalReference if custom form key.
|
|
124169
|
-
*/
|
|
124170
|
-
this.postExecute('element.updateModdleProperties', ({ element }) => {
|
|
124171
|
-
|
|
124172
|
-
if (!is$5(element, 'bpmn:UserTask') || !hasZeebeUserTask(element)) {
|
|
124173
|
-
return;
|
|
124174
|
-
}
|
|
124175
|
-
|
|
124176
|
-
const formDefinition = getFormDefinition(element);
|
|
124177
|
-
|
|
124178
|
-
if (!formDefinition) {
|
|
124179
|
-
return;
|
|
124180
|
-
}
|
|
124181
|
-
|
|
124182
|
-
const formKey = formDefinition.get('formKey');
|
|
124183
|
-
|
|
124184
|
-
if (isUndefined$5(formKey)) {
|
|
124185
|
-
return;
|
|
124186
|
-
}
|
|
124187
|
-
|
|
124188
|
-
if (isUserTaskFormKey(formKey)) {
|
|
124189
|
-
this._modeling.updateModdleProperties(element, formDefinition, { formKey: undefined });
|
|
124190
|
-
} else {
|
|
124191
|
-
this._modeling.updateModdleProperties(element, formDefinition, {
|
|
124192
|
-
externalReference: formKey
|
|
124193
|
-
});
|
|
124194
|
-
}
|
|
124195
|
-
}, true);
|
|
124196
|
-
|
|
124197
|
-
/**
|
|
124198
|
-
* Replace `externalReference` with `formKey` for non-`zeebe:UserTask`.
|
|
124199
|
-
*/
|
|
124200
|
-
this.postExecute('element.updateModdleProperties', ({ element }) => {
|
|
124201
|
-
|
|
124202
|
-
if (!is$5(element, 'bpmn:UserTask') || hasZeebeUserTask(element)) {
|
|
124203
|
-
return;
|
|
124204
|
-
}
|
|
124205
|
-
|
|
124206
|
-
const formDefinition = getFormDefinition(element);
|
|
124207
|
-
|
|
124208
|
-
if (!formDefinition) {
|
|
124209
|
-
return;
|
|
124210
|
-
}
|
|
124211
|
-
|
|
124212
|
-
const externalReference = formDefinition.get('externalReference');
|
|
124213
|
-
|
|
124214
|
-
if (isUndefined$5(externalReference)) {
|
|
124215
|
-
return;
|
|
124216
|
-
}
|
|
124217
|
-
|
|
124218
|
-
this._modeling.updateModdleProperties(element, formDefinition, {
|
|
124219
|
-
externalReference: undefined,
|
|
124220
|
-
formKey: externalReference
|
|
124221
|
-
});
|
|
124222
|
-
}, true);
|
|
124223
|
-
}
|
|
124224
|
-
}
|
|
124225
|
-
|
|
124226
|
-
FormsBehavior.$inject = [
|
|
124227
|
-
'bpmnFactory',
|
|
124228
|
-
'eventBus',
|
|
124229
|
-
'modeling'
|
|
123867
|
+
const LOW_PRIORITY$1 = 250;
|
|
123868
|
+
|
|
123869
|
+
/**
|
|
123870
|
+
* Camunda-specific behavior ensuring `isExecutable` is kept after deleting
|
|
123871
|
+
* the last participant.
|
|
123872
|
+
*/
|
|
123873
|
+
class DeleteParticipantBehaviour extends CommandInterceptor$1 {
|
|
123874
|
+
constructor(eventBus, canvas, modeling) {
|
|
123875
|
+
super(eventBus);
|
|
123876
|
+
|
|
123877
|
+
this.postExecuted('shape.delete', LOW_PRIORITY$1, function(context) {
|
|
123878
|
+
const {
|
|
123879
|
+
collaborationRoot,
|
|
123880
|
+
shape
|
|
123881
|
+
} = context;
|
|
123882
|
+
|
|
123883
|
+
const newRoot = canvas.getRootElement();
|
|
123884
|
+
|
|
123885
|
+
if (is$5(shape, 'bpmn:Participant') &&
|
|
123886
|
+
collaborationRoot &&
|
|
123887
|
+
!collaborationRoot.businessObject.get('participants').length &&
|
|
123888
|
+
is$5(newRoot, 'bpmn:Process')) {
|
|
123889
|
+
|
|
123890
|
+
const oldProcessBusinessObject = shape.businessObject.get('processRef');
|
|
123891
|
+
|
|
123892
|
+
if (!oldProcessBusinessObject) {
|
|
123893
|
+
return;
|
|
123894
|
+
}
|
|
123895
|
+
|
|
123896
|
+
modeling.updateProperties(newRoot, { isExecutable: oldProcessBusinessObject.get('isExecutable') });
|
|
123897
|
+
}
|
|
123898
|
+
|
|
123899
|
+
}, true);
|
|
123900
|
+
}
|
|
123901
|
+
}
|
|
123902
|
+
|
|
123903
|
+
DeleteParticipantBehaviour.$inject = [
|
|
123904
|
+
'eventBus',
|
|
123905
|
+
'canvas',
|
|
123906
|
+
'modeling'
|
|
124230
123907
|
];
|
|
124231
123908
|
|
|
124232
|
-
|
|
124233
|
-
|
|
124234
|
-
|
|
124235
|
-
|
|
124236
|
-
|
|
124237
|
-
|
|
124238
|
-
|
|
124239
|
-
return is$5(moddleElement, 'bpmn:ExtensionElements')
|
|
124240
|
-
&& 'values' in oldProperties
|
|
124241
|
-
&& 'values' in properties
|
|
124242
|
-
&& oldProperties.values.find(value => is$5(value, type))
|
|
124243
|
-
&& !properties.values.find(value => is$5(value, type));
|
|
124244
|
-
}
|
|
124245
|
-
|
|
124246
|
-
function hasZeebeUserTask(userTask) {
|
|
124247
|
-
return getExtensionElementsList$1(userTask, 'zeebe:UserTask').length;
|
|
123909
|
+
const ids = new Ids$1([ 32, 32, 1 ]);
|
|
123910
|
+
|
|
123911
|
+
/**
|
|
123912
|
+
* Get ID with prefix.
|
|
123913
|
+
*/
|
|
123914
|
+
function getPrefixedId(prefix) {
|
|
123915
|
+
return ids.nextPrefixed(prefix);
|
|
124248
123916
|
}
|
|
124249
123917
|
|
|
124250
|
-
const
|
|
124251
|
-
|
|
124252
|
-
|
|
124253
|
-
|
|
124254
|
-
|
|
124255
|
-
|
|
124256
|
-
|
|
124257
|
-
|
|
124258
|
-
|
|
124259
|
-
|
|
124260
|
-
|
|
124261
|
-
|
|
124262
|
-
|
|
124263
|
-
|
|
124264
|
-
|
|
124265
|
-
|
|
124266
|
-
|
|
124267
|
-
|
|
124268
|
-
|
|
124269
|
-
|
|
124270
|
-
|
|
124271
|
-
|
|
124272
|
-
|
|
124273
|
-
|
|
124274
|
-
|
|
124275
|
-
|
|
124276
|
-
|
|
124277
|
-
|
|
124278
|
-
|
|
124279
|
-
|
|
124280
|
-
|
|
124281
|
-
|
|
124282
|
-
|
|
124283
|
-
|
|
124284
|
-
|
|
124285
|
-
|
|
123918
|
+
const FORM_KEY_PREFIX = 'camunda-forms:bpmn:',
|
|
123919
|
+
USER_TASK_FORM_ID_PREFIX = 'UserTaskForm_';
|
|
123920
|
+
|
|
123921
|
+
function getFormDefinition(element) {
|
|
123922
|
+
const businessObject = getBusinessObject$2(element);
|
|
123923
|
+
|
|
123924
|
+
const formDefinitions = getExtensionElementsList$1(businessObject, 'zeebe:FormDefinition');
|
|
123925
|
+
|
|
123926
|
+
return formDefinitions[ 0 ];
|
|
123927
|
+
}
|
|
123928
|
+
|
|
123929
|
+
function getUserTaskForm(element, options = {}) {
|
|
123930
|
+
let {
|
|
123931
|
+
formKey,
|
|
123932
|
+
rootElement
|
|
123933
|
+
} = options;
|
|
123934
|
+
|
|
123935
|
+
rootElement = rootElement || getRootElement$1(element);
|
|
123936
|
+
|
|
123937
|
+
if (!formKey) {
|
|
123938
|
+
const formDefinition = getFormDefinition(element);
|
|
123939
|
+
|
|
123940
|
+
if (!formDefinition) {
|
|
123941
|
+
return;
|
|
123942
|
+
}
|
|
123943
|
+
|
|
123944
|
+
formKey = formDefinition.get('formKey');
|
|
123945
|
+
}
|
|
123946
|
+
|
|
123947
|
+
const userTaskForms = getExtensionElementsList$1(rootElement, 'zeebe:UserTaskForm');
|
|
123948
|
+
|
|
123949
|
+
return userTaskForms.find(userTaskForm => {
|
|
123950
|
+
return userTaskFormIdToFormKey(userTaskForm.get('id')) === formKey;
|
|
123951
|
+
});
|
|
123952
|
+
}
|
|
123953
|
+
|
|
123954
|
+
function userTaskFormIdToFormKey(userTaskFormId) {
|
|
123955
|
+
return `${ FORM_KEY_PREFIX }${ userTaskFormId }`;
|
|
123956
|
+
}
|
|
123957
|
+
|
|
123958
|
+
function formKeyToUserTaskFormId(formKey) {
|
|
123959
|
+
return formKey.replace(FORM_KEY_PREFIX, '');
|
|
123960
|
+
}
|
|
123961
|
+
|
|
123962
|
+
function isUserTaskFormKey(formKey) {
|
|
123963
|
+
return formKey && formKey.startsWith(FORM_KEY_PREFIX);
|
|
123964
|
+
}
|
|
123965
|
+
|
|
123966
|
+
function createUserTaskFormId() {
|
|
123967
|
+
return getPrefixedId(USER_TASK_FORM_ID_PREFIX);
|
|
123968
|
+
}
|
|
123969
|
+
|
|
123970
|
+
function getRootElement$1(element) {
|
|
123971
|
+
const businessObject = getBusinessObject$2(element);
|
|
123972
|
+
|
|
123973
|
+
let parent = businessObject;
|
|
123974
|
+
|
|
123975
|
+
while (parent.$parent && !is$5(parent, 'bpmn:Process')) {
|
|
123976
|
+
parent = parent.$parent;
|
|
123977
|
+
}
|
|
123978
|
+
|
|
123979
|
+
return parent;
|
|
124286
123980
|
}
|
|
124287
123981
|
|
|
124288
|
-
|
|
124289
|
-
|
|
124290
|
-
|
|
124291
|
-
|
|
124292
|
-
|
|
124293
|
-
|
|
124294
|
-
|
|
124295
|
-
|
|
124296
|
-
|
|
124297
|
-
|
|
124298
|
-
|
|
124299
|
-
|
|
124300
|
-
|
|
124301
|
-
|
|
124302
|
-
|
|
124303
|
-
|
|
124304
|
-
|
|
124305
|
-
|
|
124306
|
-
|
|
124307
|
-
moddleElement
|
|
124308
|
-
|
|
124309
|
-
|
|
124310
|
-
|
|
124311
|
-
|
|
124312
|
-
|
|
124313
|
-
|
|
124314
|
-
|
|
124315
|
-
|
|
124316
|
-
|
|
124317
|
-
|
|
124318
|
-
|
|
124319
|
-
|
|
124320
|
-
|
|
124321
|
-
|
|
124322
|
-
|
|
124323
|
-
|
|
124324
|
-
}
|
|
124325
|
-
|
|
124326
|
-
|
|
124327
|
-
|
|
123982
|
+
/**
|
|
123983
|
+
* Zeebe BPMN specific forms behavior.
|
|
123984
|
+
*/
|
|
123985
|
+
class FormsBehavior extends CommandInterceptor$1 {
|
|
123986
|
+
constructor(bpmnFactory, elementRegistry, eventBus, modeling) {
|
|
123987
|
+
super(eventBus);
|
|
123988
|
+
|
|
123989
|
+
this._modeling = modeling;
|
|
123990
|
+
|
|
123991
|
+
function removeUserTaskForm(element, moddleElement, userTaskForm) {
|
|
123992
|
+
const extensionElements = moddleElement.get('extensionElements');
|
|
123993
|
+
|
|
123994
|
+
const values = without(extensionElements.get('values'), userTaskForm);
|
|
123995
|
+
|
|
123996
|
+
modeling.updateModdleProperties(element, extensionElements, {
|
|
123997
|
+
values
|
|
123998
|
+
});
|
|
123999
|
+
|
|
124000
|
+
if (!values.length) {
|
|
124001
|
+
modeling.updateModdleProperties(element, moddleElement, {
|
|
124002
|
+
extensionElements: undefined
|
|
124003
|
+
});
|
|
124004
|
+
}
|
|
124005
|
+
}
|
|
124006
|
+
|
|
124007
|
+
/**
|
|
124008
|
+
* Remove zeebe:UserTaskForm on user task removed.
|
|
124009
|
+
*/
|
|
124010
|
+
this.postExecute('shape.delete', function(context) {
|
|
124011
|
+
const {
|
|
124012
|
+
oldParent,
|
|
124013
|
+
shape
|
|
124014
|
+
} = context;
|
|
124015
|
+
|
|
124016
|
+
const rootElement = getRootElement$1(oldParent);
|
|
124017
|
+
|
|
124018
|
+
const userTaskForm = getUserTaskForm(shape, { rootElement });
|
|
124019
|
+
|
|
124020
|
+
if (!is$5(shape, 'bpmn:UserTask') || !userTaskForm) {
|
|
124021
|
+
return;
|
|
124022
|
+
}
|
|
124023
|
+
|
|
124024
|
+
removeUserTaskForm(shape, rootElement, userTaskForm);
|
|
124025
|
+
}, true);
|
|
124026
|
+
|
|
124027
|
+
|
|
124028
|
+
/**
|
|
124029
|
+
* Create and reference new zeebe:UserTaskForm when user task is created
|
|
124030
|
+
* that references existing zeebe:UserTaskForm that is already referenced by
|
|
124031
|
+
* existing user task.
|
|
124032
|
+
*/
|
|
124033
|
+
this.postExecute('shape.create', function(context) {
|
|
124034
|
+
const { shape } = context;
|
|
124035
|
+
|
|
124036
|
+
if (!is$5(shape, 'bpmn:UserTask')) {
|
|
124037
|
+
return;
|
|
124038
|
+
}
|
|
124039
|
+
|
|
124040
|
+
const oldFormDefinition = getFormDefinition(shape);
|
|
124041
|
+
|
|
124042
|
+
if (!oldFormDefinition) {
|
|
124043
|
+
return;
|
|
124044
|
+
}
|
|
124045
|
+
|
|
124046
|
+
const oldUserTaskForm = getUserTaskForm(shape);
|
|
124047
|
+
|
|
124048
|
+
if (!oldUserTaskForm) {
|
|
124049
|
+
return;
|
|
124050
|
+
}
|
|
124051
|
+
|
|
124052
|
+
const isReferenced = elementRegistry.filter(element => {
|
|
124053
|
+
if (element === shape) {
|
|
124054
|
+
return false;
|
|
124055
|
+
}
|
|
124056
|
+
|
|
124057
|
+
const formDefinition = getFormDefinition(element);
|
|
124058
|
+
|
|
124059
|
+
return formDefinition
|
|
124060
|
+
&& formDefinition.get('formKey')
|
|
124061
|
+
&& formKeyToUserTaskFormId(formDefinition.get('formKey')) === oldUserTaskForm.get('id');
|
|
124062
|
+
});
|
|
124063
|
+
|
|
124064
|
+
if (!isReferenced.length) {
|
|
124065
|
+
return;
|
|
124066
|
+
}
|
|
124067
|
+
|
|
124068
|
+
const rootElement = getRootElement$1(shape);
|
|
124069
|
+
|
|
124070
|
+
let extensionElements = rootElement.get('extensionElements');
|
|
124071
|
+
|
|
124072
|
+
// (1) ensure extension elements exist
|
|
124073
|
+
if (!extensionElements) {
|
|
124074
|
+
extensionElements = createElement$2('bpmn:ExtensionElements', {
|
|
124075
|
+
values: []
|
|
124076
|
+
}, rootElement, bpmnFactory);
|
|
124077
|
+
|
|
124078
|
+
modeling.updateModdleProperties(shape, rootElement, {
|
|
124079
|
+
extensionElements
|
|
124080
|
+
});
|
|
124081
|
+
}
|
|
124082
|
+
|
|
124083
|
+
// (2) create new user task form
|
|
124084
|
+
const userTaskFormId = createUserTaskFormId();
|
|
124085
|
+
|
|
124086
|
+
const userTaskForm = createElement$2('zeebe:UserTaskForm', {
|
|
124087
|
+
id: userTaskFormId,
|
|
124088
|
+
body: oldUserTaskForm.get('body')
|
|
124089
|
+
}, extensionElements, bpmnFactory);
|
|
124090
|
+
|
|
124091
|
+
modeling.updateModdleProperties(shape, extensionElements, {
|
|
124092
|
+
values: [
|
|
124093
|
+
...(extensionElements.get('values') || []),
|
|
124094
|
+
userTaskForm
|
|
124095
|
+
]
|
|
124096
|
+
});
|
|
124097
|
+
|
|
124098
|
+
// (3) reference new user task form
|
|
124099
|
+
modeling.updateModdleProperties(shape, oldFormDefinition, {
|
|
124100
|
+
formKey: userTaskFormIdToFormKey(userTaskFormId)
|
|
124101
|
+
});
|
|
124102
|
+
}, true);
|
|
124103
|
+
|
|
124104
|
+
|
|
124105
|
+
/**
|
|
124106
|
+
* Ensure that a user task only has one of the following:
|
|
124107
|
+
*
|
|
124108
|
+
* 1. zeebe:FormDefinition with zeebe:formId (linked Camunda form)
|
|
124109
|
+
* 2. zeebe:FormDefinition with zeebe:formKey in the format of camunda-forms:bpmn:UserTaskForm_1 (embedded Camunda form)
|
|
124110
|
+
* 3. zeebe:FormDefinition with zeebe:formKey (custom form)
|
|
124111
|
+
* 4. zeebe:FormDefinition with zeebe:externalReference (external form)
|
|
124112
|
+
*
|
|
124113
|
+
* Furthermore, ensure that:
|
|
124114
|
+
*
|
|
124115
|
+
* 1. zeebe:bindingType only exists if zeebe:formId is set (linked Camunda form)
|
|
124116
|
+
*/
|
|
124117
|
+
this.preExecute('element.updateModdleProperties', function(context) {
|
|
124118
|
+
const {
|
|
124119
|
+
moddleElement,
|
|
124120
|
+
properties
|
|
124121
|
+
} = context;
|
|
124122
|
+
|
|
124123
|
+
if (is$5(moddleElement, 'zeebe:FormDefinition')) {
|
|
124124
|
+
if ('formId' in properties) {
|
|
124125
|
+
properties.formKey = undefined;
|
|
124126
|
+
properties.externalReference = undefined;
|
|
124127
|
+
} else if ('formKey' in properties) {
|
|
124128
|
+
properties.formId = undefined;
|
|
124129
|
+
properties.externalReference = undefined;
|
|
124130
|
+
properties.bindingType = undefined;
|
|
124131
|
+
} else if ('externalReference' in properties) {
|
|
124132
|
+
properties.formId = undefined;
|
|
124133
|
+
properties.formKey = undefined;
|
|
124134
|
+
properties.bindingType = undefined;
|
|
124135
|
+
}
|
|
124136
|
+
|
|
124137
|
+
if ('bindingType' in properties && !('formId' in properties) && !moddleElement.get('formId')) {
|
|
124138
|
+
properties.externalReference = undefined;
|
|
124139
|
+
properties.formId = '';
|
|
124140
|
+
properties.formKey = undefined;
|
|
124141
|
+
}
|
|
124142
|
+
}
|
|
124143
|
+
}, true);
|
|
124144
|
+
|
|
124145
|
+
/**
|
|
124146
|
+
* Clean up user task form after form key or definition is removed. Clean up
|
|
124147
|
+
* empty extension elements after form definition is removed.
|
|
124148
|
+
*/
|
|
124149
|
+
this.postExecute('element.updateModdleProperties', function(context) {
|
|
124150
|
+
const {
|
|
124151
|
+
element,
|
|
124152
|
+
moddleElement,
|
|
124153
|
+
oldProperties
|
|
124154
|
+
} = context;
|
|
124155
|
+
|
|
124156
|
+
if (is$5(moddleElement, 'zeebe:FormDefinition')) {
|
|
124157
|
+
const formKey = moddleElement.get('formKey');
|
|
124158
|
+
|
|
124159
|
+
if (!formKey || !isUserTaskFormKey(formKey)) {
|
|
124160
|
+
const userTaskForm = getUserTaskForm(element, { formKey: oldProperties.formKey });
|
|
124161
|
+
|
|
124162
|
+
if (userTaskForm) {
|
|
124163
|
+
removeUserTaskForm(element, getRootElement$1(element), userTaskForm);
|
|
124164
|
+
}
|
|
124165
|
+
}
|
|
124166
|
+
} else if (isExtensionElementRemoved(context, 'zeebe:FormDefinition')) {
|
|
124167
|
+
const formDefinition = oldProperties.values.find(value => is$5(value, 'zeebe:FormDefinition'));
|
|
124168
|
+
|
|
124169
|
+
const userTaskForm = getUserTaskForm(element, { formKey: formDefinition.get('formKey') });
|
|
124170
|
+
|
|
124171
|
+
if (userTaskForm) {
|
|
124172
|
+
removeUserTaskForm(element, getRootElement$1(element), userTaskForm);
|
|
124173
|
+
}
|
|
124174
|
+
|
|
124175
|
+
if (!moddleElement.get('values').length) {
|
|
124176
|
+
modeling.updateProperties(element, {
|
|
124177
|
+
extensionElements: undefined
|
|
124178
|
+
});
|
|
124179
|
+
}
|
|
124180
|
+
}
|
|
124181
|
+
}, true);
|
|
124182
|
+
|
|
124183
|
+
this._registerZeebeUserTaskSupport();
|
|
124184
|
+
}
|
|
124185
|
+
|
|
124186
|
+
_registerZeebeUserTaskSupport() {
|
|
124187
|
+
|
|
124188
|
+
/**
|
|
124189
|
+
* Handle `formKey` for `zeebe:UserTask`.
|
|
124190
|
+
* 1. Remove if embedded form is used.
|
|
124191
|
+
* 2. Convert to externalReference if custom form key.
|
|
124192
|
+
*/
|
|
124193
|
+
this.postExecute('element.updateModdleProperties', ({ element }) => {
|
|
124194
|
+
|
|
124195
|
+
if (!is$5(element, 'bpmn:UserTask') || !hasZeebeUserTask(element)) {
|
|
124196
|
+
return;
|
|
124197
|
+
}
|
|
124198
|
+
|
|
124199
|
+
const formDefinition = getFormDefinition(element);
|
|
124200
|
+
|
|
124201
|
+
if (!formDefinition) {
|
|
124202
|
+
return;
|
|
124203
|
+
}
|
|
124204
|
+
|
|
124205
|
+
const formKey = formDefinition.get('formKey');
|
|
124206
|
+
|
|
124207
|
+
if (isUndefined$5(formKey)) {
|
|
124208
|
+
return;
|
|
124209
|
+
}
|
|
124210
|
+
|
|
124211
|
+
if (isUserTaskFormKey(formKey)) {
|
|
124212
|
+
this._modeling.updateModdleProperties(element, formDefinition, { formKey: undefined });
|
|
124213
|
+
} else {
|
|
124214
|
+
this._modeling.updateModdleProperties(element, formDefinition, {
|
|
124215
|
+
externalReference: formKey
|
|
124216
|
+
});
|
|
124217
|
+
}
|
|
124218
|
+
}, true);
|
|
124219
|
+
|
|
124220
|
+
/**
|
|
124221
|
+
* Replace `externalReference` with `formKey` for non-`zeebe:UserTask`.
|
|
124222
|
+
*/
|
|
124223
|
+
this.postExecute('element.updateModdleProperties', ({ element }) => {
|
|
124224
|
+
|
|
124225
|
+
if (!is$5(element, 'bpmn:UserTask') || hasZeebeUserTask(element)) {
|
|
124226
|
+
return;
|
|
124227
|
+
}
|
|
124228
|
+
|
|
124229
|
+
const formDefinition = getFormDefinition(element);
|
|
124230
|
+
|
|
124231
|
+
if (!formDefinition) {
|
|
124232
|
+
return;
|
|
124233
|
+
}
|
|
124234
|
+
|
|
124235
|
+
const externalReference = formDefinition.get('externalReference');
|
|
124236
|
+
|
|
124237
|
+
if (isUndefined$5(externalReference)) {
|
|
124238
|
+
return;
|
|
124239
|
+
}
|
|
124240
|
+
|
|
124241
|
+
this._modeling.updateModdleProperties(element, formDefinition, {
|
|
124242
|
+
externalReference: undefined,
|
|
124243
|
+
formKey: externalReference
|
|
124244
|
+
});
|
|
124245
|
+
}, true);
|
|
124246
|
+
}
|
|
124247
|
+
}
|
|
124248
|
+
|
|
124249
|
+
FormsBehavior.$inject = [
|
|
124250
|
+
'bpmnFactory',
|
|
124251
|
+
'elementRegistry',
|
|
124252
|
+
'eventBus',
|
|
124253
|
+
'modeling'
|
|
124254
|
+
];
|
|
124255
|
+
|
|
124256
|
+
function isExtensionElementRemoved(context, type) {
|
|
124257
|
+
const {
|
|
124258
|
+
moddleElement,
|
|
124259
|
+
oldProperties,
|
|
124260
|
+
properties
|
|
124261
|
+
} = context;
|
|
124262
|
+
|
|
124263
|
+
return is$5(moddleElement, 'bpmn:ExtensionElements')
|
|
124264
|
+
&& 'values' in oldProperties
|
|
124265
|
+
&& 'values' in properties
|
|
124266
|
+
&& oldProperties.values.find(value => is$5(value, type))
|
|
124267
|
+
&& !properties.values.find(value => is$5(value, type));
|
|
124268
|
+
}
|
|
124269
|
+
|
|
124270
|
+
function hasZeebeUserTask(userTask) {
|
|
124271
|
+
return getExtensionElementsList$1(userTask, 'zeebe:UserTask').length;
|
|
124328
124272
|
}
|
|
124329
124273
|
|
|
124330
|
-
|
|
124331
|
-
|
|
124332
|
-
|
|
124274
|
+
const HIGH_PRIORITY$3 = 5000;
|
|
124275
|
+
|
|
124276
|
+
|
|
124277
|
+
/**
|
|
124278
|
+
* Zeebe BPMN behavior removing zeebe:AssignmentDefinition elements without
|
|
124279
|
+
* zeebe:assignee, zeebe:candidateGroups or zeebe:candidateUsers.
|
|
124280
|
+
*/
|
|
124281
|
+
class RemoveAssignmentDefinitionBehavior extends CommandInterceptor$1 {
|
|
124282
|
+
constructor(commandStack, eventBus) {
|
|
124283
|
+
super(eventBus);
|
|
124284
|
+
|
|
124285
|
+
this.postExecuted('element.updateModdleProperties' , HIGH_PRIORITY$3, function(context) {
|
|
124286
|
+
const {
|
|
124287
|
+
element,
|
|
124288
|
+
moddleElement
|
|
124289
|
+
} = context;
|
|
124290
|
+
|
|
124291
|
+
if (!is$5(moddleElement, 'zeebe:AssignmentDefinition')) {
|
|
124292
|
+
return;
|
|
124293
|
+
}
|
|
124294
|
+
|
|
124295
|
+
const assignmentDefinition = moddleElement;
|
|
124296
|
+
|
|
124297
|
+
if (
|
|
124298
|
+
is$5(element, 'bpmn:UserTask')
|
|
124299
|
+
&& isUndefined$5(assignmentDefinition.get('zeebe:assignee'))
|
|
124300
|
+
&& isUndefined$5(assignmentDefinition.get('zeebe:candidateGroups'))
|
|
124301
|
+
&& isUndefined$5(assignmentDefinition.get('zeebe:candidateUsers'))
|
|
124302
|
+
) {
|
|
124303
|
+
const businessObject = getBusinessObject$2(element);
|
|
124304
|
+
|
|
124305
|
+
removeExtensionElements(element, businessObject, assignmentDefinition, commandStack);
|
|
124306
|
+
}
|
|
124307
|
+
}, true);
|
|
124308
|
+
|
|
124309
|
+
}
|
|
124310
|
+
}
|
|
124311
|
+
|
|
124312
|
+
RemoveAssignmentDefinitionBehavior.$inject = [
|
|
124313
|
+
'commandStack',
|
|
124314
|
+
'eventBus'
|
|
124333
124315
|
];
|
|
124334
124316
|
|
|
124335
|
-
|
|
124336
|
-
|
|
124337
|
-
|
|
124338
|
-
|
|
124339
|
-
|
|
124340
|
-
|
|
124341
|
-
|
|
124342
|
-
|
|
124343
|
-
|
|
124344
|
-
|
|
124345
|
-
|
|
124346
|
-
|
|
124347
|
-
|
|
124348
|
-
|
|
124349
|
-
moddleElement
|
|
124350
|
-
|
|
124351
|
-
|
|
124352
|
-
|
|
124353
|
-
|
|
124354
|
-
|
|
124355
|
-
|
|
124356
|
-
|
|
124357
|
-
|
|
124358
|
-
|
|
124359
|
-
|
|
124360
|
-
|
|
124361
|
-
|
|
124362
|
-
|
|
124363
|
-
|
|
124364
|
-
|
|
124365
|
-
|
|
124366
|
-
}
|
|
124367
|
-
|
|
124368
|
-
|
|
124369
|
-
|
|
124370
|
-
|
|
124371
|
-
|
|
124372
|
-
|
|
124373
|
-
|
|
124374
|
-
|
|
124375
|
-
* Remove `zeebe:VersionTag` if its value is empty.
|
|
124376
|
-
*/
|
|
124377
|
-
this.postExecuted('element.updateModdleProperties', function(context) {
|
|
124378
|
-
const {
|
|
124379
|
-
element,
|
|
124380
|
-
moddleElement
|
|
124381
|
-
} = context;
|
|
124382
|
-
|
|
124383
|
-
if (!is$5(moddleElement, 'zeebe:VersionTag')) {
|
|
124384
|
-
return;
|
|
124385
|
-
}
|
|
124386
|
-
|
|
124387
|
-
if (isEmpty$1(moddleElement.get('value'))) {
|
|
124388
|
-
removeExtensionElements(element, getBusinessObject$2(element), moddleElement, commandStack);
|
|
124389
|
-
}
|
|
124390
|
-
}, true);
|
|
124391
|
-
}
|
|
124392
|
-
}
|
|
124393
|
-
|
|
124394
|
-
VersionTagBehavior.$inject = [
|
|
124395
|
-
'eventBus',
|
|
124396
|
-
'commandStack'
|
|
124317
|
+
const HIGH_PRIORITY$2 = 5000;
|
|
124318
|
+
|
|
124319
|
+
|
|
124320
|
+
/**
|
|
124321
|
+
* Zeebe BPMN behavior removing zeebe:TaskSchedule elements without
|
|
124322
|
+
* zeebe:dueDate and zeebe:followUpDate.
|
|
124323
|
+
*/
|
|
124324
|
+
class RemoveTaskScheduleBehavior extends CommandInterceptor$1 {
|
|
124325
|
+
constructor(commandStack, eventBus) {
|
|
124326
|
+
super(eventBus);
|
|
124327
|
+
|
|
124328
|
+
this.postExecuted('element.updateModdleProperties' , HIGH_PRIORITY$2, function(context) {
|
|
124329
|
+
const {
|
|
124330
|
+
element,
|
|
124331
|
+
moddleElement
|
|
124332
|
+
} = context;
|
|
124333
|
+
|
|
124334
|
+
if (!is$5(moddleElement, 'zeebe:TaskSchedule')) {
|
|
124335
|
+
return;
|
|
124336
|
+
}
|
|
124337
|
+
|
|
124338
|
+
const taskSchedule = moddleElement;
|
|
124339
|
+
|
|
124340
|
+
if (
|
|
124341
|
+
is$5(element, 'bpmn:UserTask')
|
|
124342
|
+
&& isUndefined$5(taskSchedule.get('zeebe:dueDate'))
|
|
124343
|
+
&& isUndefined$5(taskSchedule.get('zeebe:followUpDate'))
|
|
124344
|
+
) {
|
|
124345
|
+
const businessObject = getBusinessObject$2(element);
|
|
124346
|
+
|
|
124347
|
+
removeExtensionElements(element, businessObject, taskSchedule, commandStack);
|
|
124348
|
+
}
|
|
124349
|
+
}, true);
|
|
124350
|
+
|
|
124351
|
+
}
|
|
124352
|
+
}
|
|
124353
|
+
|
|
124354
|
+
RemoveTaskScheduleBehavior.$inject = [
|
|
124355
|
+
'commandStack',
|
|
124356
|
+
'eventBus'
|
|
124397
124357
|
];
|
|
124398
124358
|
|
|
124399
|
-
|
|
124400
|
-
|
|
124401
|
-
|
|
124402
|
-
|
|
124359
|
+
/**
|
|
124360
|
+
* Zeebe BPMN specific version tag behavior.
|
|
124361
|
+
*/
|
|
124362
|
+
class VersionTagBehavior extends CommandInterceptor$1 {
|
|
124363
|
+
constructor(eventBus, commandStack) {
|
|
124364
|
+
super(eventBus);
|
|
124365
|
+
|
|
124366
|
+
/**
|
|
124367
|
+
* Ensure that `zeebe:BindingTypeSupported` (`zeebe:CalledDecision`,
|
|
124368
|
+
* `zeebe:CalledElement` and `zeebe:FormDefinition`) only has
|
|
124369
|
+
* `zeebe:versionTag` if `zeebe:bindingType` is `versionTag`.
|
|
124370
|
+
*/
|
|
124371
|
+
this.preExecute('element.updateModdleProperties', function(context) {
|
|
124372
|
+
const {
|
|
124373
|
+
moddleElement,
|
|
124374
|
+
properties
|
|
124375
|
+
} = context;
|
|
124376
|
+
|
|
124377
|
+
if (!isAny$1(moddleElement, [
|
|
124378
|
+
'zeebe:CalledDecision',
|
|
124379
|
+
'zeebe:CalledElement',
|
|
124380
|
+
'zeebe:FormDefinition'
|
|
124381
|
+
])) {
|
|
124382
|
+
return;
|
|
124383
|
+
}
|
|
124384
|
+
|
|
124385
|
+
// unset `zeebe:versionTag` if `zeebe:bindingType` is not set to `versionTag`
|
|
124386
|
+
if ('bindingType' in properties
|
|
124387
|
+
&& properties.bindingType !== 'versionTag'
|
|
124388
|
+
&& isDefined(moddleElement.get('versionTag'))) {
|
|
124389
|
+
properties.versionTag = undefined;
|
|
124390
|
+
}
|
|
124391
|
+
|
|
124392
|
+
// set `zeebe:bindingType` to `versionTag` if `zeebe:versionTag` is set
|
|
124393
|
+
if ('versionTag' in properties && moddleElement.get('bindingType') !== 'versionTag') {
|
|
124394
|
+
properties.bindingType = 'versionTag';
|
|
124395
|
+
}
|
|
124396
|
+
}, true);
|
|
124397
|
+
|
|
124398
|
+
/**
|
|
124399
|
+
* Remove `zeebe:VersionTag` if its value is empty.
|
|
124400
|
+
*/
|
|
124401
|
+
this.postExecuted('element.updateModdleProperties', function(context) {
|
|
124402
|
+
const {
|
|
124403
|
+
element,
|
|
124404
|
+
moddleElement
|
|
124405
|
+
} = context;
|
|
124406
|
+
|
|
124407
|
+
if (!is$5(moddleElement, 'zeebe:VersionTag')) {
|
|
124408
|
+
return;
|
|
124409
|
+
}
|
|
124410
|
+
|
|
124411
|
+
if (isEmpty$1(moddleElement.get('value'))) {
|
|
124412
|
+
removeExtensionElements(element, getBusinessObject$2(element), moddleElement, commandStack);
|
|
124413
|
+
}
|
|
124414
|
+
}, true);
|
|
124415
|
+
}
|
|
124416
|
+
}
|
|
124417
|
+
|
|
124418
|
+
VersionTagBehavior.$inject = [
|
|
124419
|
+
'eventBus',
|
|
124420
|
+
'commandStack'
|
|
124421
|
+
];
|
|
124422
|
+
|
|
124423
|
+
// helpers //////////
|
|
124424
|
+
|
|
124425
|
+
function isEmpty$1(value) {
|
|
124426
|
+
return value == undefined || value === '';
|
|
124403
124427
|
}
|
|
124404
124428
|
|
|
124405
|
-
var behaviorsModule = {
|
|
124406
|
-
__init__: [
|
|
124407
|
-
'cleanUpBusinessRuleTaskBehavior',
|
|
124408
|
-
'cleanUpEndEventBehavior',
|
|
124409
|
-
'cleanUpExecutionListenersBehavior',
|
|
124410
|
-
'cleanUpTaskListenersBehavior',
|
|
124411
|
-
'cleanUpSubscriptionBehavior',
|
|
124412
|
-
'cleanUpTimerExpressionBehavior',
|
|
124413
|
-
'copyPasteBehavior',
|
|
124414
|
-
'createZeebeCallActivityBehavior',
|
|
124415
|
-
'deleteParticipantBehaviour',
|
|
124416
|
-
'formsBehavior',
|
|
124417
|
-
'removeAssignmentDefinitionBehavior',
|
|
124418
|
-
'removeTaskScheduleBehavior',
|
|
124419
|
-
'versionTagBehavior'
|
|
124420
|
-
],
|
|
124421
|
-
cleanUpBusinessRuleTaskBehavior: [ 'type', CleanUpBusinessRuleTaskBehavior ],
|
|
124422
|
-
cleanUpEndEventBehavior: [ 'type', CleanUpEndEventBehavior ],
|
|
124423
|
-
cleanUpExecutionListenersBehavior: [ 'type', CleanUpExecutionListenersBehavior ],
|
|
124424
|
-
cleanUpTaskListenersBehavior: [ 'type', CleanUpTaskListenersBehavior ],
|
|
124425
|
-
cleanUpSubscriptionBehavior: [ 'type', CleanUpSubscriptionBehavior ],
|
|
124426
|
-
cleanUpTimerExpressionBehavior: [ 'type', CleanUpTimerExpressionBehavior ],
|
|
124427
|
-
copyPasteBehavior: [ 'type', ZeebeModdleExtension ],
|
|
124428
|
-
createZeebeCallActivityBehavior: [ 'type', CreateZeebeCallActivityBehavior ],
|
|
124429
|
-
deleteParticipantBehaviour: [ 'type', DeleteParticipantBehaviour ],
|
|
124430
|
-
formsBehavior: [ 'type', FormsBehavior ],
|
|
124431
|
-
removeAssignmentDefinitionBehavior: [ 'type', RemoveAssignmentDefinitionBehavior ],
|
|
124432
|
-
removeTaskScheduleBehavior: [ 'type', RemoveTaskScheduleBehavior ],
|
|
124433
|
-
versionTagBehavior: [ 'type', VersionTagBehavior ]
|
|
124429
|
+
var behaviorsModule = {
|
|
124430
|
+
__init__: [
|
|
124431
|
+
'cleanUpBusinessRuleTaskBehavior',
|
|
124432
|
+
'cleanUpEndEventBehavior',
|
|
124433
|
+
'cleanUpExecutionListenersBehavior',
|
|
124434
|
+
'cleanUpTaskListenersBehavior',
|
|
124435
|
+
'cleanUpSubscriptionBehavior',
|
|
124436
|
+
'cleanUpTimerExpressionBehavior',
|
|
124437
|
+
'copyPasteBehavior',
|
|
124438
|
+
'createZeebeCallActivityBehavior',
|
|
124439
|
+
'deleteParticipantBehaviour',
|
|
124440
|
+
'formsBehavior',
|
|
124441
|
+
'removeAssignmentDefinitionBehavior',
|
|
124442
|
+
'removeTaskScheduleBehavior',
|
|
124443
|
+
'versionTagBehavior'
|
|
124444
|
+
],
|
|
124445
|
+
cleanUpBusinessRuleTaskBehavior: [ 'type', CleanUpBusinessRuleTaskBehavior ],
|
|
124446
|
+
cleanUpEndEventBehavior: [ 'type', CleanUpEndEventBehavior ],
|
|
124447
|
+
cleanUpExecutionListenersBehavior: [ 'type', CleanUpExecutionListenersBehavior ],
|
|
124448
|
+
cleanUpTaskListenersBehavior: [ 'type', CleanUpTaskListenersBehavior ],
|
|
124449
|
+
cleanUpSubscriptionBehavior: [ 'type', CleanUpSubscriptionBehavior ],
|
|
124450
|
+
cleanUpTimerExpressionBehavior: [ 'type', CleanUpTimerExpressionBehavior ],
|
|
124451
|
+
copyPasteBehavior: [ 'type', ZeebeModdleExtension ],
|
|
124452
|
+
createZeebeCallActivityBehavior: [ 'type', CreateZeebeCallActivityBehavior ],
|
|
124453
|
+
deleteParticipantBehaviour: [ 'type', DeleteParticipantBehaviour ],
|
|
124454
|
+
formsBehavior: [ 'type', FormsBehavior ],
|
|
124455
|
+
removeAssignmentDefinitionBehavior: [ 'type', RemoveAssignmentDefinitionBehavior ],
|
|
124456
|
+
removeTaskScheduleBehavior: [ 'type', RemoveTaskScheduleBehavior ],
|
|
124457
|
+
versionTagBehavior: [ 'type', VersionTagBehavior ]
|
|
124434
124458
|
};
|
|
124435
124459
|
|
|
124436
124460
|
/**
|