chore(rules): remove <connection.reconnectStart/End> rule

This commit is contained in:
Philipp Fromme 2019-11-14 08:52:19 +01:00 committed by Nico Rehwaldt
parent 1fa167088c
commit 06e1478fc8
7 changed files with 48 additions and 176 deletions

View File

@ -178,16 +178,14 @@ export default function BpmnUpdater(
'connection.create',
'connection.move',
'connection.delete',
'connection.reconnectEnd',
'connection.reconnectStart'
'connection.reconnect'
], ifBpmn(updateConnection));
this.reverted([
'connection.create',
'connection.move',
'connection.delete',
'connection.reconnectEnd',
'connection.reconnectStart'
'connection.reconnect'
], ifBpmn(updateConnection));
@ -208,85 +206,56 @@ export default function BpmnUpdater(
'connection.updateWaypoints',
], ifBpmn(updateConnectionWaypoints));
// update Default & Conditional flows
this.executed([
'connection.reconnectEnd',
'connection.reconnectStart'
], ifBpmn(function(e) {
var context = e.context,
// update conditional/default flows
this.executed('connection.reconnect', ifBpmn(function(event) {
var context = event.context,
connection = context.connection,
businessObject = getBusinessObject(connection),
oldSource = getBusinessObject(context.oldSource),
oldTarget = getBusinessObject(context.oldTarget),
newSource = getBusinessObject(connection.source),
newTarget = getBusinessObject(connection.target);
oldSource = context.oldSource,
newSource = context.newSource,
connectionBo = getBusinessObject(connection),
oldSourceBo = getBusinessObject(oldSource),
newSourceBo = getBusinessObject(newSource);
if (oldSource === newSource || oldTarget === newTarget) {
return;
}
// on reconnectStart -> default flow
if (oldSource && oldSource.default === businessObject) {
context.default = oldSource.default;
oldSource.default = undefined;
}
// on reconnectEnd -> default flow
if ((businessObject.sourceRef && businessObject.sourceRef.default) &&
!isAny(newTarget, [
// remove condition from connection on reconnect to new source
// if new source can NOT have condional sequence flow
if (connectionBo.conditionExpression && !isAny(newSourceBo, [
'bpmn:Activity',
'bpmn:EndEvent',
'bpmn:Gateway',
'bpmn:IntermediateThrowEvent',
'bpmn:IntermediateCatchEvent'
'bpmn:ExclusiveGateway',
'bpmn:InclusiveGateway'
])) {
context.default = businessObject.sourceRef.default;
businessObject.sourceRef.default = undefined;
context.oldConditionExpression = connectionBo.conditionExpression;
delete connectionBo.conditionExpression;
}
// on reconnectStart -> conditional flow
if (oldSource && (businessObject.conditionExpression) &&
!(is(newSource, 'bpmn:Activity') ||
is(newSource, 'bpmn:Gateway'))) {
context.conditionExpression = businessObject.conditionExpression;
businessObject.conditionExpression = undefined;
}
// remove default from old source flow on reconnect to new source
// if source changed
if (oldSource !== newSource && oldSourceBo.default === connectionBo) {
context.oldDefault = oldSourceBo.default;
// on reconnectEnd -> conditional flow
if (oldTarget && (businessObject.conditionExpression) &&
!isAny(newTarget, [
'bpmn:Activity',
'bpmn:EndEvent',
'bpmn:Gateway',
'bpmn:IntermediateThrowEvent',
'bpmn:IntermediateCatchEvent'
])) {
context.conditionExpression = businessObject.conditionExpression;
businessObject.conditionExpression = undefined;
delete oldSourceBo.default;
}
}));
this.reverted([
'connection.reconnectEnd',
'connection.reconnectStart'
], ifBpmn(function(e) {
var context = e.context,
this.reverted('connection.reconnect', ifBpmn(function(event) {
var context = event.context,
connection = context.connection,
businessObject = getBusinessObject(connection),
newSource = getBusinessObject(connection.source);
oldSource = context.oldSource,
newSource = context.newSource,
connectionBo = getBusinessObject(connection),
oldSourceBo = getBusinessObject(oldSource),
newSourceBo = getBusinessObject(newSource);
// default flow
if (context.default) {
if (is(newSource, 'bpmn:ExclusiveGateway') || is(newSource, 'bpmn:InclusiveGateway') ||
is(newSource, 'bpmn:Activity')) {
newSource.default = context.default;
}
// add condition to connection on revert reconnect to new source
if (context.oldConditionExpression) {
connectionBo.conditionExpression = context.oldConditionExpression;
}
// conditional flow
if (context.conditionExpression && is(newSource, 'bpmn:Activity')) {
businessObject.conditionExpression = context.conditionExpression;
// add default to old source on revert reconnect to new source
if (context.oldDefault) {
oldSourceBo.default = context.oldDefault;
delete newSourceBo.default;
}
}));

View File

@ -40,7 +40,7 @@ export default function BoundaryEventBehavior(eventBus, modeling) {
});
// remove after replacing connected gateway with event-based gateway
this.postExecute('connection.reconnectStart', function(event) {
this.postExecute('connection.reconnect', function(event) {
var oldSource = event.context.oldSource,
newSource = event.context.newSource;

View File

@ -39,14 +39,14 @@ export default function DataInputAssociationBehavior(eventBus, bpmnFactory) {
'connection.create',
'connection.delete',
'connection.move',
'connection.reconnectEnd'
'connection.reconnect'
], ifDataInputAssociation(fixTargetRef));
this.reverted([
'connection.create',
'connection.delete',
'connection.move',
'connection.reconnectEnd'
'connection.reconnect'
], ifDataInputAssociation(fixTargetRef));

View File

@ -146,11 +146,7 @@ export default function ReplaceConnectionBehavior(eventBus, modeling, bpmnRules,
forEach(allConnections, fixConnection);
}, true);
this.preExecute([
'connection.reconnect',
'connection.reconnectStart',
'connection.reconnectEnd'
], replaceReconnectedConnection);
this.preExecute('connection.reconnect', replaceReconnectedConnection);
this.postExecuted('element.updateProperties', function(event) {
var context = event.context,
@ -159,7 +155,7 @@ export default function ReplaceConnectionBehavior(eventBus, modeling, bpmnRules,
businessObject = element.businessObject,
connection;
// remove condition expression when morphing to default flow
// remove condition on change to default
if (properties.default) {
connection = find(
element.outgoing,
@ -171,7 +167,7 @@ export default function ReplaceConnectionBehavior(eventBus, modeling, bpmnRules,
}
}
// remove default property from source when morphing to conditional flow
// remove default from source on change to conditional
if (properties.conditionExpression && businessObject.sourceRef.default === businessObject) {
modeling.updateProperties(element.source, { default: undefined });
}

View File

@ -87,24 +87,6 @@ BpmnRules.prototype.init = function() {
}
});
this.addRule('connection.reconnectStart', function(context) {
var connection = context.connection,
source = context.hover || context.source,
target = connection.target;
return canConnect(source, target, connection);
});
this.addRule('connection.reconnectEnd', function(context) {
var connection = context.connection,
source = connection.source,
target = context.hover || context.target;
return canConnect(source, target, connection);
});
this.addRule('connection.reconnect', function(context) {
var connection = context.connection,

View File

@ -28,24 +28,15 @@ CustomRules.prototype.init = function() {
return canConnect(source, target);
});
this.addRule('connection.reconnectStart', HIGH_PRIORITY, function(context) {
this.addRule('connection.reconnect', HIGH_PRIORITY, function(context) {
var connection = context.connection,
source = context.hover || context.source,
source = context.source,
target = connection.target;
return canConnect(source, target, connection);
});
this.addRule('connection.reconnectEnd', HIGH_PRIORITY, function(context) {
var connection = context.connection,
source = connection.source,
target = context.hover || context.target;
return canConnect(source, target, connection);
});
this.addRule('connection.updateWaypoints', HIGH_PRIORITY, function(context) {
// OK! but visually ignore

View File

@ -1353,40 +1353,6 @@ describe('features/popup-menu - replace menu provider', function() {
);
[
'bpmn:StartEvent'
].forEach(function(type) {
it('should replace DefaultFlow with SequenceFlow when changing target to ' + type,
inject(function(elementRegistry, elementFactory, canvas, popupMenu, modeling) {
// given
var sequenceFlow = elementRegistry.get('SequenceFlow_1'),
root = canvas.getRootElement();
var intermediateEvent = elementFactory.createShape({ type: type });
modeling.createShape(intermediateEvent, { x: 686, y: 50 }, root);
openPopup(sequenceFlow);
triggerAction(popupMenu, 'replace-with-default-flow');
// when
modeling.reconnectEnd(sequenceFlow, intermediateEvent, [
{ x: 686, y: 267, original: { x: 686, y: 307 } },
{ x: 686, y: 50, original: { x: 686, y: 75 } }
]);
var gateway = elementRegistry.get('ExclusiveGateway_1');
// then
expect(gateway.businessObject.default).not.to.exist;
})
);
});
[
'bpmn:Activity',
'bpmn:EndEvent',
@ -1686,38 +1652,6 @@ describe('features/popup-menu - replace menu provider', function() {
);
[
'bpmn:StartEvent'
].forEach(function(type) {
it('should replace ConditionalFlow with SequenceFlow when changing target to ' + type,
inject(function(elementRegistry, elementFactory, canvas, popupMenu, modeling) {
// given
var sequenceFlow = elementRegistry.get('SequenceFlow_3'),
root = canvas.getRootElement(),
intermediateEvent = elementFactory.createShape({ type: type });
modeling.createShape(intermediateEvent, { x: 497, y: 197 }, root);
openPopup(sequenceFlow);
triggerAction(popupMenu, 'replace-with-conditional-flow');
// when
modeling.reconnectEnd(sequenceFlow, intermediateEvent, [
{ x: 389, y: 197, original: { x: 389, y: 197 } },
{ x: 497, y: 197, original: { x: 497, y: 197 } }
]);
// then
expect(sequenceFlow.businessObject.conditionExpression).not.to.exist;
})
);
});
[
'bpmn:Activity',
'bpmn:EndEvent',