camunda-bpmn-js 0.11.2 → 0.12.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (27) hide show
  1. package/CHANGELOG.md +26 -0
  2. package/dist/assets/properties-panel.css +780 -0
  3. package/dist/base-modeler.development.js +383 -104
  4. package/dist/base-modeler.production.min.js +3 -3
  5. package/dist/camunda-cloud-modeler.development.js +929 -609
  6. package/dist/camunda-cloud-modeler.production.min.js +3 -3
  7. package/dist/camunda-platform-modeler.development.js +573 -375
  8. package/dist/camunda-platform-modeler.production.min.js +3 -3
  9. package/lib/camunda-cloud/features/modeling/behavior/CleanUpBusinessRuleTaskBehavior.js +112 -0
  10. package/lib/camunda-cloud/features/modeling/behavior/CreateZeebeBoundaryEventBehavior.js +51 -55
  11. package/lib/camunda-cloud/features/modeling/behavior/CreateZeebeCallActivityBehavior.js +56 -59
  12. package/lib/camunda-cloud/features/modeling/behavior/FormDefinitionBehavior.js +69 -127
  13. package/lib/camunda-cloud/features/modeling/behavior/UpdatePropagateAllChildVariablesBehavior.js +76 -128
  14. package/lib/camunda-cloud/features/modeling/behavior/index.js +3 -0
  15. package/lib/camunda-cloud/features/properties-provider/parts/implementation/InputOutput.js +21 -7
  16. package/lib/camunda-cloud/features/rules/BpmnRules.js +1 -1
  17. package/lib/camunda-cloud/helper/CalledElementHelper.js +43 -41
  18. package/lib/camunda-cloud/helper/FormsHelper.js +38 -50
  19. package/lib/camunda-cloud/helper/InputOutputHelper.js +92 -106
  20. package/lib/camunda-platform/features/modeling/behavior/DeleteErrorEventDefinitionBehavior.js +24 -47
  21. package/lib/camunda-platform/features/modeling/behavior/DeleteRetryTimeCycleBehavior.js +39 -81
  22. package/lib/camunda-platform/features/modeling/behavior/UpdateCamundaExclusiveBehavior.js +31 -65
  23. package/lib/camunda-platform/features/modeling/behavior/UpdateInputOutputBehavior.js +42 -76
  24. package/lib/camunda-platform/features/modeling/behavior/UpdateResultVariableBehavior.js +21 -26
  25. package/lib/camunda-platform/features/modeling/behavior/UserTaskFormsBehavior.js +27 -9
  26. package/lib/camunda-platform/helper/InputOutputHelper.js +29 -0
  27. package/package.json +6 -6
@@ -4512,6 +4512,14 @@
4512
4512
  return isNumber(number) ? number + 'px' : number;
4513
4513
  }
4514
4514
 
4515
+ function findRoot(element) {
4516
+ while (element.parent) {
4517
+ element = element.parent;
4518
+ }
4519
+
4520
+ return element;
4521
+ }
4522
+
4515
4523
  /**
4516
4524
  * Creates a HTML container element for a SVG element with
4517
4525
  * the given configuration
@@ -4557,6 +4565,7 @@
4557
4565
  }
4558
4566
 
4559
4567
  var BASE_LAYER = 'base';
4568
+ var HIDDEN_MARKER = 'djs-element-hidden';
4560
4569
 
4561
4570
 
4562
4571
  var REQUIRED_MODEL_ATTRS = {
@@ -4593,23 +4602,23 @@
4593
4602
  'elementRegistry'
4594
4603
  ];
4595
4604
 
4605
+ /**
4606
+ * Creates a <svg> element that is wrapped into a <div>.
4607
+ * This way we are always able to correctly figure out the size of the svg element
4608
+ * by querying the parent node.
4609
+
4610
+ * (It is not possible to get the size of a svg element cross browser @ 2014-04-01)
4596
4611
 
4612
+ * <div class="djs-container" style="width: {desired-width}, height: {desired-height}">
4613
+ * <svg width="100%" height="100%">
4614
+ * ...
4615
+ * </svg>
4616
+ * </div>
4617
+ */
4597
4618
  Canvas.prototype._init = function(config) {
4598
4619
 
4599
4620
  var eventBus = this._eventBus;
4600
4621
 
4601
- // Creates a <svg> element that is wrapped into a <div>.
4602
- // This way we are always able to correctly figure out the size of the svg element
4603
- // by querying the parent node.
4604
- //
4605
- // (It is not possible to get the size of a svg element cross browser @ 2014-04-01)
4606
- //
4607
- // <div class="djs-container" style="width: {desired-width}, height: {desired-height}">
4608
- // <svg width="100%" height="100%">
4609
- // ...
4610
- // </svg>
4611
- // </div>
4612
-
4613
4622
  // html container
4614
4623
  var container = this._container = createContainer(config);
4615
4624
 
@@ -4621,6 +4630,7 @@
4621
4630
  var viewport = this._viewport = createGroup(svg, 'viewport');
4622
4631
 
4623
4632
  this._layers = {};
4633
+ this._planes = {};
4624
4634
 
4625
4635
  // debounce canvas.viewbox.changed events
4626
4636
  // for smoother diagram interaction
@@ -4679,7 +4689,8 @@
4679
4689
  delete this._svg;
4680
4690
  delete this._container;
4681
4691
  delete this._layers;
4682
- delete this._rootElement;
4692
+ delete this._planes;
4693
+ delete this._activePlane;
4683
4694
  delete this._viewport;
4684
4695
  };
4685
4696
 
@@ -4694,12 +4705,16 @@
4694
4705
  var type = getType(element);
4695
4706
 
4696
4707
  if (type === 'root') {
4697
- self.setRootElement(null, true);
4708
+ self.setRootElementForPlane(null, self.findPlane(element), true);
4698
4709
  } else {
4699
4710
  self._removeElement(element, type);
4700
4711
  }
4701
4712
  });
4702
4713
 
4714
+ // remove all planes
4715
+ this._activePlane = null;
4716
+ this._planes = {};
4717
+
4703
4718
  // force recomputation of view box
4704
4719
  delete this._cachedViewbox;
4705
4720
  };
@@ -4711,7 +4726,7 @@
4711
4726
  * @returns {SVGElement}
4712
4727
  */
4713
4728
  Canvas.prototype.getDefaultLayer = function() {
4714
- return this.getLayer(BASE_LAYER, 0);
4729
+ return this.getLayer(BASE_LAYER);
4715
4730
  };
4716
4731
 
4717
4732
  /**
@@ -4779,6 +4794,142 @@
4779
4794
 
4780
4795
  };
4781
4796
 
4797
+ /**
4798
+ * Returns a plane that is used to draw elements on it.
4799
+ *
4800
+ * @param {string} name
4801
+ *
4802
+ * @return {Object} plane descriptor with { layer, rootElement, name }
4803
+ */
4804
+ Canvas.prototype.getPlane = function(name) {
4805
+ if (!name) {
4806
+ throw new Error('must specify a name');
4807
+ }
4808
+
4809
+ var plane = this._planes[name];
4810
+
4811
+ return plane;
4812
+ };
4813
+
4814
+ /**
4815
+ * Creates a plane that is used to draw elements on it. If no
4816
+ * root element is provided, an implicit root will be used.
4817
+ *
4818
+ * @param {string} name
4819
+ * @param {Object|djs.model.Root} [rootElement] optional root element
4820
+ *
4821
+ * @return {Object} plane descriptor with { layer, rootElement, name }
4822
+ */
4823
+ Canvas.prototype.createPlane = function(name, rootElement) {
4824
+ if (!name) {
4825
+ throw new Error('must specify a name');
4826
+ }
4827
+
4828
+ if (this._planes[name]) {
4829
+ throw new Error('plane ' + name + ' already exists');
4830
+ }
4831
+
4832
+ if (!rootElement) {
4833
+ rootElement = {
4834
+ id: '__implicitroot' + name,
4835
+ children: [],
4836
+ isImplicit: true
4837
+ };
4838
+ }
4839
+
4840
+ var svgLayer = this.getLayer(name);
4841
+ classes$1(svgLayer).add(HIDDEN_MARKER);
4842
+
4843
+ var plane = this._planes[name] = {
4844
+ layer: svgLayer,
4845
+ name: name,
4846
+ rootElement: null
4847
+ };
4848
+
4849
+ this.setRootElementForPlane(rootElement, plane);
4850
+
4851
+ return plane;
4852
+ };
4853
+
4854
+ /**
4855
+ * Sets the active plane and hides the previously active plane.
4856
+ *
4857
+ * @param {string|Object} plane
4858
+ *
4859
+ * @return {Object} plane descriptor with { layer, rootElement, name }
4860
+ */
4861
+ Canvas.prototype.setActivePlane = function(plane) {
4862
+ if (!plane) {
4863
+ throw new Error('must specify a plane');
4864
+ }
4865
+
4866
+ if (typeof plane === 'string') {
4867
+ plane = this.getPlane(plane);
4868
+ }
4869
+
4870
+ // hide previous Plane
4871
+ if (this._activePlane) {
4872
+ classes$1(this._activePlane.layer).add(HIDDEN_MARKER);
4873
+ }
4874
+
4875
+ this._activePlane = plane;
4876
+
4877
+ // show current Plane
4878
+ classes$1(plane.layer).remove(HIDDEN_MARKER);
4879
+
4880
+ if (plane.rootElement) {
4881
+ this._elementRegistry.updateGraphics(plane.rootElement, this._svg, true);
4882
+ }
4883
+
4884
+ this._eventBus.fire('plane.set', { plane: plane });
4885
+
4886
+ return plane;
4887
+ };
4888
+
4889
+ /**
4890
+ * Returns the currently active layer
4891
+ *
4892
+ * @returns {SVGElement}
4893
+ */
4894
+
4895
+ Canvas.prototype.getActiveLayer = function() {
4896
+ return this.getActivePlane().layer;
4897
+ };
4898
+
4899
+ /**
4900
+ * Returns the currently active plane.
4901
+ *
4902
+ * @return {Object} plane descriptor with { layer, rootElement, name }
4903
+ */
4904
+ Canvas.prototype.getActivePlane = function() {
4905
+ var plane = this._activePlane;
4906
+ if (!plane) {
4907
+ plane = this.createPlane(BASE_LAYER);
4908
+ this.setActivePlane(BASE_LAYER);
4909
+ }
4910
+
4911
+ return plane;
4912
+ };
4913
+
4914
+ /**
4915
+ * Returns the plane which contains the given element.
4916
+ *
4917
+ * @param {string|djs.model.Base} element
4918
+ *
4919
+ * @return {Object} plane descriptor with { layer, rootElement, name }
4920
+ */
4921
+ Canvas.prototype.findPlane = function(element) {
4922
+ if (typeof element === 'string') {
4923
+ element = this._elementRegistry.get(element);
4924
+ }
4925
+
4926
+ var root = findRoot(element);
4927
+
4928
+ return find(this._planes, function(plane) {
4929
+ return plane.rootElement === root;
4930
+ });
4931
+ };
4932
+
4782
4933
  /**
4783
4934
  * Returns the html element that encloses the
4784
4935
  * drawing canvas.
@@ -4900,11 +5051,9 @@
4900
5051
  };
4901
5052
 
4902
5053
  Canvas.prototype.getRootElement = function() {
4903
- if (!this._rootElement) {
4904
- this.setRootElement({ id: '__implicitroot', children: [] });
4905
- }
5054
+ var plane = this.getActivePlane();
4906
5055
 
4907
- return this._rootElement;
5056
+ return plane.rootElement;
4908
5057
  };
4909
5058
 
4910
5059
 
@@ -4921,12 +5070,41 @@
4921
5070
  * @return {Object|djs.model.Root} new root element
4922
5071
  */
