bpmn-js 16.3.0 → 16.3.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.
@@ -11,7 +11,8 @@ import { hasEventDefinition, isEventSubProcess } from '../../../util/DiUtil';
11
11
  */
12
12
 
13
13
  /**
14
- *
14
+ * Behavior ensuring that only a single compensation activity is connected to a
15
+ * compensation boundary event when connecting, reconnecting or replacing shapes.
15
16
  *
16
17
  * @param {import('diagram-js/lib/core/EventBus').default} eventBus
17
18
  * @param {import('../Modeling').default} modeling
@@ -29,7 +30,7 @@ export default function CompensateBoundaryEventBehavior(eventBus, modeling, bpmn
29
30
  this.postExecuted('element.updateProperties', handlePropertiesUpdate, true);
30
31
 
31
32
  /**
32
- * Given a connection from boundary event is removed, remove the forCompensation property.
33
+ * Given a connection from boundary event is removed, remove the `isForCompensation` property.
33
34
  */
34
35
  function handleConnectionRemoval(context) {
35
36
  const source = context.source,
@@ -41,15 +42,16 @@ export default function CompensateBoundaryEventBehavior(eventBus, modeling, bpmn
41
42
  }
42
43
 
43
44
  /**
44
- * Add forCompensation property and make sure only a single compensation activity is connected.
45
+ * Add `isForCompensation` property and make sure only a single compensation activity is connected.
45
46
  */
46
47
  function handleNewConnection(context) {
47
- const source = context.source,
48
+ const connection = context.connection,
49
+ source = context.source,
48
50
  target = context.target;
49
51
 
50
- if (isCompensationBoundaryEvent(source) && canBeForCompensation(target)) {
52
+ if (isCompensationBoundaryEvent(source) && isForCompensationAllowed(target)) {
51
53
  addIsForCompensationProperty(target);
52
- removeExistingAssociation(source);
54
+ removeExistingAssociations(source, [ connection ]);
53
55
  }
54
56
  }
55
57
 
@@ -68,7 +70,7 @@ export default function CompensateBoundaryEventBehavior(eventBus, modeling, bpmn
68
70
  }
69
71
 
70
72
  // newTarget perspective
71
- if (isCompensationBoundaryEvent(source) && canBeForCompensation(newTarget)) {
73
+ if (isCompensationBoundaryEvent(source) && isForCompensationAllowed(newTarget)) {
72
74
  addIsForCompensationProperty(newTarget);
73
75
  }
74
76
  }
@@ -78,9 +80,9 @@ export default function CompensateBoundaryEventBehavior(eventBus, modeling, bpmn
78
80
  const { element } = context;
79
81
 
80
82
  if (isForCompensation(element)) {
81
- removeIllegalConnections(element);
83
+ removeDisallowedConnections(element);
82
84
  removeAttachments(element);
83
- } else if (canBeForCompensation(element)) {
85
+ } else if (isForCompensationAllowed(element)) {
84
86
  removeIncomingCompensationAssociations(element);
85
87
  }
86
88
  }
@@ -90,13 +92,15 @@ export default function CompensateBoundaryEventBehavior(eventBus, modeling, bpmn
90
92
  * and remove the potential candidates for connection replacement to have a single compensation activity.
91
93
  */
92
94
  function handleReplacement(context) {
93
- const { targetElement } = context.hints || {},
94
- { oldShape } = context;
95
+ const {
96
+ newData,
97
+ oldShape
98
+ } = context;
95
99
 
96
100
  // from compensate boundary event
97
101
  if (isCompensationBoundaryEvent(context.oldShape) &&
98
- targetElement.eventDefinitionType !== 'bpmn:CompensateEventDefinition' ||
99
- targetElement.type !== 'bpmn:BoundaryEvent'
102
+ newData.eventDefinitionType !== 'bpmn:CompensateEventDefinition' ||
103
+ newData.type !== 'bpmn:BoundaryEvent'
100
104
  ) {
101
105
  const targetConnection = oldShape.outgoing.find(
102
106
  ({ target }) => isForCompensation(target)
@@ -110,11 +114,11 @@ export default function CompensateBoundaryEventBehavior(eventBus, modeling, bpmn
110
114
  // to compensate boundary event
111
115
  else if (
112
116
  !isCompensationBoundaryEvent(context.oldShape) &&
113
- targetElement.eventDefinitionType === 'bpmn:CompensateEventDefinition' &&
114
- targetElement.type === 'bpmn:BoundaryEvent'
117
+ newData.eventDefinitionType === 'bpmn:CompensateEventDefinition' &&
118
+ newData.type === 'bpmn:BoundaryEvent'
115
119
  ) {
116
120
  const targetConnection = oldShape.outgoing.find(
117
- ({ target }) => canBeForCompensation(target)
121
+ ({ target }) => isForCompensationAllowed(target)
118
122
  );
119
123
 
120
124
  if (targetConnection && targetConnection.target) {
@@ -141,7 +145,7 @@ export default function CompensateBoundaryEventBehavior(eventBus, modeling, bpmn
141
145
  modeling.updateProperties(target, { isForCompensation: undefined });
142
146
  }
143
147
 
144
- function removeIllegalConnections(element) {
148
+ function removeDisallowedConnections(element) {
145
149
 
146
150
  for (const connection of element.incoming) {
147
151
  if (!bpmnRules.canConnect(connection.source, element)) {
@@ -156,9 +160,11 @@ export default function CompensateBoundaryEventBehavior(eventBus, modeling, bpmn
156
160
  }
157
161
  }
158
162
 
159
- function removeExistingAssociation(boundaryEvent) {
163
+ function removeExistingAssociations(boundaryEvent, ignoredAssociations) {
160
164
  const associations = boundaryEvent.outgoing.filter(connection => is(connection, 'bpmn:Association'));
161
- const associationsToRemove = associations.filter(association => isForCompensation(association.target));
165
+ const associationsToRemove = associations.filter(association => {
166
+ return isForCompensation(association.target) && !ignoredAssociations.includes(association);
167
+ });
162
168
 
163
169
  // remove existing associations
164
170
  associationsToRemove.forEach(association => modeling.removeConnection(association));
@@ -211,6 +217,6 @@ function isCompensationBoundaryEvent(element) {
211
217
  hasEventDefinition(element, 'bpmn:CompensateEventDefinition');
212
218
  }
213
219
 
214
- function canBeForCompensation(element) {
220
+ function isForCompensationAllowed(element) {
215
221
  return element && is(element, 'bpmn:Activity') && !isEventSubProcess(element);
216
222
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "bpmn-js",
3
- "version": "16.3.0",
3
+ "version": "16.3.2",
4
4
  "description": "A bpmn 2.0 toolkit and web modeler",
5
5
  "main": "index.js",
6
6
  "files": [