fix(bpmn-rules): adjust canAttach rule for boundary events after event based gateways

This commit is contained in:
Niklas Kiefer 2018-10-16 11:07:28 +02:00 committed by merge-me[bot]
parent ba42e9edde
commit ea681df2d3
2 changed files with 49 additions and 0 deletions

View File

@ -555,6 +555,15 @@ function isBoundaryCandidate(element) {
(is(element, 'bpmn:IntermediateThrowEvent') && !element.parent); (is(element, 'bpmn:IntermediateThrowEvent') && !element.parent);
} }
function isReceiveTaskAfterEventBasedGateway(element) {
return (
is(element, 'bpmn:ReceiveTask') &&
find(element.incoming, function(incoming) {
return is(incoming.source, 'bpmn:EventBasedGateway');
})
);
}
function canAttach(elements, target, source, position) { function canAttach(elements, target, source, position) {
@ -604,6 +613,11 @@ function canAttach(elements, target, source, position) {
return false; return false;
} }
// do not attach on receive tasks after event based gateways
if (isReceiveTaskAfterEventBasedGateway(target)) {
return false;
}
return 'attach'; return 'attach';
} }

View File

@ -1377,6 +1377,41 @@ describe('features/modeling/rules - BpmnRules', function() {
} }
)); ));
it('not attach IntermediateEvent to ReceiveTask after EventBasedGateway', inject(
function(canvas, modeling, elementFactory, bpmnRules) {
// given
var rootElement = canvas.getRootElement(),
eventBasedGatewayShape = elementFactory.createShape({ type: 'bpmn:EventBasedGateway' }),
receiveTaskShape = elementFactory.createShape({ type: 'bpmn:ReceiveTask' }),
eventShape = elementFactory.createShape({
type: 'bpmn:IntermediateThrowEvent',
x: 0, y: 0
});
var boundaryPosition = {
x: 175,
y: 100 + receiveTaskShape.height
};
// when
modeling.createShape(eventBasedGatewayShape, { x: 100, y: 100 }, rootElement);
modeling.createShape(receiveTaskShape, { x : 150, y: 100 }, rootElement);
modeling.connect(eventBasedGatewayShape, receiveTaskShape, {
type: 'bpmn:SequenceFlow'
});
var canAttach = bpmnRules.canAttach(
[ eventShape ],
receiveTaskShape,
null,
boundaryPosition
);
// then
expect(canAttach).to.be.false;
}
));
it('create IntermediateEvent in SubProcess body', inject( it('create IntermediateEvent in SubProcess body', inject(
function(elementFactory, elementRegistry, bpmnRules) { function(elementFactory, elementRegistry, bpmnRules) {