4923
5072
  Canvas.prototype.setRootElement = function(element, override) {
5073
+ var activePlane = this._activePlane;
5074
+
5075
+ if (activePlane) {
5076
+ return this.setRootElementForPlane(element, activePlane, override);
5077
+ } else {
5078
+ var basePlane = this.createPlane(BASE_LAYER, element);
5079
+
5080
+ this.setActivePlane(basePlane);
5081
+
5082
+ return basePlane.rootElement;
5083
+ }
5084
+ };
5085
+
5086
+
5087
+ /**
5088
+ * Sets a given element as the new root element for the canvas
5089
+ * and returns the new root element.
5090
+ *
5091
+ * @param {Object|djs.model.Root} element
5092
+ * @param {Object|djs.model.Root} plane
5093
+ * @param {boolean} [override] whether to override the current root element, if any
5094
+ *
5095
+ * @return {Object|djs.model.Root} new root element
5096
+ */
5097
+ Canvas.prototype.setRootElementForPlane = function(element, plane, override) {
5098
+
5099
+ if (typeof plane === 'string') {
5100
+ plane = this.getPlane(plane);
5101
+ }
4924
5102
 
4925
5103
  if (element) {
4926
5104
  this._ensureValid('root', element);
4927
5105
  }
4928
5106
 
4929
- var currentRoot = this._rootElement,
5107
+ var currentRoot = plane.rootElement,
4930
5108
  elementRegistry = this._elementRegistry,
4931
5109
  eventBus = this._eventBus;
4932
5110
 
@@ -4943,23 +5121,26 @@
4943
5121
  }
4944
5122
 
4945
5123
  if (element) {
4946
- var gfx = this.getDefaultLayer();
5124
+ var gfx = plane.layer;
4947
5125
 
4948
5126
  // resemble element add event sequence
4949
5127
  eventBus.fire('root.add', { element: element });
4950
5128
 
4951
- elementRegistry.add(element, gfx, this._svg);
5129
+ elementRegistry.add(element, gfx);
4952
5130
 
4953
5131
  eventBus.fire('root.added', { element: element, gfx: gfx });
5132
+
5133
+ // associate SVG with root element when active
5134
+ if (plane === this._activePlane) {
5135
+ this._elementRegistry.updateGraphics(element, this._svg, true);
5136
+ }
4954
5137
  }
4955
5138
 
4956
- this._rootElement = element;
5139
+ plane.rootElement = element;
4957
5140
 
4958
5141
  return element;
4959
5142
  };
4960
5143
 
4961
-
4962
-
4963
5144
  // add functionality //////////////////////
4964
5145
 
4965
5146
  Canvas.prototype._ensureValid = function(type, element) {
@@ -5345,6 +5526,13 @@
5345
5526
  */
5346
5527
  Canvas.prototype.scrollToElement = function(element, padding) {
5347
5528
  var defaultPadding = 100;
5529
+
5530
+ // switch to correct Plane
5531
+ var targetPlane = this.findPlane(element);
5532
+ if (targetPlane !== this._activePlane) {
5533
+ this.setActivePlane(targetPlane);
5534
+ }
5535
+
5348
5536
  if (!padding) {
5349
5537
  padding = {};
5350
5538
  }
@@ -5365,7 +5553,7 @@
5365
5553
  zoom = this.zoom(),
5366
5554
  dx, dy;
5367
5555
 
5368
- // Shrink viewboxBounds with padding
5556
+ // shrink viewboxBounds with padding
5369
5557
  viewboxBounds.y += padding.top / zoom;
5370
5558
  viewboxBounds.x += padding.left / zoom;
5371
5559
  viewboxBounds.width -= (padding.right + padding.left) / zoom;
@@ -5687,6 +5875,29 @@
5687
5875
  this.add(element, gfx, secondaryGfx);
5688
5876
  };
5689
5877
 
5878
+ /**
5879
+ * Update the graphics of an element
5880
+ *
5881
+ * @param {djs.model.Base} element
5882
+ * @param {SVGElement} gfx
5883
+ * @param {boolean} [secondary=false] whether to update the secondary connected element
5884
+ */
5885
+ ElementRegistry.prototype.updateGraphics = function(filter, gfx, secondary) {
5886
+ var id = filter.id || filter;
5887
+
5888
+ var container = this._elements[id];
5889
+
5890
+ if (secondary) {
5891
+ container.secondaryGfx = gfx;
5892
+ } else {
5893
+ container.gfx = gfx;
5894
+ }
5895
+
5896
+ attr$1(gfx, ELEMENT_ID, id);
5897
+
5898
+ return gfx;
5899
+ };
5900
+
5690
5901
  /**
5691
5902
  * Return the model element for a given id or graphics.
5692
5903
  *
@@ -6792,12 +7003,11 @@
6792
7003
  if (returnValue === false) {
6793
7004
  event.preventDefault();
6794
7005
  }
6795
- } catch (e) {
6796
- if (!this.handleError(e)) {
6797
- console.error('unhandled error in event listener');
6798
- console.error(e.stack);
7006
+ } catch (error) {
7007
+ if (!this.handleError(error)) {
7008
+ console.error('unhandled error in event listener', error);
6799
7009
 
6800
- throw e;
7010
+ throw error;
6801
7011
  }
6802
7012
  }
6803
7013
 
@@ -19511,8 +19721,8 @@
19511
19721
 
19512
19722
  // helpers //////////////////////
19513
19723
 
19514
- // copied from https://github.com/adobe-webplatform/Snap.svg/blob/master/src/svg.js
19515
- var tokenRegex = /\{([^}]+)\}/g,
19724
+ // copied and adjusted from https://github.com/adobe-webplatform/Snap.svg/blob/master/src/svg.js
19725
+ var tokenRegex = /\{([^{}]+)\}/g,
19516
19726
  objNotationRegex = /(?:(?:^|\.)(.+?)(?=\[|\.|$|\()|\[('|")(.+?)\2\])(\(\))?/g; // matches .xxxxx or ["xxxxx"] to run over object properties
19517
19727
 
19518
19728
  function replacer(all, key, obj) {
@@ -20741,9 +20951,10 @@
20741
20951
  *
20742
20952
  * @param {EventBus} eventBus the event bus
20743
20953
  */
20744
- function Selection(eventBus) {
20954
+ function Selection(eventBus, canvas) {
20745
20955
 
20746
20956
  this._eventBus = eventBus;
20957
+ this._canvas = canvas;
20747
20958
 
20748
20959
  this._selectedElements = [];
20749
20960
 
@@ -20754,12 +20965,12 @@
20754
20965
  self.deselect(element);
20755
20966
  });
20756
20967
 
20757
- eventBus.on([ 'diagram.clear' ], function(e) {
20968
+ eventBus.on([ 'diagram.clear', 'plane.set' ], function(e) {
20758
20969
  self.select(null);
20759
20970
  });
20760
20971
  }
20761
20972
 
20762
- Selection.$inject = [ 'eventBus' ];
20973
+ Selection.$inject = [ 'eventBus', 'canvas' ];
20763
20974
 
20764
20975
 
20765
20976
  Selection.prototype.deselect = function(element) {
@@ -20805,6 +21016,14 @@
20805
21016
  elements = elements ? [ elements ] : [];
20806
21017
  }
20807
21018
 
21019
+ var canvas = this._canvas;
21020
+
21021
+ elements = elements.filter(function(element) {
21022
+ var plane = canvas.findPlane(element);
21023
+
21024
+ return plane === canvas.getActivePlane();
21025
+ });
21026
+
20808
21027
  // selection may be cleared by passing an empty array or null
20809
21028
  // to the method
20810
21029
  if (add) {
@@ -21473,6 +21692,13 @@
21473
21692
  classes(htmlContainer).add('djs-overlay-' + overlay.type);
21474
21693
  }
21475
21694
 
21695
+ var plane = this._canvas.findPlane(element);
21696
+ var activePlane = this._canvas.getActivePlane();
21697
+ overlay.plane = plane;
21698
+ if (plane !== activePlane) {
21699
+ setVisible(htmlContainer, false);
21700
+ }
21701
+
21476
21702
  overlay.htmlContainer = htmlContainer;
21477
21703
 
21478
21704
  overlayContainer.overlays.push(overlay);
@@ -21626,6 +21852,12 @@
21626
21852
  });
21627
21853
 
21628
21854
 
21855
+ eventBus.on('plane.set', function(e) {
21856
+ forEach(self._overlays, function(el) {
21857
+ setVisible(el.htmlContainer, el.plane === e.plane);
21858
+ });
21859
+ });
21860
+
21629
21861
  // clear overlays with diagram
21630
21862
 
21631
21863
  eventBus.on('diagram.clear', this.clear, this);
@@ -21775,8 +22007,9 @@
21775
22007
  var KEYDOWN_EVENT = 'keyboard.keydown',
21776
22008
  KEYUP_EVENT = 'keyboard.keyup';
21777
22009
 
21778
- var DEFAULT_PRIORITY$1 = 1000;
22010
+ var HANDLE_MODIFIER_ATTRIBUTE = 'input-handle-modified-keys';
21779
22011
 
22012
+ var DEFAULT_PRIORITY$1 = 1000;
21780
22013
 
