camunda-bpmn-js 3.12.0 → 3.12.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -37481,7 +37481,8 @@
37481
37481
  */
37482
37482
 
37483
37483
  /**
37484
- *
37484
+ * Behavior ensuring that only a single compensation activity is connected to a
37485
+ * compensation boundary event when connecting, reconnecting or replacing shapes.
37485
37486
  *
37486
37487
  * @param {import('diagram-js/lib/core/EventBus').default} eventBus
37487
37488
  * @param {import('../Modeling').default} modeling
@@ -37499,7 +37500,7 @@
37499
37500
  this.postExecuted('element.updateProperties', handlePropertiesUpdate, true);
37500
37501
 
37501
37502
  /**
37502
- * Given a connection from boundary event is removed, remove the forCompensation property.
37503
+ * Given a connection from boundary event is removed, remove the `isForCompensation` property.
37503
37504
  */
37504
37505
  function handleConnectionRemoval(context) {
37505
37506
  const source = context.source,
@@ -37511,15 +37512,16 @@
37511
37512
  }
37512
37513
 
37513
37514
  /**
37514
- * Add forCompensation property and make sure only a single compensation activity is connected.
37515
+ * Add `isForCompensation` property and make sure only a single compensation activity is connected.
37515
37516
  */
37516
37517
  function handleNewConnection(context) {
37517
- const source = context.source,
37518
+ const connection = context.connection,
37519
+ source = context.source,
37518
37520
  target = context.target;
37519
37521
 
37520
- if (isCompensationBoundaryEvent(source) && canBeForCompensation(target)) {
37522
+ if (isCompensationBoundaryEvent(source) && isForCompensationAllowed(target)) {
37521
37523
  addIsForCompensationProperty(target);
37522
- removeExistingAssociation(source);
37524
+ removeExistingAssociations(source, [ connection ]);
37523
37525
  }
37524
37526
  }
37525
37527
 
@@ -37538,7 +37540,7 @@
37538
37540
  }
37539
37541
 
37540
37542
  // newTarget perspective
37541
- if (isCompensationBoundaryEvent(source) && canBeForCompensation(newTarget)) {
37543
+ if (isCompensationBoundaryEvent(source) && isForCompensationAllowed(newTarget)) {
37542
37544
  addIsForCompensationProperty(newTarget);
37543
37545
  }
37544
37546
  }
@@ -37548,9 +37550,9 @@
37548
37550
  const { element } = context;
37549
37551
 
37550
37552
  if (isForCompensation$1(element)) {
37551
- removeIllegalConnections(element);
37553
+ removeDisallowedConnections(element);
37552
37554
  removeAttachments(element);
37553
- } else if (canBeForCompensation(element)) {
37555
+ } else if (isForCompensationAllowed(element)) {
37554
37556
  removeIncomingCompensationAssociations(element);
37555
37557
  }
37556
37558
  }
@@ -37584,7 +37586,7 @@
37584
37586
  targetElement.type === 'bpmn:BoundaryEvent'
37585
37587
  ) {
37586
37588
  const targetConnection = oldShape.outgoing.find(
37587
- ({ target }) => canBeForCompensation(target)
37589
+ ({ target }) => isForCompensationAllowed(target)
37588
37590
  );
37589
37591
 
37590
37592
  if (targetConnection && targetConnection.target) {
@@ -37611,7 +37613,7 @@
37611
37613
  modeling.updateProperties(target, { isForCompensation: undefined });
37612
37614
  }
37613
37615
 
37614
- function removeIllegalConnections(element) {
37616
+ function removeDisallowedConnections(element) {
37615
37617
 
37616
37618
  for (const connection of element.incoming) {
37617
37619
  if (!bpmnRules.canConnect(connection.source, element)) {
@@ -37626,9 +37628,11 @@
37626
37628
  }
37627
37629
  }
37628
37630
 
37629
- function removeExistingAssociation(boundaryEvent) {
37631
+ function removeExistingAssociations(boundaryEvent, ignoredAssociations) {
37630
37632
  const associations = boundaryEvent.outgoing.filter(connection => is$6(connection, 'bpmn:Association'));
37631
- const associationsToRemove = associations.filter(association => isForCompensation$1(association.target));
37633
+ const associationsToRemove = associations.filter(association => {
37634
+ return isForCompensation$1(association.target) && !ignoredAssociations.includes(association);
37635
+ });
37632
37636
 
37633
37637
  // remove existing associations
37634
37638
  associationsToRemove.forEach(association => modeling.removeConnection(association));
@@ -37681,7 +37685,7 @@
37681
37685
  hasEventDefinition$3(element, 'bpmn:CompensateEventDefinition');
37682
37686
  }
37683
37687
 
37684
- function canBeForCompensation(element) {
37688
+ function isForCompensationAllowed(element) {
37685
37689
  return element && is$6(element, 'bpmn:Activity') && !isEventSubProcess(element);
37686
37690
  }
37687
37691