camunda-bpmn-js 5.1.0 → 5.2.1

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