21781
22014
  /**
21782
22015
  * A keyboard abstraction that may be activated and
@@ -21847,10 +22080,9 @@
21847
22080
  };
21848
22081
 
21849
22082
  Keyboard.prototype._keyHandler = function(event, type) {
21850
- var target = event.target,
21851
- eventBusResult;
22083
+ var eventBusResult;
21852
22084
 
21853
- if (isInput(target)) {
22085
+ if (this._isEventIgnored(event)) {
21854
22086
  return;
21855
22087
  }
21856
22088
 
@@ -21865,6 +22097,29 @@
21865
22097
  }
21866
22098
  };
21867
22099
 
22100
+ Keyboard.prototype._isEventIgnored = function(event) {
22101
+ return isInput(event.target) && this._isModifiedKeyIgnored(event);
22102
+ };
22103
+
22104
+ Keyboard.prototype._isModifiedKeyIgnored = function(event) {
22105
+ if (!isCmd(event)) {
22106
+ return true;
22107
+ }
22108
+
22109
+ var allowedModifiers = this._getAllowedModifiers(event.target);
22110
+ return !allowedModifiers.includes(event.key);
22111
+ };
22112
+
22113
+ Keyboard.prototype._getAllowedModifiers = function(element) {
22114
+ var modifierContainer = closest(element, '[' + HANDLE_MODIFIER_ATTRIBUTE + ']', true);
22115
+
22116
+ if (!modifierContainer || (this._node && !this._node.contains(modifierContainer))) {
22117
+ return [];
22118
+ }
22119
+
22120
+ return modifierContainer.getAttribute(HANDLE_MODIFIER_ATTRIBUTE).split(',');
22121
+ };
22122
+
21868
22123
  Keyboard.prototype.bind = function(node) {
21869
22124
 
21870
22125
  // make sure that the keyboard is only bound once to the DOM
@@ -25857,7 +26112,7 @@
25857
26112
  /**
25858
26113
  * Executes the alignment of a selection of elements
25859
26114
  *
25860
- * @param {Array} elements [description]
26115
+ * @param {Array} elements
25861
26116
  * @param {string} type left|right|center|top|bottom|middle
25862
26117
  */
25863
26118
  AlignElements.prototype.trigger = function(elements, type) {
@@ -30350,7 +30605,7 @@
30350
30605
 
30351
30606
  classes$1(gfx).add(MARKER_CONNECTION_PREVIEW);
30352
30607
 
30353
- append(this._canvas.getDefaultLayer(), gfx);
30608
+ append(this._canvas.getActiveLayer(), gfx);
30354
30609
 
30355
30610
  return gfx;
30356
30611
  };
@@ -32067,13 +32322,13 @@
32067
32322
  dragGroup = context.dragGroup = createDragGroup(elements);
32068
32323
  }
32069
32324
 
32070
- var defaultLayer;
32325
+ var activeLayer;
32071
32326
 
