bpmn-js 10.2.0 → 10.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * bpmn-js - bpmn-modeler v10.2.0
2
+ * bpmn-js - bpmn-modeler v10.2.1
3
3
  *
4
4
  * Copyright (c) 2014-present, camunda Services GmbH
5
5
  *
@@ -8,7 +8,7 @@
8
8
  *
9
9
  * Source Code: https://github.com/bpmn-io/bpmn-js
10
10
  *
11
- * Date: 2022-10-02
11
+ * Date: 2022-10-17
12
12
  */
13
13
  (function (global, factory) {
14
14
  typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
@@ -43218,62 +43218,75 @@
43218
43218
  CommandInterceptor.call(this, eventBus);
43219
43219
 
43220
43220
  /**
43221
- * Remove existing sequence flows of event-based target before connecting
43222
- * from event-based gateway.
43221
+ * Remove incoming sequence flows of event-based target when creating
43222
+ * sequence flow.
43223
+ *
43224
+ * 1. If source is event-based gateway remove all incoming sequence flows
43225
+ * 2. If source is not event-based gateway remove all incoming sequence flows
43226
+ * whose source is event-based gateway
43223
43227
  */
43224
43228
  this.preExecuted('connection.create', function(event) {
43225
-
43226
43229
  var context = event.context,
43230
+ connection = context.connection,
43227
43231
  source = context.source,
43228
43232
  target = context.target,
43229
- existingIncomingConnections = target.incoming.slice();
43233
+ hints = context.hints;
43230
43234
 
43231
- if (context.hints && context.hints.createElementsBehavior === false) {
43235
+ if (hints && hints.createElementsBehavior === false) {
43232
43236
  return;
43233
43237
  }
43234
43238
 
43235
- if (
43236
- is$1(source, 'bpmn:EventBasedGateway') &&
43237
- target.incoming.length
43238
- ) {
43239
+ if (!isSequenceFlow(connection)) {
43240
+ return;
43241
+ }
43239
43242
 
43240
- existingIncomingConnections.filter(isSequenceFlow)
43241
- .forEach(function(sequenceFlow) {
43242
- modeling.removeConnection(sequenceFlow);
43243
- });
43243
+ var sequenceFlows = [];
43244
+
43245
+ if (is$1(source, 'bpmn:EventBasedGateway')) {
43246
+ sequenceFlows = target.incoming.filter(isSequenceFlow);
43247
+ } else {
43248
+ sequenceFlows = target.incoming.filter(function(connection) {
43249
+ return isSequenceFlow(connection)
43250
+ && is$1(connection.source, 'bpmn:EventBasedGateway');
43251
+ });
43244
43252
  }
43253
+
43254
+ sequenceFlows.forEach(function(sequenceFlow) {
43255
+ modeling.removeConnection(sequenceFlow);
43256
+ });
43245
43257
  });
43246
43258
 
43247
43259
  /**
43248
- * After replacing shape with event-based gateway, remove incoming sequence
43249
- * flows of event-based targets which do not belong to event-based gateway
43250
- * source.
43260
+ * Remove incoming sequence flows of event-based targets when replacing source
43261
+ * with event-based gateway.
43251
43262
  */
43252
43263
  this.preExecuted('shape.replace', function(event) {
43253
-
43254
- var newShape = event.context.newShape,
43255
- newShapeTargets,
43256
- newShapeTargetsIncomingSequenceFlows;
43264
+ var context = event.context,
43265
+ newShape = context.newShape;
43257
43266
 
43258
43267
  if (!is$1(newShape, 'bpmn:EventBasedGateway')) {
43259
43268
  return;
43260
43269
  }
43261
43270
 
43262
- newShapeTargets = newShape.outgoing.filter(isSequenceFlow)
43263
- .map(function(sequenceFlow) {
43264
- return sequenceFlow.target;
43265
- });
43271
+ var targets = newShape.outgoing.filter(isSequenceFlow)
43272
+ .reduce(function(targets, sequenceFlow) {
43273
+ if (!targets.includes(sequenceFlow.target)) {
43274
+ return targets.concat(sequenceFlow.target);
43275
+ }
43266
43276
 
43267
- newShapeTargetsIncomingSequenceFlows = newShapeTargets.reduce(function(sequenceFlows, target) {
43268
- var incomingSequenceFlows = target.incoming.filter(isSequenceFlow);
43277
+ return targets;
43278
+ }, []);
43269
43279
 
43270
- return sequenceFlows.concat(incomingSequenceFlows);
43271
- }, []);
43280
+ targets.forEach(function(target) {
43281
+ target.incoming.filter(isSequenceFlow).forEach(function(sequenceFlow) {
43282
+ const sequenceFlowsFromNewShape = target.incoming.filter(isSequenceFlow).filter(function(sequenceFlow) {
43283
+ return sequenceFlow.source === newShape;
43284
+ });
43272
43285
 
43273
- newShapeTargetsIncomingSequenceFlows.forEach(function(sequenceFlow) {
43274
- if (sequenceFlow.source !== newShape) {
43275
- modeling.removeConnection(sequenceFlow);
43276
- }
43286
+ if (sequenceFlow.source !== newShape || sequenceFlowsFromNewShape.length > 1) {
43287
+ modeling.removeConnection(sequenceFlow);
43288
+ }
43289
+ });
43277
43290
  });
43278
43291
  });
43279
43292
  }
@@ -43285,9 +43298,7 @@
43285
43298
 
43286
43299
  e(EventBasedGatewayBehavior, CommandInterceptor);
43287
43300
 
43288
-
43289
-
43290
- // helpers //////////////////////
43301
+ // helpers //////////
43291
43302
 
43292
43303
  function isSequenceFlow(connection) {
43293
43304
  return is$1(connection, 'bpmn:SequenceFlow');
@@ -48088,16 +48099,6 @@
48088
48099
  }
48089
48100
 
48090
48101
  function canConnectSequenceFlow(source, target) {
48091
-
48092
- if (
48093
- isEventBasedTarget(target) &&
48094
- target.incoming.length > 0 &&
48095
- areOutgoingEventBasedGatewayConnections(target.incoming) &&
48096
- !is$1(source, 'bpmn:EventBasedGateway')
48097
- ) {
48098
- return false;
48099
- }
48100
-
48101
48102
  return isSequenceFlowSource(source) &&
48102
48103
  isSequenceFlowTarget(target) &&
48103
48104
  isSameScope(source, target) &&
@@ -48169,19 +48170,6 @@
48169
48170
  return true;
48170
48171
  }
48171
48172
 
48172
- function isOutgoingEventBasedGatewayConnection(connection) {
48173
-
48174
- if (connection && connection.source) {
48175
- return is$1(connection.source, 'bpmn:EventBasedGateway');
48176
- }
48177
- }
48178
-
48179
- function areOutgoingEventBasedGatewayConnections(connections) {
48180
- connections = connections || [];
48181
-
48182
- return connections.some(isOutgoingEventBasedGatewayConnection);
48183
- }
48184
-
48185
48173
  function getRootElement(element) {
48186
48174
  return getParent(element, 'bpmn:Process') || getParent(element, 'bpmn:Collaboration');
48187
48175
  }