camunda-bpmn-js 3.10.1 → 3.10.2

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.
@@ -32860,7 +32860,7 @@
32860
32860
  * @typedef {import('../../core/EventBus').default} EventBus
32861
32861
  */
32862
32862
 
32863
- var HIGH_PRIORITY$q = 1500;
32863
+ var HIGH_PRIORITY$r = 1500;
32864
32864
 
32865
32865
 
32866
32866
  /**
@@ -32928,7 +32928,7 @@
32928
32928
  */
32929
32929
  eventBus.on('drag.start', function(event) {
32930
32930
 
32931
- eventBus.once('drag.move', HIGH_PRIORITY$q, function(event) {
32931
+ eventBus.once('drag.move', HIGH_PRIORITY$r, function(event) {
32932
32932
 
32933
32933
  ensureHover(event);
32934
32934
 
@@ -32959,7 +32959,7 @@
32959
32959
  hover = event.element;
32960
32960
  });
32961
32961
 
32962
- eventBus.on('element.hover', HIGH_PRIORITY$q, function(event) {
32962
+ eventBus.on('element.hover', HIGH_PRIORITY$r, function(event) {
32963
32963
 
32964
32964
  // (3) am I on an element still?
32965
32965
  if (hover) {
@@ -34911,7 +34911,7 @@
34911
34911
  MARKER_CONNECT_UPDATING$1 = 'djs-updating',
34912
34912
  MARKER_DRAGGER = 'djs-dragging';
34913
34913
 
34914
- var HIGH_PRIORITY$p = 1100;
34914
+ var HIGH_PRIORITY$q = 1100;
34915
34915
 
34916
34916
  /**
34917
34917
  * Preview connection while moving bendpoints.
@@ -34979,7 +34979,7 @@
34979
34979
  eventBus.on([
34980
34980
  'bendpoint.move.out',
34981
34981
  'bendpoint.move.cleanup'
34982
- ], HIGH_PRIORITY$p, function(event) {
34982
+ ], HIGH_PRIORITY$q, function(event) {
34983
34983
  var context = event.context,
34984
34984
  hover = context.hover,
34985
34985
  target = context.target;
@@ -35065,7 +35065,7 @@
35065
35065
  eventBus.on([
35066
35066
  'bendpoint.move.end',
35067
35067
  'bendpoint.move.cancel'
35068
- ], HIGH_PRIORITY$p, function(event) {
35068
+ ], HIGH_PRIORITY$q, function(event) {
35069
35069
  var context = event.context,
35070
35070
  connection = context.connection,
35071
35071
  draggerGfx = context.draggerGfx,
@@ -36081,7 +36081,7 @@
36081
36081
  * @typedef {import('../../core/EventBus').default} EventBus
36082
36082
  */
36083
36083
 
36084
- var HIGH_PRIORITY$o = 1100,
36084
+ var HIGH_PRIORITY$p = 1100,
36085
36085
  LOW_PRIORITY$m = 900;
36086
36086
 
36087
36087
  var MARKER_OK$3 = 'connect-ok',
@@ -36142,7 +36142,7 @@
36142
36142
  eventBus.on([
36143
36143
  'connect.out',
36144
36144
  'connect.cleanup'
36145
- ], HIGH_PRIORITY$o, function(event) {
36145
+ ], HIGH_PRIORITY$p, function(event) {
36146
36146
  var hover = event.hover;
36147
36147
 
36148
36148
  if (hover) {
@@ -37468,7 +37468,7 @@
37468
37468
 
37469
37469
  var PARTICIPANT_BORDER_WIDTH = 30;
37470
37470
 
37471
- var HIGH_PRIORITY$n = 2000;
37471
+ var HIGH_PRIORITY$o = 2000;
37472
37472
 
37473
37473
 
37474
37474
  /**
@@ -37485,7 +37485,7 @@
37485
37485
  eventBus.on([
37486
37486
  'create.start',
37487
37487
  'shape.move.start'
37488
- ], HIGH_PRIORITY$n, function(event) {
37488
+ ], HIGH_PRIORITY$o, function(event) {
37489
37489
  var context = event.context,
37490
37490
  shape = context.shape,
37491
37491
  rootElement = canvas.getRootElement();
@@ -37520,7 +37520,7 @@
37520
37520
  });
37521
37521
 
37522
37522
  // force hovering process when creating first participant
37523
- eventBus.on('create.start', HIGH_PRIORITY$n, function(event) {
37523
+ eventBus.on('create.start', HIGH_PRIORITY$o, function(event) {
37524
37524
  var context = event.context,
37525
37525
  shape = context.shape,
37526
37526
  rootElement = canvas.getRootElement(),
@@ -37532,7 +37532,7 @@
37532
37532
  }
37533
37533
 
37534
37534
  if (is$6(shape, 'bpmn:Participant') && is$6(rootElement, 'bpmn:Process')) {
37535
- eventBus.on('element.hover', HIGH_PRIORITY$n, ensureHoveringProcess);
37535
+ eventBus.on('element.hover', HIGH_PRIORITY$o, ensureHoveringProcess);
37536
37536
 
37537
37537
  eventBus.once('create.cleanup', function() {
37538
37538
  eventBus.off('element.hover', ensureHoveringProcess);
@@ -37553,7 +37553,7 @@
37553
37553
 
37554
37554
  // when creating mutliple elements through `elements.create` parent must be set to collaboration
37555
37555
  // and passed to `shape.create` as hint
37556
- this.preExecute('elements.create', HIGH_PRIORITY$n, function(context) {
37556
+ this.preExecute('elements.create', HIGH_PRIORITY$o, function(context) {
37557
37557
  var elements = context.elements,
37558
37558
  parent = context.parent,
37559
37559
  participant = findParticipant(elements),
@@ -38975,7 +38975,7 @@
38975
38975
  * @typedef {import('diagram-js/lib/core/Canvas').default} Canvas
38976
38976
  */
38977
38977
 
38978
- var HIGH_PRIORITY$m = 1500;
38978
+ var HIGH_PRIORITY$n = 1500;
38979
38979
  var HIGHEST_PRIORITY = 2000;
38980
38980
 
38981
38981
 
@@ -38997,7 +38997,7 @@
38997
38997
  'shape.move.move',
38998
38998
  'shape.move.out',
38999
38999
  'shape.move.end'
39000
- ], HIGH_PRIORITY$m, function(event) {
39000
+ ], HIGH_PRIORITY$n, function(event) {
39001
39001
  var context = event.context,
39002
39002
  shape = context.shape || event.shape,
39003
39003
  hover = event.hover;
@@ -39028,7 +39028,7 @@
39028
39028
  'global-connect.out',
39029
39029
  'global-connect.end',
39030
39030
  'global-connect.cleanup'
39031
- ], HIGH_PRIORITY$m, function(event) {
39031
+ ], HIGH_PRIORITY$n, function(event) {
39032
39032
  var hover = event.hover;
39033
39033
 
39034
39034
  // ensure connections start/end on bpmn:Participant,
@@ -39042,7 +39042,7 @@
39042
39042
 
39043
39043
  eventBus.on([
39044
39044
  'bendpoint.move.hover'
39045
- ], HIGH_PRIORITY$m, function(event) {
39045
+ ], HIGH_PRIORITY$n, function(event) {
39046
39046
  var context = event.context,
39047
39047
  hover = event.hover,
39048
39048
  type = context.type;
@@ -39058,7 +39058,7 @@
39058
39058
 
39059
39059
  eventBus.on([
39060
39060
  'connect.start'
39061
- ], HIGH_PRIORITY$m, function(event) {
39061
+ ], HIGH_PRIORITY$n, function(event) {
39062
39062
  var context = event.context,
39063
39063
  start = context.start;
39064
39064
 
@@ -41508,7 +41508,7 @@
41508
41508
  'selection'
41509
41509
  ];
41510
41510
 
41511
- var HIGH_PRIORITY$l = 1500;
41511
+ var HIGH_PRIORITY$m = 1500;
41512
41512
 
41513
41513
  /**
41514
41514
  * @typedef {import('diagram-js/lib/core/EventBus').default} EventBus
@@ -41551,7 +41551,7 @@
41551
41551
  * @param {EventBus} eventBus
41552
41552
  */
41553
41553
  function ResizeBehavior$1(eventBus) {
41554
- eventBus.on('resize.start', HIGH_PRIORITY$l, function(event) {
41554
+ eventBus.on('resize.start', HIGH_PRIORITY$m, function(event) {
41555
41555
  var context = event.context,
41556
41556
  shape = context.shape,
41557
41557
  direction = context.direction,
@@ -42094,7 +42094,7 @@
42094
42094
  */
42095
42095
 
42096
42096
  var LOW_PRIORITY$h = 400;
42097
- var HIGH_PRIORITY$k = 600;
42097
+ var HIGH_PRIORITY$l = 600;
42098
42098
 
42099
42099
  var DEFAULT_POSITION = {
42100
42100
  x: 180,
@@ -42381,7 +42381,7 @@
42381
42381
  }, true);
42382
42382
 
42383
42383
  // move elements between planes
42384
- this.postExecuted('shape.toggleCollapse', HIGH_PRIORITY$k, function(context) {
42384
+ this.postExecuted('shape.toggleCollapse', HIGH_PRIORITY$l, function(context) {
42385
42385
  var shape = context.shape;
42386
42386
 
42387
42387
  if (!is$6(shape, 'bpmn:SubProcess')) {
@@ -43029,7 +43029,7 @@
43029
43029
  */
43030
43030
 
43031
43031
  var LOW_PRIORITY$f = 500,
43032
- HIGH_PRIORITY$j = 5000;
43032
+ HIGH_PRIORITY$k = 5000;
43033
43033
 
43034
43034
 
43035
43035
  /**
@@ -43103,7 +43103,7 @@
43103
43103
 
43104
43104
  // listen to a lot of stuff to group lane updates
43105
43105
 
43106
- this.preExecute(laneRefUpdateEvents, HIGH_PRIORITY$j, function(event) {
43106
+ this.preExecute(laneRefUpdateEvents, HIGH_PRIORITY$k, function(event) {
43107
43107
  initContext();
43108
43108
  });
43109
43109
 
@@ -44431,7 +44431,7 @@
44431
44431
  * @typedef {import('diagram-js/lib/core/Canvas').default} Canvas
44432
44432
  */
44433
44433
 
44434
- var HIGH_PRIORITY$i = 2000;
44434
+ var HIGH_PRIORITY$j = 2000;
44435
44435
 
44436
44436
  /**
44437
44437
  * @param {EventBus} eventBus
@@ -44439,7 +44439,7 @@
44439
44439
  */
44440
44440
  function BpmnDiOrdering(eventBus, canvas) {
44441
44441
 
44442
- eventBus.on('saveXML.start', HIGH_PRIORITY$i, orderDi);
44442
+ eventBus.on('saveXML.start', HIGH_PRIORITY$j, orderDi);
44443
44443
 
44444
44444
  function orderDi() {
44445
44445
  var rootElements = canvas.getRootElements();
@@ -44806,7 +44806,7 @@
44806
44806
 
44807
44807
  var PREFIX = 'create';
44808
44808
 
44809
- var HIGH_PRIORITY$h = 2000;
44809
+ var HIGH_PRIORITY$i = 2000;
44810
44810
 
44811
44811
 
44812
44812
  /**
@@ -45034,7 +45034,7 @@
45034
45034
  eventBus.on('create.init', function() {
45035
45035
  eventBus.on('elements.changed', cancel);
45036
45036
 
45037
- eventBus.once([ 'create.cancel', 'create.end' ], HIGH_PRIORITY$h, function() {
45037
+ eventBus.once([ 'create.cancel', 'create.end' ], HIGH_PRIORITY$i, function() {
45038
45038
  eventBus.off('elements.changed', cancel);
45039
45039
  });
45040
45040
  });
@@ -47174,7 +47174,7 @@
47174
47174
  e: 'right'
47175
47175
  };
47176
47176
 
47177
- var HIGH_PRIORITY$g = 1500;
47177
+ var HIGH_PRIORITY$h = 1500;
47178
47178
 
47179
47179
  var DIRECTION_TO_OPPOSITE = {
47180
47180
  n: 's',
@@ -47223,7 +47223,7 @@
47223
47223
  });
47224
47224
  });
47225
47225
 
47226
- eventBus.on('spaceTool.move', HIGH_PRIORITY$g , function(event) {
47226
+ eventBus.on('spaceTool.move', HIGH_PRIORITY$h , function(event) {
47227
47227
  var context = event.context,
47228
47228
  initialized = context.initialized;
47229
47229
 
@@ -48712,7 +48712,7 @@
48712
48712
  }
48713
48713
 
48714
48714
  var LOW_PRIORITY$a = 250,
48715
- HIGH_PRIORITY$f = 1400;
48715
+ HIGH_PRIORITY$g = 1400;
48716
48716
 
48717
48717
  /**
48718
48718
  * @typedef {import('../../model/Types').Element} Element
@@ -48739,7 +48739,7 @@
48739
48739
 
48740
48740
  // remove labels from the collection that are being
48741
48741
  // moved with other elements anyway
48742
- eventBus.on('shape.move.start', HIGH_PRIORITY$f, function(e) {
48742
+ eventBus.on('shape.move.start', HIGH_PRIORITY$g, function(e) {
48743
48743
 
48744
48744
  var context = e.context,
48745
48745
  shapes = context.shapes,
@@ -48778,7 +48778,7 @@
48778
48778
  });
48779
48779
 
48780
48780
  // add all labels to move closure
48781
- this.preExecuted('elements.move', HIGH_PRIORITY$f, function(e) {
48781
+ this.preExecuted('elements.move', HIGH_PRIORITY$g, function(e) {
48782
48782
  var context = e.context,
48783
48783
  closure = context.closure,
48784
48784
  enclosedElements = closure.enclosedElements;
@@ -48894,7 +48894,7 @@
48894
48894
  */
48895
48895
 
48896
48896
  var LOW_PRIORITY$9 = 251,
48897
- HIGH_PRIORITY$e = 1401;
48897
+ HIGH_PRIORITY$f = 1401;
48898
48898
 
48899
48899
  var MARKER_ATTACH$1 = 'attach-ok';
48900
48900
 
@@ -48923,7 +48923,7 @@
48923
48923
 
48924
48924
  // remove all the attached elements from the shapes to be validated
48925
48925
  // add all the attached shapes to the overall list of moved shapes
48926
- eventBus.on('shape.move.start', HIGH_PRIORITY$e, function(e) {
48926
+ eventBus.on('shape.move.start', HIGH_PRIORITY$f, function(e) {
48927
48927
 
48928
48928
  var context = e.context,
48929
48929
  shapes = context.shapes,
@@ -48976,7 +48976,7 @@
48976
48976
  });
48977
48977
 
48978
48978
  // add all attachers to move closure
48979
- this.preExecuted('elements.move', HIGH_PRIORITY$e, function(e) {
48979
+ this.preExecuted('elements.move', HIGH_PRIORITY$f, function(e) {
48980
48980
  var context = e.context,
48981
48981
  closure = context.closure,
48982
48982
  shapes = context.shapes,
@@ -60624,7 +60624,7 @@
60624
60624
  * @typedef {import('../../grid-snapping/GridSnapping').default} GridSnapping
60625
60625
  */
60626
60626
 
60627
- var HIGH_PRIORITY$d = 2000;
60627
+ var HIGH_PRIORITY$e = 2000;
60628
60628
 
60629
60629
  /**
60630
60630
  * Integrates space tool with grid snapping.
@@ -60636,7 +60636,7 @@
60636
60636
  eventBus.on([
60637
60637
  'spaceTool.move',
60638
60638
  'spaceTool.end'
60639
- ], HIGH_PRIORITY$d, function(event) {
60639
+ ], HIGH_PRIORITY$e, function(event) {
60640
60640
  var context = event.context;
60641
60641
 
60642
60642
  if (!context.initialized) {
@@ -60695,14 +60695,14 @@
60695
60695
  * @typedef {import('diagram-js/lib/util/Types').Axis} Axis
60696
60696
  */
60697
60697
 
60698
- var HIGH_PRIORITY$c = 2000;
60698
+ var HIGH_PRIORITY$d = 2000;
60699
60699
 
60700
60700
  /**
60701
60701
  * @param {EventBus} eventBus
60702
60702
  * @param {GridSnapping} gridSnapping
60703
60703
  */
60704
60704
  function GridSnappingAutoPlaceBehavior(eventBus, gridSnapping) {
60705
- eventBus.on('autoPlace', HIGH_PRIORITY$c, function(context) {
60705
+ eventBus.on('autoPlace', HIGH_PRIORITY$d, function(context) {
60706
60706
  var source = context.source,
60707
60707
  sourceMid = getMid(source),
60708
60708
  shape = context.shape;
@@ -60811,7 +60811,7 @@
60811
60811
  * @typedef {import('diagram-js/lib/util/Types').Point} Point
60812
60812
  */
60813
60813
 
60814
- var HIGH_PRIORITY$b = 3000;
60814
+ var HIGH_PRIORITY$c = 3000;
60815
60815
 
60816
60816
 
60817
60817
  /**
@@ -60831,7 +60831,7 @@
60831
60831
  this.postExecuted([
60832
60832
  'connection.create',
60833
60833
  'connection.layout'
60834
- ], HIGH_PRIORITY$b, function(event) {
60834
+ ], HIGH_PRIORITY$c, function(event) {
60835
60835
  var context = event.context,
60836
60836
  connection = context.connection,
60837
60837
  hints = context.hints || {},
@@ -62060,7 +62060,7 @@
62060
62060
  * } } DirectEditingContext
62061
62061
  */
62062
62062
 
62063
- var HIGH_PRIORITY$a = 2000;
62063
+ var HIGH_PRIORITY$b = 2000;
62064
62064
 
62065
62065
  /**
62066
62066
  * @param {EventBus} eventBus
@@ -62105,7 +62105,7 @@
62105
62105
  eventBus.on([
62106
62106
  'shape.remove',
62107
62107
  'connection.remove'
62108
- ], HIGH_PRIORITY$a, function(event) {
62108
+ ], HIGH_PRIORITY$b, function(event) {
62109
62109
 
62110
62110
  if (directEditing.isActive(event.element)) {
62111
62111
  directEditing.cancel();
@@ -63077,7 +63077,7 @@
63077
63077
 
63078
63078
  var LOW_PRIORITY$5 = 500,
63079
63079
  MEDIUM_PRIORITY = 1250,
63080
- HIGH_PRIORITY$9 = 1500;
63080
+ HIGH_PRIORITY$a = 1500;
63081
63081
 
63082
63082
  var round$2 = Math.round;
63083
63083
 
@@ -63127,7 +63127,7 @@
63127
63127
  // * validatedShapes: a list of shapes that are being checked
63128
63128
  // against the rules before and during move
63129
63129
  //
63130
- eventBus.on('shape.move.start', HIGH_PRIORITY$9, function(event) {
63130
+ eventBus.on('shape.move.start', HIGH_PRIORITY$a, function(event) {
63131
63131
 
63132
63132
  var context = event.context,
63133
63133
  shape = event.shape,
@@ -64556,7 +64556,7 @@
64556
64556
  * @typedef {import('../tool-manager/ToolManager').default} ToolManager
64557
64557
  */
64558
64558
 
64559
- var HIGH_PRIORITY$8 = 1500;
64559
+ var HIGH_PRIORITY$9 = 1500;
64560
64560
  var HAND_CURSOR = 'grab';
64561
64561
 
64562
64562
  /**
@@ -64582,7 +64582,7 @@
64582
64582
  dragging: 'hand.move'
64583
64583
  });
64584
64584
 
64585
- eventBus.on('element.mousedown', HIGH_PRIORITY$8, function(event) {
64585
+ eventBus.on('element.mousedown', HIGH_PRIORITY$9, function(event) {
64586
64586
 
64587
64587
  if (!hasPrimaryModifier(event)) {
64588
64588
  return;
@@ -64593,7 +64593,7 @@
64593
64593
  return false;
64594
64594
  });
64595
64595
 
64596
- keyboard && keyboard.addListener(HIGH_PRIORITY$8, function(e) {
64596
+ keyboard && keyboard.addListener(HIGH_PRIORITY$9, function(e) {
64597
64597
  if (!isSpace$1(e.keyEvent) || self.isActive()) {
64598
64598
  return;
64599
64599
  }
@@ -64603,7 +64603,7 @@
64603
64603
  self.activateMove(mouseEvent, !!mouseEvent);
64604
64604
  }, 'keyboard.keydown');
64605
64605
 
64606
- keyboard && keyboard.addListener(HIGH_PRIORITY$8, function(e) {
64606
+ keyboard && keyboard.addListener(HIGH_PRIORITY$9, function(e) {
64607
64607
  if (!isSpace$1(e.keyEvent) || !self.isActive()) {
64608
64608
  return;
64609
64609
  }
@@ -65899,7 +65899,7 @@
65899
65899
  * @typedef {import('../../model/Types').Shape} Shape
65900
65900
  */
65901
65901
 
65902
- var HIGH_PRIORITY$7 = 1500;
65902
+ var HIGH_PRIORITY$8 = 1500;
65903
65903
 
65904
65904
 
65905
65905
  /**
@@ -65912,7 +65912,7 @@
65912
65912
  injector.invoke(CreateMoveSnapping, this);
65913
65913
 
65914
65914
  // creating first participant
65915
- eventBus.on([ 'create.move', 'create.end' ], HIGH_PRIORITY$7, setSnappedIfConstrained);
65915
+ eventBus.on([ 'create.move', 'create.end' ], HIGH_PRIORITY$8, setSnappedIfConstrained);
65916
65916
 
65917
65917
  // snap boundary events
65918
65918
  eventBus.on([
@@ -65920,7 +65920,7 @@
65920
65920
  'create.end',
65921
65921
  'shape.move.move',
65922
65922
  'shape.move.end'
65923
- ], HIGH_PRIORITY$7, function(event) {
65923
+ ], HIGH_PRIORITY$8, function(event) {
65924
65924
  var context = event.context,
65925
65925
  canExecute = context.canExecute,
65926
65926
  target = context.target;
@@ -121259,7 +121259,7 @@
121259
121259
  });
121260
121260
  }
121261
121261
 
121262
- const HIGH_PRIORITY$6 = 5000;
121262
+ const HIGH_PRIORITY$7 = 5000;
121263
121263
 
121264
121264
 
121265
121265
  /**
@@ -121275,7 +121275,7 @@
121275
121275
  /**
121276
121276
  * Remove zeebe:CalledDecision if zeebe:TaskDefinition is about to be added.
121277
121277
  */
121278
- this.preExecute('element.updateModdleProperties' , HIGH_PRIORITY$6, function(context) {
121278
+ this.preExecute('element.updateModdleProperties' , HIGH_PRIORITY$7, function(context) {
121279
121279
  const {
121280
121280
  element,
121281
121281
  moddleElement,
@@ -121306,7 +121306,7 @@
121306
121306
  /**
121307
121307
  * Remove zeebe:TaskDefinition and zeebe:TaskHeaders if zeebe:CalledDecision is about to be added.
121308
121308
  */
121309
- this.preExecute('element.updateModdleProperties', HIGH_PRIORITY$6, function(context) {
121309
+ this.preExecute('element.updateModdleProperties', HIGH_PRIORITY$7, function(context) {
121310
121310
  const {
121311
121311
  element,
121312
121312
  moddleElement,
@@ -121900,7 +121900,7 @@
121900
121900
  }
121901
121901
  }
121902
121902
 
121903
- const HIGH_PRIORITY$5 = 5000;
121903
+ const HIGH_PRIORITY$6 = 5000;
121904
121904
 
121905
121905
 
121906
121906
  /**
@@ -121914,7 +121914,7 @@
121914
121914
  * Add zeebe:CalledElement extension element with zeebe:propagateAllChildVariables attribute = false
121915
121915
  * when creating bpmn:CallActivity.
121916
121916
  */
121917
- this.postExecuted('shape.create', HIGH_PRIORITY$5, function(context) {
121917
+ this.postExecuted('shape.create', HIGH_PRIORITY$6, function(context) {
121918
121918
  const { shape } = context;
121919
121919
 
121920
121920
  if (!is$6(shape, 'bpmn:CallActivity')) {
@@ -122277,7 +122277,7 @@
122277
122277
  && !properties.values.find(value => is$6(value, type));
122278
122278
  }
122279
122279
 
122280
- const HIGH_PRIORITY$4 = 5000;
122280
+ const HIGH_PRIORITY$5 = 5000;
122281
122281
 
122282
122282
 
122283
122283
  /**
@@ -122288,7 +122288,7 @@
122288
122288
  constructor(commandStack, eventBus) {
122289
122289
  super(eventBus);
122290
122290
 
122291
- this.postExecuted('element.updateModdleProperties' , HIGH_PRIORITY$4, function(context) {
122291
+ this.postExecuted('element.updateModdleProperties' , HIGH_PRIORITY$5, function(context) {
122292
122292
  const {
122293
122293
  element,
122294
122294
  moddleElement
@@ -122320,7 +122320,7 @@
122320
122320
  'eventBus'
122321
122321
  ];
122322
122322
 
122323
- const HIGH_PRIORITY$3 = 5000;
122323
+ const HIGH_PRIORITY$4 = 5000;
122324
122324
 
122325
122325
 
122326
122326
  /**
@@ -122331,7 +122331,7 @@
122331
122331
  constructor(commandStack, eventBus) {
122332
122332
  super(eventBus);
122333
122333
 
122334
- this.postExecuted('element.updateModdleProperties' , HIGH_PRIORITY$3, function(context) {
122334
+ this.postExecuted('element.updateModdleProperties' , HIGH_PRIORITY$4, function(context) {
122335
122335
  const {
122336
122336
  element,
122337
122337
  moddleElement
@@ -122362,7 +122362,7 @@
122362
122362
  'eventBus'
122363
122363
  ];
122364
122364
 
122365
- const HIGH_PRIORITY$2 = 5000;
122365
+ const HIGH_PRIORITY$3 = 5000;
122366
122366
 
122367
122367
 
122368
122368
  /**
@@ -122380,7 +122380,7 @@
122380
122380
  * Remove zeebe:Output elements if zeebe:propagateAllChildVariables is set to true.
122381
122381
  * Remove zeebe:IoMapping extension element if empty.
122382
122382
  */
122383
- this.postExecute('element.updateModdleProperties' , HIGH_PRIORITY$2, function(context) {
122383
+ this.postExecute('element.updateModdleProperties' , HIGH_PRIORITY$3, function(context) {
122384
122384
  const {
122385
122385
  element,
122386
122386
  moddleElement,
@@ -122420,7 +122420,7 @@
122420
122420
  * Set zeebe:propagateAllChildVariables of zeebe:CalledElement to false if
122421
122421
  * zeebe:Output or zeebe:IoMapping with zeebe:Output is added.
122422
122422
  */
122423
- this.preExecute('element.updateModdleProperties' , HIGH_PRIORITY$2, function(context) {
122423
+ this.preExecute('element.updateModdleProperties' , HIGH_PRIORITY$3, function(context) {
122424
122424
  const {
122425
122425
  element,
122426
122426
  moddleElement,
@@ -123383,11 +123383,11 @@
123383
123383
  }
123384
123384
  businessObject = eventDefinitions[0];
123385
123385
  }
123386
+ if (!businessObject) {
123387
+ return;
123388
+ }
123386
123389
  return businessObject.get('messageRef');
123387
123390
  }
123388
- function findZeebeSubscription(message) {
123389
- return findExtension$1(message, 'zeebe:Subscription');
123390
- }
123391
123391
  function getDefaultValue(property) {
123392
123392
  if (property.value !== undefined) {
123393
123393
  return property.value;
@@ -124009,242 +124009,6 @@
124009
124009
  // should never throw as templates are validated beforehand
124010
124010
  throw unknownBindingError$1(element, property);
124011
124011
  }
124012
- function unsetProperty(commandStack, element, property) {
124013
- let businessObject = getBusinessObject$2(element);
124014
- const {
124015
- binding
124016
- } = property;
124017
- const {
124018
- type
124019
- } = binding;
124020
- let extensionElements;
124021
- const commands = [];
124022
- const context = {
124023
- element,
124024
- property
124025
- };
124026
- if (MESSAGE_BINDING_TYPES.includes(type)) {
124027
- businessObject = findMessage(businessObject);
124028
- if (!businessObject) {
124029
- return;
124030
- }
124031
- }
124032
-
124033
- // property
124034
- if (PROPERTY_BINDING_TYPES.includes(type)) {
124035
- const {
124036
- name
124037
- } = binding;
124038
- commands.push({
124039
- cmd: 'element.updateModdleProperties',
124040
- context: {
124041
- ...context,
124042
- moddleElement: businessObject,
124043
- properties: {
124044
- [name]: undefined
124045
- }
124046
- }
124047
- });
124048
- }
124049
- if (EXTENSION_BINDING_TYPES$1.includes(type)) {
124050
- extensionElements = businessObject.get('extensionElements');
124051
- if (!extensionElements) return;
124052
- }
124053
-
124054
- // zeebe:taskDefinition
124055
- if (TASK_DEFINITION_TYPES.includes(type)) {
124056
- const oldTaskDefinition = findExtension$1(extensionElements, 'zeebe:TaskDefinition');
124057
- const propertyName = getTaskDefinitionPropertyName(binding);
124058
- if (oldTaskDefinition) {
124059
- if (isOnlyProperty(oldTaskDefinition, propertyName)) {
124060
- // remove task definition
124061
- commands.push({
124062
- cmd: 'element.updateModdleProperties',
124063
- context: {
124064
- ...context,
124065
- moddleElement: extensionElements,
124066
- properties: {
124067
- values: without(extensionElements.get('values'), oldTaskDefinition)
124068
- }
124069
- }
124070
- });
124071
- } else {
124072
- // remove property
124073
- commands.push({
124074
- cmd: 'element.updateModdleProperties',
124075
- context: {
124076
- ...context,
124077
- moddleElement: oldTaskDefinition,
124078
- properties: {
124079
- [propertyName]: undefined
124080
- }
124081
- }
124082
- });
124083
- }
124084
- }
124085
- }
124086
-
124087
- // zeebe:IoMapping
124088
- if (IO_BINDING_TYPES$1.includes(type)) {
124089
- let ioMapping = findExtension$1(extensionElements, 'zeebe:IoMapping');
124090
- if (!ioMapping) return;
124091
-
124092
- // zeebe:Input
124093
- if (type === ZEBBE_INPUT_TYPE) {
124094
- const oldZeebeInputParameter = findInputParameter$1(ioMapping, binding);
124095
- const values = ioMapping.get('inputParameters').filter(value => value !== oldZeebeInputParameter);
124096
- if (ioMapping.get('outputParameters').length == 0 && values.length == 0) {
124097
- commands.push({
124098
- cmd: 'element.updateModdleProperties',
124099
- context: {
124100
- ...context,
124101
- moddleElement: extensionElements,
124102
- properties: {
124103
- values: without(extensionElements.get('values'), ioMapping)
124104
- }
124105
- }
124106
- });
124107
- } else {
124108
- commands.push({
124109
- cmd: 'element.updateModdleProperties',
124110
- context: {
124111
- ...context,
124112
- moddleElement: ioMapping,
124113
- properties: {
124114
- inputParameters: [...values]
124115
- }
124116
- }
124117
- });
124118
- }
124119
- }
124120
-
124121
- // zeebe:Output
124122
- if (type === ZEEBE_OUTPUT_TYPE) {
124123
- const oldZeebeOutputParameter = findOutputParameter$1(ioMapping, binding);
124124
- const values = ioMapping.get('outputParameters').filter(value => value !== oldZeebeOutputParameter);
124125
- if (ioMapping.get('inputParameters').length == 0 && values.length == 0) {
124126
- commands.push({
124127
- cmd: 'element.updateModdleProperties',
124128
- context: {
124129
- ...context,
124130
- moddleElement: extensionElements,
124131
- properties: {
124132
- values: without(extensionElements.get('values'), ioMapping)
124133
- }
124134
- }
124135
- });
124136
- }
124137
- commands.push({
124138
- cmd: 'element.updateModdleProperties',
124139
- context: {
124140
- ...context,
124141
- moddleElement: ioMapping,
124142
- properties: {
124143
- 'outputParameters': [...values]
124144
- }
124145
- }
124146
- });
124147
- }
124148
- }
124149
-
124150
- // zeebe:taskHeaders
124151
- if (type === ZEEBE_TASK_HEADER_TYPE) {
124152
- let taskHeaders = findExtension$1(extensionElements, 'zeebe:TaskHeaders');
124153
- if (!taskHeaders) return;
124154
- const oldTaskHeader = findTaskHeader(taskHeaders, binding);
124155
- const values = taskHeaders.get('values').filter(value => value !== oldTaskHeader);
124156
- if (values.length === 0) {
124157
- commands.push({
124158
- cmd: 'element.updateModdleProperties',
124159
- context: {
124160
- ...context,
124161
- moddleElement: extensionElements,
124162
- properties: {
124163
- values: without(extensionElements.get('values'), taskHeaders)
124164
- }
124165
- }
124166
- });
124167
- } else {
124168
- commands.push({
124169
- cmd: 'element.updateModdleProperties',
124170
- context: {
124171
- ...context,
124172
- moddleElement: taskHeaders,
124173
- properties: {
124174
- values: [...values]
124175
- }
124176
- }
124177
- });
124178
- }
124179
- }
124180
-
124181
- // zeebe:Property
124182
- if (type === ZEEBE_PROPERTY_TYPE) {
124183
- let zeebeProperties = findExtension$1(extensionElements, 'zeebe:Properties');
124184
- if (!zeebeProperties) return;
124185
- const oldZeebeProperty = findZeebeProperty(zeebeProperties, binding);
124186
- const properties = zeebeProperties.get('properties').filter(property => property !== oldZeebeProperty);
124187
- if (!properties.length) {
124188
- commands.push({
124189
- cmd: 'element.updateModdleProperties',
124190
- context: {
124191
- ...context,
124192
- moddleElement: extensionElements,
124193
- properties: {
124194
- values: without(extensionElements.get('values'), zeebeProperties)
124195
- }
124196
- }
124197
- });
124198
- } else {
124199
- commands.push({
124200
- cmd: 'element.updateModdleProperties',
124201
- context: {
124202
- ...context,
124203
- moddleElement: zeebeProperties,
124204
- properties: {
124205
- properties: [...properties]
124206
- }
124207
- }
124208
- });
124209
- }
124210
- }
124211
-
124212
- // bpmn:Message#property
124213
- if (type === MESSAGE_PROPERTY_TYPE) {
124214
- commands.push({
124215
- cmd: 'element.updateModdleProperties',
124216
- context: {
124217
- ...context,
124218
- moddleElement: businessObject,
124219
- properties: {
124220
- [binding.name]: undefined
124221
- }
124222
- }
124223
- });
124224
- }
124225
-
124226
- // bpmn:Message#zeebe:subscription#property
124227
- if (type === MESSAGE_ZEEBE_SUBSCRIPTION_PROPERTY_TYPE) {
124228
- const subscription = findZeebeSubscription(businessObject);
124229
- if (!subscription) {
124230
- return;
124231
- }
124232
- commands.push({
124233
- cmd: 'element.updateModdleProperties',
124234
- context: {
124235
- ...context,
124236
- moddleElement: subscription,
124237
- properties: {
124238
- [binding.name]: undefined
124239
- }
124240
- }
124241
- });
124242
- }
124243
- if (commands.length) {
124244
- commandStack.execute('properties-panel.multi-command-executor', commands);
124245
- return;
124246
- }
124247
- }
124248
124012
  function validateProperty(value, property, translate$1 = translate) {
124249
124013
  const {
124250
124014
  constraints = {},
@@ -124309,14 +124073,6 @@
124309
124073
  function matchesPattern$1(string, pattern) {
124310
124074
  return new RegExp(pattern).test(string);
124311
124075
  }
124312
- function isOnlyProperty(moddleElement, propertyName) {
124313
- const descriptor = moddleElement.$descriptor;
124314
- return descriptor.properties.every(({
124315
- name
124316
- }) => {
124317
- return propertyName === name || moddleElement.get(name) === undefined;
124318
- });
124319
- }
124320
124076
 
124321
124077
  /**
124322
124078
  * Based on conditions, remove properties from the template.
@@ -124395,49 +124151,7 @@
124395
124151
  return true;
124396
124152
  }
124397
124153
 
124398
- function removeRootElement(rootElement, injector) {
124399
- const modeling = injector.get('modeling'),
124400
- canvas = injector.get('canvas'),
124401
- bpmnjs = injector.get('bpmnjs');
124402
- const element = canvas.getRootElement(),
124403
- definitions = bpmnjs.getDefinitions(),
124404
- rootElements = definitions.get('rootElements');
124405
- const newRootElements = rootElements.filter(e => e !== rootElement);
124406
-
124407
- // short-circuit to prevent unnecessary updates
124408
- if (newRootElements.length === rootElements.length) {
124409
- return;
124410
- }
124411
- modeling.updateModdleProperties(element, definitions, {
124412
- rootElements: newRootElements
124413
- });
124414
- }
124415
-
124416
- /**
124417
- * Remove message from element and the diagram.
124418
- *
124419
- * @param {import('bpmn-js/lib/model/Types').Element} element
124420
- * @param {import('didi').Injector} injector
124421
- */
124422
- function removeMessage(element, injector) {
124423
- const modeling = injector.get('modeling');
124424
- const bo = getReferringElement(element);
124425
- const message = findMessage(bo);
124426
- if (!message) {
124427
- return;
124428
- }
124429
- modeling.updateModdleProperties(element, bo, {
124430
- messageRef: undefined
124431
- });
124432
- removeRootElement(message, injector);
124433
- }
124434
- function getReferringElement(element) {
124435
- const bo = getBusinessObject$2(element);
124436
- if (is$6(bo, 'bpmn:Event')) {
124437
- return bo.get('eventDefinitions')[0];
124438
- }
124439
- return bo;
124440
- }
124154
+ const HIGH_PRIORITY$2 = 2500;
124441
124155
 
124442
124156
  /**
124443
124157
  * Checks the conditions of an element template and sets/resets the
@@ -124453,6 +124167,20 @@
124453
124167
  this._injector = injector;
124454
124168
  this.preExecute(['element.updateProperties', 'element.updateModdleProperties'], this._saveConditionalState, true, this);
124455
124169
  this.postExecute(['element.updateProperties', 'element.updateModdleProperties', 'propertiesPanel.zeebe.changeTemplate', 'element.move'], this._applyConditions, true, this);
124170
+
124171
+ // Apply Conditions before changing properties. This persists the template so we can check if conditions apply
124172
+ // after upgrading the template.
124173
+ this.preExecute(['propertiesPanel.zeebe.changeTemplate'], HIGH_PRIORITY$2, this._handleTemplateUpgrade, true, this);
124174
+ }
124175
+ _handleTemplateUpgrade(context) {
124176
+ const {
124177
+ element,
124178
+ newTemplate
124179
+ } = context;
124180
+ if (!element || !newTemplate) {
124181
+ return;
124182
+ }
124183
+ context.newTemplate = applyConditions(context.element, context.newTemplate);
124456
124184
  }
124457
124185
  _saveConditionalState(context) {
124458
124186
  const {
@@ -124467,29 +124195,52 @@
124467
124195
  _applyConditions(context) {
124468
124196
  const {
124469
124197
  element,
124470
- oldTemplate
124198
+ hints = {}
124471
124199
  } = context;
124200
+ if (hints.skipConditionUpdate) {
124201
+ return;
124202
+ }
124472
124203
  const template = this._elementTemplates.get(element);
124204
+
124205
+ // New Template is persisted before applying default values,
124206
+ // new conditions might apply after the defaults are present.
124207
+ const oldTemplate = context.oldTemplate || context.newTemplate;
124473
124208
  if (!template || !oldTemplate || template.id !== oldTemplate.id) {
124474
124209
  return;
124475
124210
  }
124476
124211
  const newTemplate = applyConditions(element, template);
124477
- const propertiesToAdd = getMissingProperties(oldTemplate, newTemplate);
124478
- const propertiesToRemove = getPropertiesToRemove(newTemplate, oldTemplate);
124479
- this._updateReferencedElement(element, oldTemplate, newTemplate);
124480
- propertiesToAdd.forEach(property => setPropertyValue(this._bpmnFactory, this._commandStack, element, property, property.value));
124481
- propertiesToRemove.forEach(property => unsetProperty(this._commandStack, element, property));
124482
- }
124483
- _updateReferencedElement(element, oldTemplate, newTemplate) {
124484
- if (hasMessageProperties(oldTemplate) && !hasMessageProperties(newTemplate)) {
124485
- removeMessage(element, this._injector);
124212
+ if (!hasDifferentPropertyBindings(newTemplate, oldTemplate)) {
124213
+ return;
124486
124214
  }
124215
+ const changeContext = {
124216
+ element,
124217
+ newTemplate,
124218
+ oldTemplate,
124219
+ hints: {
124220
+ skipConditionUpdate: true
124221
+ }
124222
+ };
124223
+ this._commandStack.execute('propertiesPanel.zeebe.changeTemplate', changeContext);
124487
124224
  }
124488
124225
  }
124489
124226
  ElementTemplatesConditionChecker.$inject = ['eventBus', 'elementTemplates', 'commandStack', 'bpmnFactory', 'injector'];
124490
124227
 
124491
124228
  // helpers
124492
124229
 
124230
+ function hasDifferentPropertyBindings(sourceTemplate, targetTemplate) {
124231
+ return hasNewProperties(sourceTemplate, targetTemplate) || hasRemovedProperties(sourceTemplate, targetTemplate);
124232
+ }
124233
+ function hasNewProperties(sourceTemplate, targetTemplate) {
124234
+ let properties = targetTemplate.properties;
124235
+ return properties.some(targetProp => !sourceTemplate.properties.find(sourceProp => compareProps(sourceProp, targetProp)));
124236
+ }
124237
+ function hasRemovedProperties(oldTemplate, newTemplate) {
124238
+ const oldProperties = getMissingProperties(newTemplate, oldTemplate);
124239
+
124240
+ // ensure XML properties are mantained for properties with
124241
+ // different conditions but same bindings
124242
+ return oldProperties.some(property => !findPropertyWithBinding(newTemplate, property));
124243
+ }
124493
124244
  function getMissingProperties(sourceTemplate, targetTemplate) {
124494
124245
  let properties = targetTemplate.properties;
124495
124246
  return properties.filter(targetProp => !sourceTemplate.properties.find(sourceProp => compareProps(sourceProp, targetProp)));
@@ -124500,13 +124251,6 @@
124500
124251
  function findPropertyWithBinding(template, prop1) {
124501
124252
  return template.properties.some(prop2 => areBindingsEqual(prop1.binding, prop2.binding));
124502
124253
  }
124503
- function getPropertiesToRemove(newTemplate, oldTemplate) {
124504
- const oldProperties = getMissingProperties(newTemplate, oldTemplate);
124505
-
124506
- // ensure XML properties are mantained for properties with
124507
- // different conditions but same bindings
124508
- return oldProperties.filter(property => !findPropertyWithBinding(newTemplate, property));
124509
- }
124510
124254
  function normalizeReplacer$1(key, value) {
124511
124255
  if (isObject$1(value)) {
124512
124256
  const keys = Object.keys(value).sort();
@@ -124539,9 +124283,6 @@
124539
124283
  function equals(a, b) {
124540
124284
  return JSON.stringify(a, normalizeReplacer$1) === JSON.stringify(b, normalizeReplacer$1);
124541
124285
  }
124542
- function hasMessageProperties(template) {
124543
- return template.properties.some(p => MESSAGE_BINDING_TYPES.includes(p.binding.type));
124544
- }
124545
124286
 
124546
124287
  /**
124547
124288
  * The BPMN 2.0 extension attribute name under
@@ -125321,16 +125062,87 @@
125321
125062
  return !is$6(eventDefinitions[0], eventDefinition);
125322
125063
  }
125323
125064
 
125065
+ function removeRootElement(rootElement, injector) {
125066
+ const modeling = injector.get('modeling'),
125067
+ canvas = injector.get('canvas'),
125068
+ bpmnjs = injector.get('bpmnjs');
125069
+ const element = canvas.getRootElement(),
125070
+ definitions = bpmnjs.getDefinitions(),
125071
+ rootElements = definitions.get('rootElements');
125072
+ const newRootElements = rootElements.filter(e => e !== rootElement);
125073
+
125074
+ // short-circuit to prevent unnecessary updates
125075
+ if (newRootElements.length === rootElements.length) {
125076
+ return;
125077
+ }
125078
+ modeling.updateModdleProperties(element, definitions, {
125079
+ rootElements: newRootElements
125080
+ });
125081
+ }
125082
+
125083
+ /**
125084
+ * Remove message from element and the diagram.
125085
+ *
125086
+ * @param {import('bpmn-js/lib/model/Types').Element} element
125087
+ * @param {import('didi').Injector} injector
125088
+ */
125089
+ function removeMessage(element, injector) {
125090
+ const modeling = injector.get('modeling');
125091
+ const bo = getReferringElement(element);
125092
+
125093
+ // Event does not have an event definition
125094
+ if (!bo) {
125095
+ return;
125096
+ }
125097
+ const message = findMessage(bo);
125098
+ if (!message) {
125099
+ return;
125100
+ }
125101
+ modeling.updateModdleProperties(element, bo, {
125102
+ messageRef: undefined
125103
+ });
125104
+ removeRootElement(message, injector);
125105
+ }
125106
+ function getReferringElement(element) {
125107
+ const bo = getBusinessObject$2(element);
125108
+ if (is$6(bo, 'bpmn:Event')) {
125109
+ return bo.get('eventDefinitions')[0];
125110
+ }
125111
+ return bo;
125112
+ }
125113
+
125324
125114
  /**
125325
125115
  * Applies an element template to an element. Sets `zeebe:modelerTemplate` and
125326
125116
  * `zeebe:modelerTemplateVersion`.
125327
125117
  */
125328
125118
  let ChangeElementTemplateHandler$1 = class ChangeElementTemplateHandler {
125329
- constructor(bpmnFactory, bpmnReplace, commandStack, modeling) {
125119
+ constructor(bpmnFactory, bpmnReplace, commandStack, injector) {
125330
125120
  this._bpmnFactory = bpmnFactory;
125331
125121
  this._bpmnReplace = bpmnReplace;
125332
- this._commandStack = commandStack;
125333
- this._modeling = modeling;
125122
+
125123
+ // Wrap commandStack and modeling to add hints to all commands
125124
+ this._commandStackWrapper = {
125125
+ execute: (event, context, ...rest) => {
125126
+ commandStack.execute(event, {
125127
+ hints: {
125128
+ skipConditionUpdate: true
125129
+ },
125130
+ ...context
125131
+ }, ...rest);
125132
+ }
125133
+ };
125134
+ this._modelingWrapper = {
125135
+ updateModdleProperties: (element, moddleElement, properties) => this._commandStackWrapper.execute('element.updateModdleProperties', {
125136
+ element,
125137
+ moddleElement,
125138
+ properties
125139
+ }),
125140
+ updateProperties: (element, properties) => this._commandStackWrapper.execute('element.updateProperties', {
125141
+ element,
125142
+ properties
125143
+ })
125144
+ };
125145
+ this._injector = injector;
125334
125146
  }
125335
125147
 
125336
125148
  /**
@@ -125355,11 +125167,8 @@
125355
125167
  // update zeebe:modelerTemplateIcon
125356
125168
  this._updateZeebeModelerTemplateIcon(element, newTemplate);
125357
125169
  if (newTemplate) {
125358
- // do not apply properties that don't meet conditions
125359
- newTemplate = applyConditions(element, newTemplate);
125360
-
125361
125170
  // update element type
125362
- element = context.element = this._updateElementType(element, newTemplate);
125171
+ element = context.element = this._updateElementType(element, oldTemplate, newTemplate);
125363
125172
 
125364
125173
  // update properties
125365
125174
  this._updateProperties(element, oldTemplate, newTemplate);
@@ -125375,18 +125184,12 @@
125375
125184
 
125376
125185
  // update zeebe:Property properties
125377
125186
  this._updateZeebePropertyProperties(element, oldTemplate, newTemplate);
125378
-
125379
- // update bpmn:Message properties
125380
- this._updateMessageProperties(element, oldTemplate, newTemplate);
125381
-
125382
- // update bpmn:Message zeebe:subscription properties
125383
- this._updateMessageZeebeSubscriptionProperties(element, oldTemplate, newTemplate);
125384
- this._updateZeebeModelerTemplateOnReferencedElement(element, oldTemplate, newTemplate);
125187
+ this._updateMessage(element, oldTemplate, newTemplate);
125385
125188
  }
125386
125189
  }
125387
125190
  _getOrCreateExtensionElements(element, businessObject = getBusinessObject$2(element)) {
125388
125191
  const bpmnFactory = this._bpmnFactory,
125389
- modeling = this._modeling;
125192
+ modeling = this._modelingWrapper;
125390
125193
  let extensionElements = businessObject.get('extensionElements');
125391
125194
  if (!extensionElements) {
125392
125195
  extensionElements = bpmnFactory.create('bpmn:ExtensionElements', {
@@ -125400,30 +125203,48 @@
125400
125203
  return extensionElements;
125401
125204
  }
125402
125205
  _updateZeebeModelerTemplate(element, newTemplate) {
125403
- const modeling = this._modeling;
125206
+ const modeling = this._modelingWrapper;
125404
125207
  modeling.updateProperties(element, {
125405
125208
  'zeebe:modelerTemplate': newTemplate && newTemplate.id,
125406
125209
  'zeebe:modelerTemplateVersion': newTemplate && newTemplate.version
125407
125210
  });
125408
125211
  }
125409
125212
  _updateZeebeModelerTemplateIcon(element, newTemplate) {
125410
- const modeling = this._modeling;
125213
+ const modeling = this._modelingWrapper;
125411
125214
  const icon = newTemplate && newTemplate.icon;
125412
125215
  modeling.updateProperties(element, {
125413
125216
  'zeebe:modelerTemplateIcon': icon && icon.contents
125414
125217
  });
125415
125218
  }
125416
125219
  _updateProperties(element, oldTemplate, newTemplate) {
125417
- const commandStack = this._commandStack;
125220
+ const commandStack = this._commandStackWrapper;
125221
+ const businessObject = getBusinessObject$2(element);
125418
125222
  const newProperties = newTemplate.properties.filter(newProperty => {
125419
125223
  const newBinding = newProperty.binding,
125420
125224
  newBindingType = newBinding.type;
125421
125225
  return newBindingType === 'property';
125422
125226
  });
125227
+
125228
+ // Remove old Properties if no new Properties specified
125229
+ const propertiesToRemove = oldTemplate && oldTemplate.properties.filter(oldProperty => {
125230
+ const oldBinding = oldProperty.binding,
125231
+ oldBindingType = oldBinding.type;
125232
+ return oldBindingType === 'property' && !newProperties.find(newProperty => newProperty.binding.name === oldProperty.binding.name);
125233
+ }) || [];
125234
+ if (propertiesToRemove.length) {
125235
+ const payload = propertiesToRemove.reduce((properties, property) => {
125236
+ properties[property.binding.name] = undefined;
125237
+ return properties;
125238
+ }, {});
125239
+ commandStack.execute('element.updateModdleProperties', {
125240
+ element,
125241
+ moddleElement: businessObject,
125242
+ properties: payload
125243
+ });
125244
+ }
125423
125245
  if (!newProperties.length) {
125424
125246
  return;
125425
125247
  }
125426
- const businessObject = getBusinessObject$2(element);
125427
125248
  newProperties.forEach(newProperty => {
125428
125249
  const oldProperty = findOldProperty$1(oldTemplate, newProperty),
125429
125250
  newBinding = newProperty.binding,
@@ -125453,34 +125274,42 @@
125453
125274
  */
125454
125275
  _updateZeebeTaskDefinition(element, oldTemplate, newTemplate) {
125455
125276
  const bpmnFactory = this._bpmnFactory,
125456
- commandStack = this._commandStack;
125277
+ commandStack = this._commandStackWrapper;
125457
125278
  const newProperties = newTemplate.properties.filter(newProperty => {
125458
125279
  const newBinding = newProperty.binding,
125459
125280
  newBindingType = newBinding.type;
125460
125281
  return TASK_DEFINITION_TYPES.includes(newBindingType);
125461
125282
  });
125283
+ const businessObject = this._getOrCreateExtensionElements(element);
125284
+ let taskDefinition = findExtension$1(businessObject, 'zeebe:TaskDefinition');
125285
+
125286
+ // (1) remove old task definition if no new properties specified
125462
125287
 
125463
- // (1) do not override old task definition if no new properties specified
125464
125288
  if (!newProperties.length) {
125289
+ commandStack.execute('element.updateModdleProperties', {
125290
+ element,
125291
+ moddleElement: businessObject,
125292
+ properties: {
125293
+ values: without(businessObject.get('values'), taskDefinition)
125294
+ }
125295
+ });
125465
125296
  return;
125466
125297
  }
125467
- const businessObject = this._getOrCreateExtensionElements(element);
125468
125298
  newProperties.forEach(newProperty => {
125469
125299
  const oldProperty = findOldProperty$1(oldTemplate, newProperty),
125470
- oldTaskDefinition = findBusinessObject(businessObject, newProperty),
125471
125300
  newPropertyValue = getDefaultValue(newProperty),
125472
125301
  newBinding = newProperty.binding,
125473
125302
  propertyName = getTaskDefinitionPropertyName(newBinding);
125474
125303
 
125475
125304
  // (2) update old task definition
125476
- if (oldTaskDefinition) {
125477
- if (!shouldKeepValue(oldTaskDefinition, oldProperty, newProperty)) {
125305
+ if (taskDefinition) {
125306
+ if (!shouldKeepValue(taskDefinition, oldProperty, newProperty)) {
125478
125307
  const properties = {
125479
125308
  [propertyName]: newPropertyValue
125480
125309
  };
125481
125310
  commandStack.execute('element.updateModdleProperties', {
125482
125311
  element,
125483
- moddleElement: oldTaskDefinition,
125312
+ moddleElement: taskDefinition,
125484
125313
  properties
125485
125314
  });
125486
125315
  }
@@ -125491,17 +125320,34 @@
125491
125320
  const properties = {
125492
125321
  [propertyName]: newPropertyValue
125493
125322
  };
125494
- const newTaskDefinition = createTaskDefinition(properties, bpmnFactory);
125495
- newTaskDefinition.$parent = businessObject;
125323
+ taskDefinition = createTaskDefinition(properties, bpmnFactory);
125324
+ taskDefinition.$parent = businessObject;
125496
125325
  commandStack.execute('element.updateModdleProperties', {
125497
125326
  element,
125498
125327
  moddleElement: businessObject,
125499
125328
  properties: {
125500
- values: [...businessObject.get('values'), newTaskDefinition]
125329
+ values: [...businessObject.get('values'), taskDefinition]
125501
125330
  }
125502
125331
  });
125503
125332
  }
125504
125333
  });
125334
+
125335
+ // (4) remove properties no longer templated
125336
+ const oldProperties = oldTemplate && oldTemplate.properties.filter(oldProperty => {
125337
+ const oldBinding = oldProperty.binding,
125338
+ oldBindingType = oldBinding.type;
125339
+ return TASK_DEFINITION_TYPES.includes(oldBindingType) && !newProperties.find(newProperty => newProperty.binding.property === oldProperty.binding.property);
125340
+ }) || [];
125341
+ oldProperties.forEach(oldProperty => {
125342
+ const properties = {
125343
+ [oldProperty.binding.property]: undefined
125344
+ };
125345
+ commandStack.execute('element.updateModdleProperties', {
125346
+ element,
125347
+ moddleElement: taskDefinition,
125348
+ properties
125349
+ });
125350
+ });
125505
125351
  }
125506
125352
 
125507
125353
  /**
@@ -125514,7 +125360,7 @@
125514
125360
  */
125515
125361
  _updateZeebeInputOutputParameterProperties(element, oldTemplate, newTemplate) {
125516
125362
  const bpmnFactory = this._bpmnFactory,
125517
- commandStack = this._commandStack;
125363
+ commandStack = this._commandStackWrapper;
125518
125364
  const newProperties = newTemplate.properties.filter(newProperty => {
125519
125365
  const newBinding = newProperty.binding,
125520
125366
  newBindingType = newBinding.type;
@@ -125641,7 +125487,7 @@
125641
125487
  */
125642
125488
  _updateZeebeTaskHeaderProperties(element, oldTemplate, newTemplate) {
125643
125489
  const bpmnFactory = this._bpmnFactory,
125644
- commandStack = this._commandStack;
125490
+ commandStack = this._commandStackWrapper;
125645
125491
  const newProperties = newTemplate.properties.filter(newProperty => {
125646
125492
  const newBinding = newProperty.binding,
125647
125493
  newBindingType = newBinding.type;
@@ -125731,7 +125577,7 @@
125731
125577
  */
125732
125578
  _updateZeebePropertyProperties(element, oldTemplate, newTemplate) {
125733
125579
  const bpmnFactory = this._bpmnFactory,
125734
- commandStack = this._commandStack;
125580
+ commandStack = this._commandStackWrapper;
125735
125581
  const newProperties = newTemplate.properties.filter(newProperty => {
125736
125582
  const newBinding = newProperty.binding,
125737
125583
  newBindingType = newBinding.type;
@@ -125812,6 +125658,17 @@
125812
125658
  });
125813
125659
  }
125814
125660
  }
125661
+ _updateMessage(element, oldTemplate, newTemplate) {
125662
+ // update bpmn:Message properties
125663
+ this._updateMessageProperties(element, oldTemplate, newTemplate);
125664
+
125665
+ // update bpmn:Message zeebe:subscription properties
125666
+ this._updateMessageZeebeSubscriptionProperties(element, oldTemplate, newTemplate);
125667
+ this._updateZeebeModelerTemplateOnReferencedElement(element, oldTemplate, newTemplate);
125668
+ if (!hasMessageProperties(newTemplate)) {
125669
+ removeMessage(element, this._injector);
125670
+ }
125671
+ }
125815
125672
 
125816
125673
  /**
125817
125674
  * Update bpmn:Message properties.
@@ -125826,10 +125683,21 @@
125826
125683
  newBindingType = newBinding.type;
125827
125684
  return newBindingType === MESSAGE_PROPERTY_TYPE;
125828
125685
  });
125686
+ const removedProperties = oldTemplate && oldTemplate.properties.filter(oldProperty => {
125687
+ const oldBinding = oldProperty.binding,
125688
+ oldBindingType = oldBinding.type;
125689
+ return oldBindingType === MESSAGE_PROPERTY_TYPE && !newProperties.find(newProperty => newProperty.binding.name === oldProperty.binding.name);
125690
+ }) || [];
125691
+ let message = this._getMessage(element);
125692
+ message && removedProperties.forEach(removedProperty => {
125693
+ this._modelingWrapper.updateModdleProperties(element, message, {
125694
+ [removedProperty.binding.name]: undefined
125695
+ });
125696
+ });
125829
125697
  if (!newProperties.length) {
125830
125698
  return;
125831
125699
  }
125832
- const message = this._getOrCreateMessage(element, newTemplate);
125700
+ message = this._getOrCreateMessage(element, newTemplate);
125833
125701
  newProperties.forEach(newProperty => {
125834
125702
  const oldProperty = findOldProperty$1(oldTemplate, newProperty),
125835
125703
  newBinding = newProperty.binding,
@@ -125841,7 +125709,7 @@
125841
125709
  return;
125842
125710
  }
125843
125711
  properties[newBindingName] = newPropertyValue;
125844
- this._modeling.updateModdleProperties(element, changedElement, properties);
125712
+ this._modelingWrapper.updateModdleProperties(element, changedElement, properties);
125845
125713
  });
125846
125714
  }
125847
125715
 
@@ -125858,24 +125726,50 @@
125858
125726
  newBindingType = newBinding.type;
125859
125727
  return newBindingType === MESSAGE_ZEEBE_SUBSCRIPTION_PROPERTY_TYPE;
125860
125728
  });
125861
- if (!newProperties.length) {
125729
+ const removedProperties = oldTemplate && oldTemplate.properties.filter(oldProperty => {
125730
+ const oldBinding = oldProperty.binding,
125731
+ oldBindingType = oldBinding.type;
125732
+ return oldBindingType === MESSAGE_ZEEBE_SUBSCRIPTION_PROPERTY_TYPE && !newProperties.find(newProperty => newProperty.binding.name === oldProperty.binding.name);
125733
+ }) || [];
125734
+ if (!newProperties.length && !removedProperties.length) {
125862
125735
  return;
125863
125736
  }
125864
125737
  const message = this._getOrCreateMessage(element, newTemplate);
125865
- const zeebeSubscription = this._getOrCreateExtension(element, message, 'zeebe:Subscription');
125866
- newProperties.forEach(newProperty => {
125738
+ const messageExtensionElements = this._getOrCreateExtensionElements(element, message);
125739
+ const zeebeSubscription = this._getSubscription(element, message);
125740
+ const propertiesToSet = newProperties.reduce((properties, newProperty) => {
125867
125741
  const oldProperty = findOldProperty$1(oldTemplate, newProperty),
125868
125742
  newBinding = newProperty.binding,
125869
125743
  newBindingName = newBinding.name,
125870
125744
  newPropertyValue = getDefaultValue(newProperty),
125871
125745
  changedElement = zeebeSubscription;
125872
- let properties = {};
125873
125746
  if (shouldKeepValue(changedElement, oldProperty, newProperty)) {
125874
- return;
125747
+ return properties;
125875
125748
  }
125876
125749
  properties[newBindingName] = newPropertyValue;
125877
- this._modeling.updateModdleProperties(element, changedElement, properties);
125878
- });
125750
+ return properties;
125751
+ }, {});
125752
+
125753
+ // Update zeebe Subscription
125754
+ if (zeebeSubscription) {
125755
+ this._modelingWrapper.updateModdleProperties(element, zeebeSubscription, propertiesToSet);
125756
+ } else {
125757
+ // create new Subscription
125758
+ const newSubscription = createElement$1('zeebe:Subscription', propertiesToSet, message, this._bpmnFactory);
125759
+ this._modelingWrapper.updateModdleProperties(element, messageExtensionElements, {
125760
+ values: [...messageExtensionElements.get('values'), newSubscription]
125761
+ });
125762
+ }
125763
+
125764
+ // Remove old properties
125765
+ if (!oldTemplate || !zeebeSubscription) {
125766
+ return;
125767
+ }
125768
+ const propertiesToRemove = removedProperties.reduce((properties, removedProperty) => {
125769
+ properties[removedProperty.binding.name] = undefined;
125770
+ return properties;
125771
+ }, {});
125772
+ this._modelingWrapper.updateModdleProperties(element, zeebeSubscription, propertiesToRemove);
125879
125773
  }
125880
125774
  _updateZeebeModelerTemplateOnReferencedElement(element, oldTemplate, newTemplate) {
125881
125775
  const businessObject = getBusinessObject$2(element);
@@ -125886,39 +125780,41 @@
125886
125780
  if (getTemplateId$1(message) === newTemplate.id) {
125887
125781
  return;
125888
125782
  }
125889
- this._modeling.updateModdleProperties(element, message, {
125783
+ this._modelingWrapper.updateModdleProperties(element, message, {
125890
125784
  'zeebe:modelerTemplate': newTemplate.id
125891
125785
  });
125892
125786
  }
125893
- _getOrCreateExtension(element, bo, type) {
125787
+ _getSubscription(element, bo) {
125894
125788
  const extensionElements = this._getOrCreateExtensionElements(element, bo);
125895
- const extension = findExtension$1(extensionElements, type);
125789
+ const extension = findExtension$1(extensionElements, 'zeebe:Subscription');
125896
125790
  if (extension) {
125897
125791
  return extension;
125898
125792
  }
125899
- const newExtension = createElement$1(type, {}, bo, this._bpmnFactory);
125900
- this._modeling.updateModdleProperties(element, extensionElements, {
125901
- values: [...extensionElements.get('values'), newExtension]
125902
- });
125903
- return newExtension;
125904
125793
  }
125905
125794
  _getOrCreateMessage(element, template) {
125795
+ return this._getMessage(element) || this._createMessage(element, template);
125796
+ }
125797
+ _createMessage(element, template) {
125906
125798
  let bo = getBusinessObject$2(element);
125907
125799
  if (is$6(bo, 'bpmn:Event')) {
125908
125800
  bo = bo.get('eventDefinitions')[0];
125909
125801
  }
125910
- let message = bo.get('messageRef');
125911
- if (!message) {
125912
- message = this._bpmnFactory.create('bpmn:Message', {
125913
- 'zeebe:modelerTemplate': template.id
125914
- });
125915
- message.$parent = getRoot(bo);
125916
- this._modeling.updateModdleProperties(element, bo, {
125917
- messageRef: message
125918
- });
125919
- }
125802
+ const message = this._bpmnFactory.create('bpmn:Message', {
125803
+ 'zeebe:modelerTemplate': template.id
125804
+ });
125805
+ message.$parent = getRoot(bo);
125806
+ this._modelingWrapper.updateModdleProperties(element, bo, {
125807
+ messageRef: message
125808
+ });
125920
125809
  return message;
125921
125810
  }
125811
+ _getMessage(element) {
125812
+ let bo = getBusinessObject$2(element);
125813
+ if (is$6(bo, 'bpmn:Event')) {
125814
+ bo = bo.get('eventDefinitions')[0];
125815
+ }
125816
+ return bo && bo.get('messageRef');
125817
+ }
125922
125818
 
125923
125819
  /**
125924
125820
  * Replaces the element with the specified elementType.
@@ -125927,12 +125823,18 @@
125927
125823
  * @param {djs.model.Base} element
125928
125824
  * @param {Object} newTemplate
125929
125825
  */
125930
- _updateElementType(element, newTemplate) {
125826
+ _updateElementType(element, oldTemplate, newTemplate) {
125931
125827
  // determine new task type
125932
125828
  const newType = newTemplate.elementType;
125933
125829
  if (!newType) {
125934
125830
  return element;
125935
125831
  }
125832
+ const oldType = oldTemplate && oldTemplate.elementType;
125833
+
125834
+ // Do not replace if the element type did not change
125835
+ if (oldType && oldType.value === newType.value && oldType.eventDefinition === newType.eventDefinition) {
125836
+ return element;
125837
+ }
125936
125838
  const replacement = {
125937
125839
  type: newType.value
125938
125840
  };
@@ -125943,7 +125845,7 @@
125943
125845
  return replacedElement;
125944
125846
  }
125945
125847
  };
125946
- ChangeElementTemplateHandler$1.$inject = ['bpmnFactory', 'bpmnReplace', 'commandStack', 'modeling'];
125848
+ ChangeElementTemplateHandler$1.$inject = ['bpmnFactory', 'bpmnReplace', 'commandStack', 'injector'];
125947
125849
 
125948
125850
  // helpers //////////
125949
125851
 
@@ -126142,6 +126044,9 @@
126142
126044
  }
126143
126045
  function getPropertyValue(element, property) {
126144
126046
  const businessObject = getBusinessObject$2(element);
126047
+ if (!businessObject) {
126048
+ return;
126049
+ }
126145
126050
  const binding = property.binding,
126146
126051
  bindingName = binding.name,
126147
126052
  bindingType = binding.type;
@@ -126178,6 +126083,9 @@
126178
126083
  array.splice(index, 1);
126179
126084
  return array;
126180
126085
  }
126086
+ function hasMessageProperties(template) {
126087
+ return template.properties.some(p => MESSAGE_BINDING_TYPES.includes(p.binding.type));
126088
+ }
126181
126089
 
126182
126090
  class RemoveElementTemplateHandler {
126183
126091
  constructor(modeling, elementFactory, elementRegistry, canvas, bpmnFactory, replace, commandStack) {