32072
32327
  if (hover) {
32073
32328
  if (!dragGroup.parentNode) {
32074
- defaultLayer = canvas.getDefaultLayer();
32329
+ activeLayer = canvas.getActiveLayer();
32075
32330
 
32076
- append(defaultLayer, dragGroup);
32331
+ append(activeLayer, dragGroup);
32077
32332
  }
32078
32333
 
32079
32334
  translate(dragGroup, event.x, event.y);
@@ -33749,11 +34004,16 @@
33749
34004
 
33750
34005
  var propertyDescriptor = this._moddle.getPropertyDescriptor(parent, propertyName);
33751
34006
 
33752
- // do NOT copy Ids and references
33753
- if (propertyDescriptor.isId || propertyDescriptor.isReference) {
34007
+ // do NOT copy references
34008
+ if (propertyDescriptor.isReference) {
33754
34009
  return;
33755
34010
  }
33756
34011
 
34012
+ // copy id
34013
+ if (propertyDescriptor.isId) {
34014
+ return this._copyId(property, parent);
34015
+ }
34016
+
33757
34017
  // copy arrays
33758
34018
  if (isArray(property)) {
33759
34019
  return reduce(property, function(childProperties, childProperty) {
@@ -33792,6 +34052,18 @@
33792
34052
  return property;
33793
34053
  };
33794
34054
 
34055
+ ModdleCopy.prototype._copyId = function(id, element) {
34056
+
34057
+ // disallow if already taken
34058
+ if (this._moddle.ids.assigned(id)) {
34059
+ return;
34060
+ } else {
34061
+
34062
+ this._moddle.ids.claim(id, element);
34063
+ return id;
34064
+ }
34065
+ };
34066
+
33795
34067
  // helpers //////////
33796
34068
 
33797
34069
  function getPropertyNames(descriptor, keepDefaultProperties) {
@@ -36541,8 +36813,8 @@
36541
36813
  /**
36542
36814
  * Distributes the elements with a given orientation
36543
36815
  *
36544
- * @param {Array} elements [description]
36545
- * @param {string} orientation [description]
36816
+ * @param {Array} elements
36817
+ * @param {string} orientation
36546
36818
  */
36547
36819
  DistributeElements.prototype.trigger = function(elements, orientation) {
36548
36820
  var modeling = this._modeling;
@@ -36676,11 +36948,11 @@
36676
36948
  /**
36677
36949
  * Returns the min and max values for an element
36678
36950
  *
36679
- * @param {[type]} element [description]
36680
- * @param {[type]} axis [description]
36681
- * @param {[type]} dimension [description]
36951
+ * @param {Bounds} element
36952
+ * @param {string} axis
36953
+ * @param {string} dimension
36682
36954
  *
36683
- * @return {[type]} [description]
36955
+ * @return {{ min: number, max: number }}
36684
36956
  */
36685
36957
  DistributeElements.prototype._findRange = function(element) {
36686
36958
  var axis = element[this._axis],
@@ -38782,7 +39054,7 @@
38782
39054
  frame = context.frame;
38783
39055
 
38784
39056
  if (!frame) {
38785
- frame = context.frame = previewSupport.addFrame(shape, canvas.getDefaultLayer());
39057
+ frame = context.frame = previewSupport.addFrame(shape, canvas.getActiveLayer());
38786
39058
 
38787
39059
  canvas.addMarker(shape, MARKER_RESIZING);
38788
39060
  }
@@ -43393,6 +43665,49 @@
43393
43665
  'selection'
43394
43666
  ];
43395
43667
 
43668
+ var HIGH_PRIORITY$b = 1500;
43669
+
43670
+ var LANE_MIN_DIMENSIONS = { width: 300, height: 60 };
43671
+
43672
+ var PARTICIPANT_MIN_DIMENSIONS = { width: 300, height: 150 };
43673
+
43674
+ var SUB_PROCESS_MIN_DIMENSIONS = { width: 140, height: 120 };
43675
+
43676
+ var TEXT_ANNOTATION_MIN_DIMENSIONS = { width: 50, height: 30 };
43677
+
43678
+ /**
43679
+ * Set minimum bounds/resize constraints on resize.
43680
+ *
43681
+ * @param {EventBus} eventBus
43682
+ */
43683
+ function ResizeBehavior$1(eventBus) {
43684
+ eventBus.on('resize.start', HIGH_PRIORITY$b, function(event) {
43685
+ var context = event.context,
43686
+ shape = context.shape,
43687
+ direction = context.direction,
43688
+ balanced = context.balanced;
43689
+
43690
+ if (is$1(shape, 'bpmn:Lane') || is$1(shape, 'bpmn:Participant')) {
43691
+ context.resizeConstraints = getParticipantResizeConstraints(shape, direction, balanced);
43692
+ }
43693
+
43694
+ if (is$1(shape, 'bpmn:Participant')) {
43695
+ context.minDimensions = PARTICIPANT_MIN_DIMENSIONS;
43696
+ }
43697
+
43698
+ if (is$1(shape, 'bpmn:SubProcess') && isExpanded(shape)) {
43699
+ context.minDimensions = SUB_PROCESS_MIN_DIMENSIONS;
43700
+ }
43701
+
43702
+ if (is$1(shape, 'bpmn:TextAnnotation')) {
43703
+ context.minDimensions = TEXT_ANNOTATION_MIN_DIMENSIONS;
43704
+ }
43705
+ });
43706
+ }
43707
+
43708
+ ResizeBehavior$1.$inject = [ 'eventBus' ];
43709
+
43710
+
43396
43711
  var abs$5 = Math.abs,
43397
43712
  min$3 = Math.min,
43398
43713
  max$4 = Math.max;
@@ -43420,7 +43735,6 @@
43420
43735
  LANE_TOP_PADDING = 20,
43421
43736
  LANE_BOTTOM_PADDING = 20;
43422
43737
 
43423
-
43424
43738
  function getParticipantResizeConstraints(laneShape, resizeDirection, balanced) {
43425
43739
  var lanesRoot = getLanesRoot(laneShape);
43426
43740
 
@@ -43513,49 +43827,6 @@
43513
43827
  };
43514
43828
  }
43515
43829
 
43516
- var HIGH_PRIORITY$b = 1500;
43517
-
43518
- var LANE_MIN_DIMENSIONS = { width: 300, height: 60 };
43519
-
43520
- var PARTICIPANT_MIN_DIMENSIONS = { width: 300, height: 150 };
43521
-
43522
- var SUB_PROCESS_MIN_DIMENSIONS = { width: 140, height: 120 };
43523
-
43524
- var TEXT_ANNOTATION_MIN_DIMENSIONS = { width: 50, height: 30 };
43525
-
43526
-
43527
- /**
43528
- * Set minimum bounds/resize constraints on resize.
43529
- *
43530
- * @param {EventBus} eventBus
43531
- */
43532
- function ResizeBehavior$1(eventBus) {
43533
- eventBus.on('resize.start', HIGH_PRIORITY$b, function(event) {
43534
- var context = event.context,
43535
- shape = context.shape,
43536
- direction = context.direction,
43537
- balanced = context.balanced;
43538
-
43539
- if (is$1(shape, 'bpmn:Lane') || is$1(shape, 'bpmn:Participant')) {
43540
- context.resizeConstraints = getParticipantResizeConstraints(shape, direction, balanced);
43541
- }
43542
-
43543
- if (is$1(shape, 'bpmn:Participant')) {
43544
- context.minDimensions = PARTICIPANT_MIN_DIMENSIONS;
43545
- }
43546
-
43547
- if (is$1(shape, 'bpmn:SubProcess') && isExpanded(shape)) {
43548
- context.minDimensions = SUB_PROCESS_MIN_DIMENSIONS;
43549
- }
43550
-
43551
- if (is$1(shape, 'bpmn:TextAnnotation')) {
43552
- context.minDimensions = TEXT_ANNOTATION_MIN_DIMENSIONS;
43553
- }
43554
- });
43555
- }
43556
-
43557
- ResizeBehavior$1.$inject = [ 'eventBus' ];
43558
-
43559
43830
  var SLIGHTLY_HIGHER_PRIORITY = 1001;
43560
43831
 
43561
43832
 
@@ -47732,7 +48003,7 @@
47732
48003
  var dragGroup = create('g');
47733
48004
  attr$1(dragGroup, styles.cls('djs-drag-group', [ 'no-events' ]));
47734
48005
 
47735
- append(canvas.getDefaultLayer(), dragGroup);
48006
+ append(canvas.getActiveLayer(), dragGroup);
47736
48007
 
47737
48008
  // shapes
47738
48009
  addPreviewGfx(movingShapes, dragGroup);
@@ -47794,7 +48065,7 @@
47794
48065
  var frameGroup = create('g');
47795
48066
  attr$1(frameGroup, styles.cls('djs-frame-group', [ 'no-events' ]));
47796
48067
 
47797
- append(canvas.getDefaultLayer(), frameGroup);
48068
+ append(canvas.getActiveLayer(), frameGroup);
47798
48069
 
47799
48070
  var frames = [];
47800
48071
 
@@ -54171,9 +54442,9 @@
54171
54442
 
54172
54443
  attr$1(dragGroup, styles.cls('djs-drag-group', [ 'no-events' ]));
54173
54444
 
54174
- var defaultLayer = canvas.getDefaultLayer();
54445
+ var activeLayer = canvas.getActiveLayer();
54175
54446
 
54176
- append(defaultLayer, dragGroup);
54447
+ append(activeLayer, dragGroup);
54177
54448
 
54178
54449
  context.dragGroup = dragGroup;
54179
54450
  }
@@ -54796,7 +55067,7 @@
54796
55067
  var visuals = {
54797
55068
 
54798
55069
  create: function(context) {
54799
- var container = canvas.getDefaultLayer(),
55070
+ var container = canvas.getActiveLayer(),
54800
55071
  frame;
54801
55072
 
54802
55073
  frame = context.frame = create('rect');
@@ -65687,6 +65958,14 @@
65687
65958
  priority = DEFAULT_PRIORITY$6;
65688
65959
  }
65689
65960
 
65961
+ if (typeof provider.getTabs !== 'function') {
65962
+ console.error(
65963
+ 'Properties provider does not impement #getTabs(element) API'
65964
+ );
65965
+
65966
+ return;
65967
+ }
65968
+
65690
65969
  this._eventBus.on('propertiesPanel.getProviders', priority, function(event) {
65691
65970
  event.providers.push(provider);
65692
65971
  });
@@ -65798,7 +66077,7 @@
65798
66077
  self.detach();
65799
66078
  });
65800
66079
 
65801
- this._container = domify$2('<div class="bpp-properties-panel"></div>');
66080
+ this._container = domify$2('<div class="bpp-properties-panel" input-handle-modified-keys="z,y"></div>');
65802
66081
 
65803
66082
  this._bindListeners(this._container);
65804
66083
 
@@ -71790,78 +72069,183 @@
71790
72069
  Modeler$1.prototype._extensionModules
71791
72070
  );
71792
72071
 
71793
- const HIGH_PRIORITY$l = 15000;
72072
+ const HIGH_PRIORITY$l = 5000;
72073
+
71794
72074
 
71795
72075
  /**
71796
- * BPMN specific create zeebe boundary event behavior
72076
+ * Zeebe BPMN behavior for ensuring that a BusinessRuleTask:
72077
+ * 1) Either has a taskDefinition ExtensionElement OR
72078
+ * 2) Or has a calledDecision ExtensionElement
72079
+ * 2.1) If it has a calledDecision ExtensionElement, it shall not have taskHeaders
71797
72080
  */
71798
- function CreateZeebeBoundaryEventBehavior(
71799
- eventBus, elementFactory, bpmnFactory) {
72081
+ class CleanUpBusinessRuleTaskBehavior extends CommandInterceptor {
72082
+ constructor(eventBus, modeling) {
72083
+ super(eventBus);
71800
72084
 
71801
- CommandInterceptor.call(this, eventBus);
72085
+ /**
72086
+ * Remove zeebe:calledDecision when zeebe:taskDefinition is added
72087
+ */
72088
+ this.postExecute([
72089
+ 'properties-panel.update-businessobject-list',
72090
+ 'element.updateModdleProperties'
72091
+ ] , HIGH_PRIORITY$l, function(context) {
72092
+ const {
72093
+ element,
72094
+ currentObject,
72095
+ objectsToAdd,
72096
+ moddleElement,
72097
+ properties
72098
+ } = context;
71802
72099
 
71803
- /**
71804
- * replace intermediate catch event with boundary event when
71805
- * attaching it to a shape
71806
- */
71807
- this.preExecute('shape.create', HIGH_PRIORITY$l, function(context) {
71808
- const {
71809
- shape,
71810
- host
71811
- } = context;
72100
+ // (1) map properties from both commands
72101
+ const extensionElement = currentObject || moddleElement,
72102
+ newValues = objectsToAdd || (properties && properties.values);
71812
72103
 
71813
- const businessObject = getBusinessObject(shape);
72104
+ // (2) check conditions and potentially update
72105
+ if (
72106
+ is$1(element, 'bpmn:BusinessRuleTask')
72107
+ && extensionElement
72108
+ && is$1(extensionElement, 'bpmn:ExtensionElements')
72109
+ && extensionElement.get('values').some((ele) => is$1(ele, 'zeebe:CalledDecision'))
72110
+ && newValues
72111
+ && newValues.some((ele) => is$1(ele, 'zeebe:TaskDefinition'))
72112
+ ) {
72113
+ removeCalledDecision(element, extensionElement, modeling);
72114
+ }
72115
+ }, true);
71814
72116
 
71815
- let attrs = {
71816
- cancelActivity: true
71817
- };
72117
+ /**
72118
+ * Remove zeebe:taskDefinition and zeebe:taskHeaders when zeebe:calledDecision
72119
+ */
72120
+ this.postExecute([
72121
+ 'properties-panel.update-businessobject-list',
72122
+ 'element.updateModdleProperties'
72123
+ ] , HIGH_PRIORITY$l, function(context) {
72124
+ const {
72125
+ element,
72126
+ currentObject,
72127
+ objectsToAdd,
72128
+ moddleElement,
72129
+ properties
72130
+ } = context;
71818
72131
 
71819
- let newBusinessObject,
71820
- hostBusinessObject,
71821
- boundaryEvent,
71822
- eventDefinitions;
72132
+ // (1) map properties from both commands
72133
+ const extensionElement = currentObject || moddleElement,
72134
+ newValues = objectsToAdd || (properties && properties.values);
71823
72135
 
71824
- if (!host || !is$1(shape, 'bpmn:IntermediateCatchEvent')) {
71825
- return;
71826
- }
72136
+ // (2) check conditions and potentially update
72137
+ if (
72138
+ is$1(element, 'bpmn:BusinessRuleTask')
72139
+ && extensionElement
72140
+ && is$1(extensionElement, 'bpmn:ExtensionElements')
72141
+ && extensionElement.get('values').some(
72142
+ (ele) => is$1(ele, 'zeebe:TaskDefinition') || is$1(ele, 'zeebe:TaskHeaders'))
72143
+ && newValues
72144
+ && newValues.some((ele) => is$1(ele, 'zeebe:CalledDecision'))
72145
+ ) {
72146
+ removeTaskDefintionAndHeaders(element, extensionElement, modeling);
72147
+ }
72148
+ }, true);
71827
72149
 
71828
- hostBusinessObject = getBusinessObject(host);
72150
+ }
72151
+ }
71829
72152
 
71830
- attrs = {
71831
- attachedToRef: hostBusinessObject,
71832
- ...attrs
71833
- };
72153
+ CleanUpBusinessRuleTaskBehavior.$inject = [
72154
+ 'eventBus',
72155
+ 'modeling'
72156
+ ];
71834
72157
 
71835
- eventDefinitions = businessObject.eventDefinitions;
71836
72158
 
71837
- newBusinessObject = bpmnFactory.create('bpmn:BoundaryEvent', attrs);
72159
+ // helper ////////////////////
71838
72160
 
71839
- boundaryEvent = {
71840
- type: 'bpmn:BoundaryEvent',
71841
- businessObject: newBusinessObject,
71842
- };
72161
+ function removeFromExtensionElements(element, extensionElements, modeling, filterFun) {
72162
+ const values = extensionElements.get('values').filter(filterFun);
72163
+
72164
+ modeling.updateModdleProperties(element, extensionElements, {
72165
+ values
72166
+ });
72167
+ }
72168
+
72169
+ function removeCalledDecision(element, extensionElements, modeling) {
72170
+ removeFromExtensionElements(element, extensionElements, modeling,
72171
+ (ele) => !is$1(ele, 'zeebe:CalledDecision'));
72172
+ }
72173
+
72174
+ function removeTaskDefintionAndHeaders(element, extensionElements, modeling) {
72175
+ removeFromExtensionElements(element, extensionElements, modeling,
72176
+ (ele) => !is$1(ele, 'zeebe:TaskDefinition') && !is$1(ele, 'zeebe:TaskHeaders'));
72177
+ }
72178
+
72179
+ const HIGH_PRIORITY$m = 5000;
72180
+
72181
+
72182
+ /**
72183
+ * Zeebe BPMN specific behavior for creating boundary events.
72184
+ */
72185
+ class CreateZeebeBoundaryEventBehavior extends CommandInterceptor {
72186
+ constructor(bpmnFactory, elementFactory, eventBus) {
72187
+ super(eventBus);
72188
+
72189
+ /**
72190
+ * Replace intermediate catch event with boundary event when attaching it to a shape.
72191
+ */
72192
+ this.preExecute('shape.create', HIGH_PRIORITY$m, function(context) {
72193
+ const {
72194
+ shape,
72195
+ host
72196
+ } = context;
72197
+
72198
+ const businessObject = getBusinessObject(shape);
72199
+
72200
+ let attrs = {
72201
+ cancelActivity: true
72202
+ };
72203
+
72204
+ let newBusinessObject,
72205
+ hostBusinessObject,
72206
+ boundaryEvent,
72207
+ eventDefinitions;
72208
+
72209
+ if (!host || !is$1(shape, 'bpmn:IntermediateCatchEvent')) {
72210
+ return;
72211
+ }
72212
+
72213
+ hostBusinessObject = getBusinessObject(host);
72214
+
72215
+ attrs = {
72216
+ ...attrs,
72217
+ attachedToRef: hostBusinessObject
72218
+ };
72219
+
72220
+ eventDefinitions = businessObject.eventDefinitions;
72221
+
72222
+ newBusinessObject = bpmnFactory.create('bpmn:BoundaryEvent', attrs);
71843
72223
 
71844
- if (eventDefinitions && eventDefinitions[0]) {
71845
72224
  boundaryEvent = {
71846
- ...boundaryEvent,
71847
- eventDefinitionType: eventDefinitions[0].$type
72225
+ type: 'bpmn:BoundaryEvent',
72226
+ businessObject: newBusinessObject,
71848
72227
  };
71849
- }
71850
72228
 
71851
- context.shape = elementFactory.createShape(boundaryEvent);
72229
+ if (eventDefinitions && eventDefinitions[0]) {
72230
+ boundaryEvent = {
72231
+ ...boundaryEvent,
72232
+ eventDefinitionType: eventDefinitions[0].$type
72233
+ };
72234
+ }
72235
+
72236
+ context.shape = elementFactory.createShape(boundaryEvent);
71852
72237
 
71853
- }, true);
71854
- }
72238
+ }, true);
71855
72239
 
72240
+ }
72241
+ }
71856
72242
 
71857
72243
  CreateZeebeBoundaryEventBehavior.$inject = [
71858
- 'eventBus',
72244
+ 'bpmnFactory',
71859
72245
  'elementFactory',
71860
- 'bpmnFactory'
72246
+ 'eventBus'
71861
72247
  ];
71862
72248
 
71863
- inherits_browser(CreateZeebeBoundaryEventBehavior, CommandInterceptor);
71864
-
71865
72249
  function isZeebeServiceTask(element) {
71866
72250
  if (!is$1(element, 'zeebe:ZeebeServiceTask')) return false;
71867
72251
 
@@ -71872,6 +72256,113 @@
71872
72256
  return true;
71873
72257
  }
71874
72258
 
72259
+ /**
72260
+ * Get zeebe:IoMapping from an element.
72261
+ *
72262
+ * @param {djs.model.Base|ModdleElement} element
72263
+ *
72264
+ * @return {ModdleElement}
72265
+ */
72266
+ function getIoMapping(element) {
72267
+ const businessObject = getBusinessObject(element);
72268
+
72269
+ const extensionElements = businessObject.get('extensionElements');
72270
+
72271
+ if (!extensionElements) {
72272
+ return;
72273
+ }
72274
+
72275
+ return extensionElements.get('values').find((value) => {
72276
+ return is$1(value, 'zeebe:IoMapping');
72277
+ });
72278
+ }
72279
+
72280
+ /**
72281
+ * Get zeebe:InputParameters from an element.
72282
+ *
72283
+ * @param {djs.model.Base|ModdleElement} element
72284
+ *
72285
+ * @return {Array<ModdleElement>}
72286
+ */
72287
+ function getInputParameters(element) {
72288
+ const ioMapping = getIoMapping(element);
72289
+
72290
+ if (ioMapping) {
72291
+ return ioMapping.get('zeebe:inputParameters');
72292
+ }
72293
+
72294
+ return [];
72295
+ }
72296
+
72297
+ /**
72298
+ * Get zeebe:OutputParameters from an element.
72299
+ *
72300
+ * @param {djs.model.Base|ModdleElement} element
72301
+ *
72302
+ * @return {Array<ModdleElement>}
72303
+ */
72304
+ function getOutputParameters(element) {
72305
+ const ioMapping = getIoMapping(element);
72306
+
72307
+ if (ioMapping) {
72308
+ return ioMapping.get('zeebe:outputParameters');
72309
+ }
72310
+
72311
+ return [];
72312
+ }
72313
+
72314
+ /**
72315
+ * Check whether element supports zeebe:Input or zeebe:Output.
72316
+ *
72317
+ * @param {djs.model.Base|ModdleElement} element
72318
+ *
72319
+ * @return {boolean}
72320
+ */
72321
+ function isInputOutputSupported(element) {
72322
+ return areInputParametersSupported(element) || areOutputParametersSupported(element);
72323
+ }
72324
+
72325
+ /**
72326
+ * Check whether element supports zeebe:Input.
72327
+ *
72328
+ * @param {djs.model.Base|ModdleElement} element
72329
+ *
72330
+ * @return {boolean}
72331
+ */
72332
+ function areInputParametersSupported(element) {
72333
+ return isAny(element, [
72334
+ 'bpmn:CallActivity',
72335
+ 'bpmn:SubProcess',
72336
+ 'bpmn:UserTask'
72337
+ ]) || isZeebeServiceTask(element);
72338
+ }
72339
+
72340
+ /**
72341
+ * Check whether element supports zeebe:Output.
72342
+ *
72343
+ * @param {djs.model.Base|ModdleElement} element
72344
+ *
72345
+ * @return {boolean}
72346
+ */
72347
+ function areOutputParametersSupported(element) {
72348
+ return isAny(element, [
72349
+ 'bpmn:CallActivity',
72350
+ 'bpmn:Event',
72351
+ 'bpmn:ReceiveTask',
72352
+ 'bpmn:SubProcess',
72353
+ 'bpmn:UserTask',
72354
+ 'zeebe:ZeebeServiceTask'
72355
+ ]);
72356
+ }
72357
+
72358
+ function createElement(type, parent, factory, properties) {
72359
+ return ElementHelper_1.createElement(type, properties, parent, factory);
72360
+ }
72361
+
72362
+ function createIoMapping(parent, bpmnFactory, properties) {
72363
+ return createElement('zeebe:IoMapping', parent, bpmnFactory, properties);
72364
+ }
72365
+
71875
72366
  var is$g = require$$0.is;
71876
72367
 
71877
72368
  var ExtensionElementsHelper = {};
@@ -71922,406 +72413,223 @@
71922
72413
 
71923
72414
  var ExtensionElementsHelper_1 = ExtensionElementsHelper;
71924
72415
 
71925
- function getElements(bo, type, prop) {
71926
- const elems = ExtensionElementsHelper_1.getExtensionElements(bo, type);
71927
- return !prop ? elems : (elems[0] || {})[prop] || [];
71928
- }
71929
-
71930
- function getParameters(element, prop) {
71931
- const inputOutput = getInputOutput(element);
71932
- return (inputOutput && inputOutput.get(prop)) || [];
71933
- }
71934
-
71935
- /**
71936
- * Get a inputOutput from the business object
71937
- *
71938
- * @param {djs.model.Base} element
71939
- *
71940
- * @return {ModdleElement} the inputOutput object
71941
- */
71942
- function getInputOutput(element) {
71943
- const bo = getBusinessObject(element);
71944
- return (getElements(bo, 'zeebe:IoMapping') || [])[0];
71945
- }
71946
-
71947
-
71948
- /**
71949
- * Return all input parameters existing in the business object, and
71950
- * an empty array if none exist.
71951
- *
71952
- * @param {djs.model.Base} element
71953
- *
71954
- * @return {Array} a list of input parameter objects
71955
- */
71956
- function getInputParameters(element) {
71957
- return getParameters.apply(this, [ element, 'inputParameters' ]);
71958
- }
71959
-
71960
- /**
71961
- * Return all output parameters existing in the business object, and
71962
- * an empty array if none exist.
71963
- *
71964
- * @param {djs.model.Base} element
71965
- *
71966
- * @return {Array} a list of output parameter objects
71967
- */
71968
- function getOutputParameters(element) {
71969
- return getParameters.apply(this, [ element, 'outputParameters' ]);
71970
- }
71971
-
71972
72416
  /**
71973
- * Returns 'true' if the given element supports inputOutput
71974
- *
71975
- * @param {djs.model.Base} element
71976
- *
71977
- * @return {boolean} a boolean value
71978
- */
71979
- function isInputOutputSupported(element) {
71980
- return areOutputParametersSupported(element) || areInputParametersSupported(element);
71981
- }
71982
-
71983
- /**
71984
- * Returns 'true' if the given element supports input parameters
71985
- *
71986
- * @param {djs.model.Base} element
71987
- *
71988
- * @return {boolean} a boolean value
71989
- */
71990
- function areInputParametersSupported(element) {
71991
- return isAny(element, [
71992
- 'bpmn:UserTask',
71993
- 'bpmn:SubProcess',
71994
- 'bpmn:CallActivity'
71995
- ]) || isZeebeServiceTask(element);
71996
- }
71997
-
71998
- /**
71999
- * Returns 'true' if the given element supports output parameters
72000
- *
72001
- * @param {djs.model.Base} element
72002
- *
72003
- * @return {boolean} a boolean value
72004
- */
72005
- function areOutputParametersSupported(element) {
72006
- return isAny(element, [
72007
- 'zeebe:ZeebeServiceTask',
72008
- 'bpmn:UserTask',
72009
- 'bpmn:SubProcess',
72010
- 'bpmn:ReceiveTask',
72011
- 'bpmn:CallActivity',
72012
- 'bpmn:Event'
72013
- ]);
72014
- }
72015
-
72016
- function createElement(type, parent, factory, properties) {
72017
- return ElementHelper_1.createElement(type, properties, parent, factory);
72018
- }
72019
-
72020
- function createIOMapping(parent, bpmnFactory, properties) {
72021
- return createElement('zeebe:IoMapping', parent, bpmnFactory, properties);
72022
- }
72023
-
72024
- /**
72025
- * Get getter function for IOMapping parameters according to provided property name
72417
+ * Get default value for zeebe:propagateAllChildVariables.
72026
72418
  *
72027
- * @param {string} property
72419
+ * @param {djs.model.Base|ModdleElement} element
72028
72420
  *
72029
- * @returns {Function} Getter function for the IOMapping parameters according to provided property name
72421
+ * @returns {boolean}
72030
72422
  */
72031
- function determineParamGetFunc(property) {
72032
- if (property == 'inputParameters') {
72033
- return getInputParameters;
72423
+ function getPropagateAllChildVariablesDefault(element) {
72424
+ if (!is$1(element, 'bpmn:CallActivity')) {
72425
+ return;
72034
72426
  }
72035
72427
 
72036
- if (property == 'outputParameters') {
72037
- return getOutputParameters;
72038
- }
72039
- }
72040
-
72041
- /**
72042
- * Determine default value for propagateAllChildVariables attribute
72043
- * @param {Object} element representing a bpmn:CallActivity
72044
- *
72045
- * @returns {boolean}
72046
- */
72047
- function determinePropAllChildVariablesDefault(element) {
72048
72428
  const outputParameters = getOutputParameters(element);
72049
72429
 
72050
72430
  if (outputParameters) {
72051
- return (outputParameters.length > 0) ? false : true;
72431
+ return !outputParameters.length;
72052
72432
  }
72053
72433
  }
72054
72434
 
72055
72435
  /**
72056
- * Get the 'zeebe:CalledElement' extension element for a given business Object
72057
- * @param {Object} bo businessObject
72058
- *
72059
- * @returns {Object} the calledElement Moddle Object or undefined if zeebe:CalledElement does not exist
72060
- */
72436
+ * Get zeebe:CalledElement of an element.
72437
+ *
72438
+ * @param {djs.model.Base|ModdleElement} element
72439
+ *
72440
+ * @returns {ModdleElement}
72441
+ */
72061
72442
  function getCalledElement(element) {
72062
72443
  const calledElements = getCalledElements(element);
72063
- return calledElements[0];
72444
+
72445
+ return calledElements[ 0 ];
72064
72446
  }
72065
72447
 
72066
72448
  function getCalledElements(element) {
72067
- const bo = getBusinessObject(element);
72068
- const extElements = ExtensionElementsHelper_1.getExtensionElements(bo, 'zeebe:CalledElement');
72069
- return extElements;
72449
+ const businessObject = getBusinessObject(element);
72450
+
72451
+ return ExtensionElementsHelper_1.getExtensionElements(businessObject, 'zeebe:CalledElement');
72070
72452
  }
72071
72453
 
72072
72454
  /**
72073
- * Check whether the propagateAllChildVariables attribute is set on an element.
72074
- * Note that a default logic will be determine if it is not explicitly set.
72075
- * @param {Object} element
72076
- *
72077
- * @returns {boolean}
72078
- */
72455
+ * Check whether zeebe:propagateAllChildVariables is set on an element.
72456
+ * Fall back to default if zeebe:propagateAllChildVariables not set.
72457
+ *
72458
+ * @param {djs.model.Base|ModdleElement} element
72459
+ *
72460
+ * @returns {boolean}
72461
+ */
72079
72462
  function isPropagateAllChildVariables(element) {
72080
72463
  if (!is$1(element, 'bpmn:CallActivity')) {
72081
- return undefined;
72464
+ return;
72082
72465
  }
72083
72466
 
72084
- const bo = getBusinessObject(element),
72085
- calledElement = getCalledElement(bo);
72467
+ const businessObject = getBusinessObject(element),
72468
+ calledElement = getCalledElement(businessObject);
72086
72469
 
72087
- return calledElement && has(calledElement, 'propagateAllChildVariables') ?
72088
- calledElement.get('propagateAllChildVariables') :
72089
- determinePropAllChildVariablesDefault(element);
72470
+ if (calledElement && has(calledElement, 'propagateAllChildVariables')) {
72471
+ return calledElement.get('propagateAllChildVariables');
72472
+ } else {
72473
+ return getPropagateAllChildVariablesDefault(element);
72474
+ }
72090
72475
  }
72091
72476
 
72092
- const HIGH_PRIORITY$m = 15000;
72477
+ const HIGH_PRIORITY$n = 5000;
72478
+
72093
72479
 
72094
72480
  /**
72095
- * BPMN specific create zeebe call activity behavior
72481
+ * Zeebe BPMN specific behavior for creating call activities.
72096
72482
  */
72097
- function CreateZeebeCallActivityBehavior(
72098
- eventBus, bpmnFactory) {
72483
+ class CreateZeebeCallActivityBehavior extends CommandInterceptor {
72484
+ constructor(bpmnFactory, eventBus, modeling) {
72485
+ super(eventBus);
72099
72486
 
72100
- CommandInterceptor.call(this, eventBus);
72487
+ /**
72488
+ * Add zeebe:CalledElement extension element with zeebe:propagateAllChildVariables attribute = false
72489
+ * when creating bpmn:CallActivity.
72490
+ */
72491
+ this.postExecuted('shape.create', HIGH_PRIORITY$n, function(context) {
72492
+ const { shape } = context;
72101
72493
 
72102
- /**
72103
- * add a zeebe:calledElement extensionElement with
72104
- * propagateAllChildVariables attribute = false when creating
72105
- * a bpmn:callActivity
72106
- */
72107
- this.postExecuted('shape.create', HIGH_PRIORITY$m, function(context) {
72108
- const {
72109
- shape
72110
- } = context;
72494
+ if (!is$1(shape, 'bpmn:CallActivity')) {
72495
+ return;
72496
+ }
72111
72497
 
72112
- if (!is$1(shape, 'bpmn:CallActivity')) {
72113
- return;
72114
- }
72498
+ const businessObject = getBusinessObject(shape);
72115
72499
 
72116
- const bo = getBusinessObject(shape);
72500
+ let calledElement = getCalledElement(businessObject);
72117
72501
 
72118
- // Reuse ExtensionElement if existing
72119
- const extensionElements = bo.get('extensionElements') ||
72120
- ElementHelper_1.createElement('bpmn:ExtensionElements', { values: [] }, bo, bpmnFactory);
72502
+ if (!calledElement) {
72503
+ calledElement = bpmnFactory.create('zeebe:CalledElement', {
72504
+ propagateAllChildVariables: false
72505
+ });
72121
72506
 
72122
- // Ensure we have a calledElement
72123
- let calledElement = getCalledElement(bo);
72507
+ let extensionElements = businessObject.get('extensionElements');
72124
72508
 
72125
- if (!calledElement) {
72126
- calledElement = bpmnFactory.create('zeebe:CalledElement', {});
72127
- calledElement.propagateAllChildVariables = false;
72509
+ if (!extensionElements) {
72510
+ extensionElements = ElementHelper_1.createElement('bpmn:ExtensionElements', { values: [] }, businessObject, bpmnFactory);
72128
72511
 
72129
- extensionElements.get('values').push(
72130
- calledElement
72131
- );
72512
+ modeling.updateProperties(shape, { extensionElements });
72513
+ }
72132
72514
 
72133
- bo.extensionElements = extensionElements;
72515
+ modeling.updateModdleProperties(shape, extensionElements, {
72516
+ values: [
72517
+ ...(extensionElements.values || []),
72518
+ calledElement
72519
+ ]
72520
+ });
72521
+ } else if (!has(calledElement, 'propagateAllChildVariables')) {
72134
72522
 
72135
- // Handle existing callActivities
72136
- } else if (!has(calledElement, 'propagateAllChildVariables')) {
72137
- calledElement.propagateAllChildVariables = false;
72138
- }
72523
+ // if zeebe:CalledElement exist set zeebe:propagateAllChildVariables to false
72524
+ modeling.updateModdleProperties(shape, calledElement, {
72525
+ propagateAllChildVariables: false
72526
+ });
72527
+ }
72528
+ }, true);
72139
72529
 
72140
- }, true);
72530
+ }
72141
72531
  }
72142
72532
 
72143
-
72144
72533
  CreateZeebeCallActivityBehavior.$inject = [
72534
+ 'bpmnFactory',
72145
72535
  'eventBus',
72146
- 'bpmnFactory'
72536
+ 'modeling'
72147
72537
  ];
72148
72538
 
72149
- inherits_browser(CreateZeebeCallActivityBehavior, CommandInterceptor);
72150
-
72151
- const HIGH_PRIORITY$n = 15000;
72539
+ const HIGH_PRIORITY$o = 5000;
72152
72540
 
72153
72541
 
72154
72542
  /**
72155
- * UpdatePropagateAllChildVariablesBehavior reacts to either (1) toggling on propagateAllChildVariables
72156
- * when there are outputParameters present or (2) to adding outputParameters when
72157
- * propagateAllChildVariables is set to true.
72158
- * It will ensure that the propagateAllChildVariables attribute on calledElement
72159
- * extensionElements for callActivities is always consistent with outputParameter mappings
72543
+ * Zeebe BPMN behavior for updating zeebe:propagateAllChildVariables.
72160
72544
  */
72161
- function UpdatePropagateAllChildVariablesBehavior(
72162
- eventBus) {
72163
-
72164
- CommandInterceptor.call(this, eventBus);
72165
-
72166
- // Behavior when toggling propagateAllChildVariables /////////////////////////
72167
- /**
72168
- * remove outputParameters from zeebe:IoMapping when setting propgateAlLChildVariables
72169
- * to true in the proeprties panel
72170
- */
72171
- this.executed('properties-panel.update-businessobject' , HIGH_PRIORITY$n, function(context) {
72172
- const {
72173
- element,
72174
- properties
72175
- } = context;
72176
-
72177
- // (1) Don't execute this behavior if we are not in a call activity or not
72178
- // have properties to update or not update the propagateAllChildVariables
72179
- // to false
72180
- if (!is$1(element, 'bpmn:CallActivity') ||
72181
- !properties ||
72182
- !!properties.propagateAllChildVariables === false) {
72183
- return;
72184
- }
72185
-
72186
- // (2) Check whether we have outputParameters
72187
- const outputParameters = getOutputParameters(element),
72188
- inputParameters = getInputParameters(element);
72189
-
72190
- if (!outputParameters ||
72191
- outputParameters.length === 0) {
72192
- return;
72193
- }
72194
-
72195
- // (3) Store old outputParameters and remove them
72196
- context.oldOutputParameters = outputParameters;
72197
-
72198
- const inputOutput = getInputOutput(element);
72199
- inputOutput.outputParameters = [];
72200
-
72201
- // (4) if we also have no inputParameters, store IOMapping and remove it
72202
- if (!inputParameters || inputParameters.length === 0) {
72203
- const extensionElements = getBusinessObject(element).extensionElements;
72204
- context.oldExtensionElements = extensionElements.values;
72205
-
72206
- extensionElements.values = extensionElements.values.filter(ele => ele.$type !== 'zeebe:IoMapping');
72207
- }
72208
- }, true);
72209
-
72210
- // Revert behavior when toggling propagateAllChildVariables //////////////////
72211
- this.reverted('properties-panel.update-businessobject', HIGH_PRIORITY$n, function(context) {
72212
- const {
72213
- element,
72214
- oldOutputParameters,
72215
- oldExtensionElements
72216
- } = context;
72217
-
72218
- // (1) Only intercept the revert, if the behavior became active
72219
- if (oldOutputParameters) {
72545
+ class UpdatePropagateAllChildVariablesBehavior extends CommandInterceptor {
72546
+ constructor(eventBus, modeling) {
72547
+ super(eventBus);
72220
72548
 
72221
- // (2) If we removed the IOMapping, bring it back first
72222
- if (oldExtensionElements) {
72223
- const extensionElements = getBusinessObject(element).extensionElements;
72549
+ /**
72550
+ * Remove zeebe:OutputParameters when zeebe:propagateAllChildVariables is set to true.
72551
+ */
72552
+ this.postExecute('properties-panel.update-businessobject' , HIGH_PRIORITY$o, function(context) {
72553
+ const {
72554
+ element,
72555
+ properties
72556
+ } = context;
72224
72557
 
72225
- extensionElements.values = oldExtensionElements;
72558
+ if (
72559
+ !is$1(element, 'bpmn:CallActivity')
72560
+ || !properties
72561
+ || !!properties.propagateAllChildVariables === false
72562
+ ) {
72563
+ return;
72226
72564
  }
72227
72565
 
72228
- // (3) Bring back the outputParameters
72229
- const inputOutput = getInputOutput(element);
72230
- inputOutput.outputParameters = oldOutputParameters;
72231
- }
72232
- }, true);
72566
+ const inputParameters = getInputParameters(element),
72567
+ outputParameters = getOutputParameters(element);
72233
72568
 
72569
+ if (!outputParameters || !outputParameters.length) {
72570
+ return;
72571
+ }
72234
72572
 
72235
- // Behavior when adding outputParameters ////////////////////////////////////
72236
- /**
72237
- * un-toggle propgateAlLChildVariables when adding output parameters
72238
- */
72239
- this.executed('properties-panel.update-businessobject-list' , HIGH_PRIORITY$n, function(context) {
72240
- const {
72241
- element,
72242
- objectsToAdd
72243
- } = context;
72244
-
72573
+ const ioMapping = getIoMapping(element);
72245
72574
 
72246
- // (1) Exit if we are not in a CallActivity, not adding an OutputParameter or not
72247
- // having set propagateAllChildVariables to false
72248
- if (!is$1(element, 'bpmn:CallActivity') ||
72249
- !objectsToAdd ||
72250
- objectsToAdd.length === 0 ||
72251
- objectsToAdd.filter(obj => is$1(obj, 'zeebe:Output')).length === 0 ||
72252
- isPropagateAllChildVariables(element) === false) {
72253
- return;
72254
- }
72575
+ modeling.updateModdleProperties(element, ioMapping, {
72576
+ 'zeebe:outputParameters': []
72577
+ });
72255
72578
 
72256
- // (2) Store the old propAllChildVariables value and update it then
72257
- const bo = getBusinessObject(element),
72258
- calledElement = getCalledElement(bo);
72579
+ if (!inputParameters || !inputParameters.length) {
72580
+ const businessObject = getBusinessObject(element),
72581
+ extensionElements = businessObject.get('extensionElements');
72259
72582
 
72260
- context.oldPropagateAllChildVariables = true;
72583
+ const values = extensionElements.get('values').filter((element) => {
72584
+ return !is$1(element, 'zeebe:IoMapping');
72585
+ });
72261
72586
 
72262
- calledElement.propagateAllChildVariables = false;
72263
- }, true);
72587
+ modeling.updateModdleProperties(element, extensionElements, {
72588
+ values
72589
+ });
72590
+ }
72591
+ }, true);
72264
72592
 
72265
- // Revert behavior when adding outputParmaeters ////////////////////////////////////
72266
- this.reverted('properties-panel.update-businessobject-list' , HIGH_PRIORITY$n, function(context) {
72267
- const {
72268
- element,
72269
- oldPropagateAllChildVariables
72270
- } = context;
72271
72593
 
72272
- // (1) Only intercept the revert, if the behavior became active
72273
- if (oldPropagateAllChildVariables) {
72274
- const bo = getBusinessObject(element),
72275
- calledElement = getCalledElement(bo);
72594
+ /**
72595
+ * Set zeebe:propagateAllChildVariables to false on zeebe:Output added.
72596
+ */
72597
+ this.postExecute('properties-panel.update-businessobject-list' , HIGH_PRIORITY$o, function(context) {
72598
+ const {
72599
+ currentObject,
72600
+ element,
72601
+ objectsToAdd,
72602
+ propertyName
72603
+ } = context;
72604
+
72605
+ if (!is$1(element, 'bpmn:CallActivity')
72606
+ || !is$1(currentObject, 'zeebe:IoMapping')
72607
+ || (propertyName !== 'outputParameters' && propertyName !== 'zeebe:outputParameters')
72608
+ || !objectsToAdd
72609
+ || !objectsToAdd.length
72610
+ || !objectsToAdd.find((object) => is$1(object, 'zeebe:Output'))
72611
+ || !isPropagateAllChildVariables(element)) {
72612
+ return;
72613
+ }
72276
72614
 
72277
- calledElement.propagateAllChildVariables = oldPropagateAllChildVariables;
72278
- }
72279
- }, true);
72615
+ const businessObject = getBusinessObject(element),
72616
+ calledElement = getCalledElement(businessObject);
72280
72617
 
72618
+ modeling.updateModdleProperties(element, calledElement, {
72619
+ 'zeebe:propagateAllChildVariables': false
72620
+ });
72621
+ }, true);
72281
72622
 
72623
+ }
72282
72624
  }
72283
72625
 
72284
-
72285
72626
  UpdatePropagateAllChildVariablesBehavior.$inject = [
72286
- 'eventBus'
72627
+ 'eventBus',
72628
+ 'modeling'
72287
72629
  ];
72288
72630
 
72631
+ const USER_TASK_FORM_PREFIX = 'UserTaskForm_';
72289
72632
 
72290
- inherits_browser(UpdatePropagateAllChildVariablesBehavior, CommandInterceptor);
72291
-
72292
- const USER_TASK_FORM_PREFIX = 'userTaskForm_';
72293
-
72294
-
72295
- function getUserTaskForm(element, parent) {
72296
-
72297
- const rootElement = parent || getRootElement$1(element);
72298
-
72299
- // (1) get form definition from user task
72300
- const formDefinition = getFormDefinition(element);
72301
-
72302
- if (!formDefinition) {
72303
- return;
72304
- }
72305
-
72306
- const formKey = formDefinition.get('formKey');
72307
-
72308
- // (2) retrieve user task form via form key
72309
- const userTaskForm = findUserTaskForm(formKey, rootElement);
72310
-
72311
- return userTaskForm;
72312
- }
72313
-
72314
- function getFormDefinition(element) {
72315
- const businessObject = getBusinessObject(element);
72316
-
72317
- const formDefinitions = ExtensionElementsHelper_1.getExtensionElements(businessObject, 'zeebe:FormDefinition');
72318
-
72319
- return formDefinitions[0];
72320
- }
72321
-
72322
- function createFormKey(formId) {
72323
- return 'camunda-forms:bpmn:' + formId;
72324
- }
72325
72633
 
72326
72634
  function createFormDefinition(properties, extensionElements, bpmnFactory) {
72327
72635
  return ElementHelper_1.createElement(
@@ -72332,6 +72640,14 @@
72332
72640
  );
72333
72641
  }
72334
72642
 
72643
+ function createFormId() {
72644
+ return nextId_1(USER_TASK_FORM_PREFIX);
72645
+ }
72646
+
72647
+ function createFormKey(formId) {
72648
+ return `camunda-forms:bpmn:${ formId }`;
72649
+ }
72650
+
72335
72651
  function createUserTaskForm(properties, extensionElements, bpmnFactory) {
72336
72652
  return ElementHelper_1.createElement(
72337
72653
  'zeebe:UserTaskForm',
@@ -72341,19 +72657,22 @@
72341
72657
  );
72342
72658
  }
72343
72659
 
72344
- function createFormId() {
72345
- return nextId_1(USER_TASK_FORM_PREFIX);
72346
- }
72660
+ function findUserTaskForm(formKey, rootElement) {
72661
+ const userTaskForms = ExtensionElementsHelper_1.getExtensionElements(rootElement, 'zeebe:UserTaskForm');
72347
72662
 
72663
+ return find(userTaskForms, function(userTaskForm) {
72664
+ const id = userTaskForm.get('zeebe:id');
72348
72665
 
72349
- // helpers /////////////////////
72666
+ return createFormKey(id) === formKey;
72667
+ });
72668
+ }
72350
72669
 
72351
- function findUserTaskForm(formKey, rootElement) {
72352
- const forms = ExtensionElementsHelper_1.getExtensionElements(rootElement, 'zeebe:UserTaskForm');
72670
+ function getFormDefinition(element) {
72671
+ const businessObject = getBusinessObject(element);
72353
72672
 
72354
- return find(forms, function(userTaskForm) {
72355
- return createFormKey(userTaskForm.id) === formKey;
72356
- });
72673
+ const formDefinitions = ExtensionElementsHelper_1.getExtensionElements(businessObject, 'zeebe:FormDefinition');
72674
+
72675
+ return formDefinitions[ 0 ];
72357
72676
  }
72358
72677
 
72359
72678
  function getRootElement$1(element) {
@@ -72367,162 +72686,125 @@
72367
72686
  return parent;
72368
72687
  }
72369
72688
 
72370
- /**
72371
- * Zeebe specific form definition behavior.
72372
- */
72373
- function FormDefinitionBehavior(
72374
- eventBus, bpmnFactory) {
72375
-
72376
- CommandInterceptor.call(this, eventBus);
72377
-
72378
- /**
72379
- * ensures a zeebe:userTaskForm is cleaned up when user task got removed
72380
- */
72381
- this.executed('shape.delete', function(context) {
72382
- const {
72383
- shape,
72384
- oldParent
72385
- } = context;
72689
+ function getUserTaskForm(element, parent) {
72690
+ const rootElement = parent || getRootElement$1(element);
72386
72691
 
72387
- const rootElement = getRootElement$2(oldParent);
72692
+ const formDefinition = getFormDefinition(element);
72388
72693
 
72389
- const userTaskForm = getUserTaskForm(shape, rootElement);
72694
+ if (!formDefinition) {
72695
+ return;
72696
+ }
72390
72697
 
72391
- const rootExtensionElements = rootElement.get('extensionElements');
72698
+ const formKey = formDefinition.get('zeebe:formKey');
72392
72699
 
72393
- if (!is$1(shape, 'bpmn:UserTask') || !userTaskForm) {
72394
- return;
72395
- }
72700
+ return findUserTaskForm(formKey, rootElement);
72701
+ }
72396
72702
 
72397
- remove$2(rootExtensionElements.get('values'), userTaskForm);
72703
+ /**
72704
+ * Zeebe BPMN specific form definition behavior.
72705
+ */
72706
+ class FormDefinitionBehavior extends CommandInterceptor {
72707
+ constructor(bpmnFactory, eventBus, modeling) {
72708
+ super(eventBus);
72398
72709
 
72399
- context.removedUserTaskForm = userTaskForm;
72400
- }, true);
72710
+ /**
72711
+ * Remove zeebe:UserTaskForm on user task removed.
72712
+ */
72713
+ this.postExecute('shape.delete', function(context) {
72714
+ const {
72715
+ oldParent,
72716
+ shape
72717
+ } = context;
72401
72718
 
72402
- this.revert('shape.delete', function(context) {
72403
- const {
72404
- removedUserTaskForm,
72405
- oldParent
72406
- } = context;
72719
+ const rootElement = getRootElement$2(oldParent);
72407
72720
 
72408
- const rootElement = getRootElement$2(oldParent);
72721
+ const userTaskForm = getUserTaskForm(shape, rootElement);
72409
72722
 
72410
- const rootExtensionElements = rootElement.get('extensionElements');
72723
+ if (!is$1(shape, 'bpmn:UserTask') || !userTaskForm) {
72724
+ return;
72725
+ }
72411
72726
 
72412
- if (!removedUserTaskForm) {
72413
- return;
72414
- }
72727
+ const rootExtensionElements = rootElement.get('extensionElements');
72415
72728
 
72416
- add$1(rootExtensionElements.get('values'), removedUserTaskForm);
72417
- }, true);
72729
+ const values = rootExtensionElements.get('values').filter((element) => {
72730
+ return element !== userTaskForm;
72731
+ });
72418
72732
 
72733
+ modeling.updateModdleProperties(shape, rootExtensionElements, { values });
72734
+ }, true);
72419
72735
 
72420
- /**
72421
- * create fresh new copied form definition + user task form
72422
- */
72423
- this.executed('shape.create', function(context) {
72424
- const {
72425
- shape,
72426
- } = context;
72427
72736
 
72428
- const oldFormDefinition = getFormDefinition(shape);
72737
+ /**
72738
+ * Create new zeebe:FormDefinition and zeebe:UserTaskForm on user task created.
72739
+ */
72740
+ this.postExecute('shape.create', function(context) {
72741
+ const { shape } = context;
72429
72742
 
72430
- if (!is$1(shape, 'bpmn:UserTask') || !oldFormDefinition) {
72431
- return;
72432
- }
72743
+ const oldFormDefinition = getFormDefinition(shape);
72433
72744
 
72434
- const oldUserTaskForm = getUserTaskForm(shape);
72745
+ if (!is$1(shape, 'bpmn:UserTask') || !oldFormDefinition) {
72746
+ return;
72747
+ }
72435
72748
 
72436
- const rootElement = getRootElement$2(shape);
72749
+ const oldUserTaskForm = getUserTaskForm(shape);
72437
72750
 
72438
- const businessObject = getBusinessObject(shape);
72751
+ const rootElement = getRootElement$2(shape);
72439
72752
 
72440
- const extensionElements = businessObject.get('extensionElements');
72753
+ const businessObject = getBusinessObject(shape);
72441
72754
 
72442
- let rootExtensionElements = rootElement.get('extensionElements');
72755
+ const extensionElements = businessObject.get('extensionElements');
72443
72756
 
72444
- // (1) ensure extension elements in root
72445
- if (!rootExtensionElements) {
72757
+ let rootExtensionElements = rootElement.get('extensionElements');
72446
72758
 
72447
- rootExtensionElements = ElementHelper_1.createElement(
72448
- 'bpmn:ExtensionElements',
72449
- { values: [] },
72450
- rootElement,
72451
- bpmnFactory
72452
- );
72759
+ // (1) ensure extension elements exists
72760
+ if (!rootExtensionElements) {
72761
+ rootExtensionElements = ElementHelper_1.createElement('bpmn:ExtensionElements', { values: [] }, rootElement, bpmnFactory);
72453
72762
 
72454
- rootElement.set('extensionElements', rootExtensionElements);
72455
- }
72763
+ modeling.updateModdleProperties(shape, rootElement, { extensionElements: rootExtensionElements });
72764
+ }
72456
72765
 
72457
- // (2) remove existing form definition
72458
- context.oldFormDefinition = oldFormDefinition;
72766
+ // (2) remove existing form definition
72767
+ let values = extensionElements.get('values').filter((element) => {
72768
+ return element !== oldFormDefinition;
72769
+ });
72459
72770
 
72460
- remove$2(extensionElements.get('values'), oldFormDefinition);
72771
+ // (3) create new form definition
72772
+ const formId = createFormId();
72461
72773
 
72462
- const formId = createFormId();
72774
+ const newFormDefinition = createFormDefinition({ formKey: createFormKey(formId) }, extensionElements, bpmnFactory);
72463
72775
 
72464
- // (3) create new form definition
72465
- const formDefinition = createFormDefinition(
72466
- {
72467
- formKey: createFormKey(formId)
72468
- },
72469
- extensionElements,
72470
- bpmnFactory
72471
- );
72776
+ values = [
72777
+ ...values,
72778
+ newFormDefinition
72779
+ ];
72472
72780
 
72473
- add$1(extensionElements.get('values'), formDefinition);
72781
+ modeling.updateModdleProperties(shape, extensionElements, {
72782
+ values
72783
+ });
72474
72784
 
72475
- // (4) create new user task form
72476
- const userTaskForm = createUserTaskForm(
72477
- {
72785
+ // (4) create new user task form
72786
+ const userTaskForm = createUserTaskForm({
72478
72787
  id: formId,
72479
72788
  body: oldUserTaskForm ? oldUserTaskForm.get('body') : ''
72480
- },
72481
- rootExtensionElements,
72482
- bpmnFactory
72483
- );
72484
-
72485
- add$1(rootExtensionElements.get('values'), userTaskForm);
72486
- }, true);
72487
-
72488
- this.revert('shape.create', function(context) {
72489
- const {
72490
- shape,
72491
- oldFormDefinition
72492
- } = context;
72493
-
72494
- const businessObject = getBusinessObject(shape);
72495
-
72496
- const extensionElements = businessObject.get('extensionElements');
72497
-
72498
- const formDefinition = getFormDefinition(shape);
72499
-
72500
- const userTaskForm = getUserTaskForm(shape);
72789
+ }, rootExtensionElements, bpmnFactory);
72501
72790
 
72502
- const rootElement = getRootElement$2(shape);
72503
-
72504
- const rootExtensionElements = rootElement.get('extensionElements');
72505
-
72506
- if (!is$1(shape, 'bpmn:UserTask') || !userTaskForm) {
72507
- return;
72508
- }
72509
-
72510
- // we need to cover the old form definition to make <redo> possible
72511
- remove$2(extensionElements.get('values'), formDefinition);
72512
- add$1(extensionElements.get('values'), oldFormDefinition);
72513
-
72514
- remove$2(rootExtensionElements.get('values'), userTaskForm);
72515
- }, true);
72791
+ modeling.updateModdleProperties(shape, rootExtensionElements, {
72792
+ values: [
72793
+ ...(rootExtensionElements.get('values') || []),
72794
+ userTaskForm
72795
+ ]
72796
+ });
72797
+ }, true);
72516
72798
 
72799
+ }
72517
72800
  }
72518
72801
 
72519
72802
  FormDefinitionBehavior.$inject = [
72803
+ 'bpmnFactory',
72520
72804
  'eventBus',
72521
- 'bpmnFactory'
72805
+ 'modeling'
72522
72806
  ];
72523
72807
 
72524
- inherits_browser(FormDefinitionBehavior, CommandInterceptor);
72525
-
72526
72808
 
72527
72809
  // helpers //////////////
72528
72810
 
@@ -72539,11 +72821,13 @@
72539
72821
 
72540
72822
  var zeebeModelingBehaviors = {
72541
72823
  __init__: [
72824
+ 'cleanUpBusinessRuleTaskBehavior',
72542
72825
  'createZeebeBoundaryEventBehavior',
72543
72826
  'createZeebeCallActivityBehavior',
72544
72827
  'updatePropagateAllChildVariablesBehavior',
72545
72828
  'formDefinitionBehavior'
72546
72829
  ],
72830
+ cleanUpBusinessRuleTaskBehavior: [ 'type', CleanUpBusinessRuleTaskBehavior ],
72547
72831
  createZeebeBoundaryEventBehavior: [ 'type', CreateZeebeBoundaryEventBehavior ],
72548
72832
  createZeebeCallActivityBehavior: [ 'type', CreateZeebeCallActivityBehavior ],
72549
72833
  updatePropagateAllChildVariablesBehavior: [ 'type', UpdatePropagateAllChildVariablesBehavior ],
@@ -72772,7 +73056,7 @@
72772
73056
  zeebeReplaceMenuProvider: [ 'type', ReplaceMenuProvider$1 ]
72773
73057
  };
72774
73058
 
72775
- const HIGH_PRIORITY$o = 15000;
73059
+ const HIGH_PRIORITY$p = 5000;
72776
73060
 
72777
73061
  /**
72778
73062
  * Zeebe rule provider that allows to create boundary events with catch events
@@ -72790,7 +73074,7 @@
72790
73074
 
72791
73075
  init() {
72792
73076
  super.init();
72793
- this.addRule('shape.attach', HIGH_PRIORITY$o,(context) => {
73077
+ this.addRule('shape.attach', HIGH_PRIORITY$p,(context) => {
72794
73078
  return this.canAttach(
72795
73079
  context.shape,
72796
73080
  context.target,
@@ -73218,12 +73502,12 @@
73218
73502
  }
73219
73503
 
73220
73504
  // Get the IOMapping
73221
- let inputOutput = getInputOutput(element);
73505
+ let inputOutput = getIoMapping(element);
73222
73506
 
73223
73507
  if (!inputOutput) {
73224
73508
  const parent = extensionElements;
73225
73509
 
73226
- inputOutput = createIOMapping(parent, bpmnFactory, {
73510
+ inputOutput = createIoMapping(parent, bpmnFactory, {
73227
73511
  inputParameters: [],
73228
73512
  outputParameters: []
73229
73513
  });
@@ -73278,7 +73562,7 @@
73278
73562
  function getIOMappingEntries(element, bpmnFactory, translate, options) {
73279
73563
 
73280
73564
  // Get the IOMapping and determine whether we are dealing with input or output parameters
73281
- const inputOutput = getInputOutput(element),
73565
+ const inputOutput = getIoMapping(element),
73282
73566
  params = determineParamGetFunc(options.prop)(element, false);
73283
73567
 
73284
73568
  if (!params.length) {
@@ -73347,6 +73631,19 @@
73347
73631
  }
73348
73632
  }
73349
73633
 
73634
+
73635
+ // helpers //////////
73636
+
73637
+ function determineParamGetFunc(property) {
73638
+ if (property == 'inputParameters') {
73639
+ return getInputParameters;
73640
+ }
73641
+
73642
+ if (property == 'outputParameters') {
73643
+ return getOutputParameters;
73644
+ }
73645
+ }
73646
+
73350
73647
  function inputOutput$1(group, element, bpmnFactory, translate, options) {
73351
73648
 
73352
73649
  const inputOutputEntry = inputOutput(element, bpmnFactory, translate, options);
@@ -75138,6 +75435,29 @@
75138
75435
  isAttr: true
75139
75436
  }
75140
75437
  ]
75438
+ },
75439
+ {
75440
+ name: "CalledDecision",
75441
+ superClass: [
75442
+ "Element"
75443
+ ],
75444
+ meta: {
75445
+ allowedIn: [
75446
+ "bpmn:BusinessRuleTask"
75447
+ ]
75448
+ },
75449
+ properties: [
75450
+ {
75451
+ name: "decisionId",
75452
+ type: "String",
75453
+ isAttr: true
75454
+ },
75455
+ {
75456
+ name: "resultVariable",
75457
+ type: "String",
75458
+ isAttr: true
75459
+ }
75460
+ ]
75141
75461
  }
75142
75462
  ];
75143
75463
  var zeebeModdle = {