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

View File

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

View File

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

View File

@ -28,24 +28,15 @@ CustomRules.prototype.init = function() {
return canConnect(source, target); return canConnect(source, target);
}); });
this.addRule('connection.reconnectStart', HIGH_PRIORITY, function(context) { this.addRule('connection.reconnect', HIGH_PRIORITY, function(context) {
var connection = context.connection, var connection = context.connection,
source = context.hover || context.source, source = context.source,
target = connection.target; target = connection.target;
return canConnect(source, target, connection); 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) { this.addRule('connection.updateWaypoints', HIGH_PRIORITY, function(context) {
// OK! but visually ignore // 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:Activity',
'bpmn:EndEvent', '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:Activity',
'bpmn:EndEvent', 'bpmn:EndEvent',