feat(modeling/BpmnLayouter): layout Element -> Element loops

Closes #824
This commit is contained in:
Philipp Fromme 2018-07-11 16:33:42 +02:00 committed by Nico Rehwaldt
parent 220c0a73f3
commit e637a8e57b
4 changed files with 39 additions and 10 deletions

View File

@ -105,10 +105,17 @@ BpmnLayouter.prototype.layoutConnection = function(connection, hints) {
//
// (1) outgoing of BoundaryEvents -> layout based on attach orientation and target orientation
// (2) incoming / outgoing of Gateway -> v:h (outgoing), h:v (incoming)
// (3) loops from / to the same element
//
if (is(connection, 'bpmn:SequenceFlow') ||
isCompensationAssociation(connection)) {
if (source === target) {
manhattanOptions = {
preferredLayouts: [ 'b:l' ]
};
} else
if (is(source, 'bpmn:BoundaryEvent')) {
manhattanOptions = {
@ -136,6 +143,7 @@ BpmnLayouter.prototype.layoutConnection = function(connection, hints) {
preferredLayouts: [ 'h:h' ]
};
}
}
if (manhattanOptions) {

View File

@ -378,15 +378,6 @@ function canConnect(source, target, connection) {
return null;
}
// See https://github.com/bpmn-io/bpmn-js/issues/178
// as a workround we disallow connections with same
// target and source element.
// This rule must be removed if a auto layout for this
// connections is implemented.
if (isSame(source, target)) {
return false;
}
if (!is(connection, 'bpmn:DataAssociation')) {
if (canConnectMessageFlow(source, target)) {

View File

@ -18,7 +18,6 @@ import coreModule from 'lib/core';
describe('features/modeling - layout', function() {
describe.skip('overall experience, flow elements', function() {
var diagramXML = require('./LayoutSequenceFlowSpec.flowElements.bpmn');
@ -177,6 +176,26 @@ describe('features/modeling - layout', function() {
beforeEach(bootstrapModeler(diagramXML, { modules: testModules }));
describe('loops', function() {
it('should layout loop', function() {
// when
var connection = connect('Task_1', 'Task_1');
// then
expect(connection).to.have.waypoints([
{ x: 332, y: 260 },
{ x: 332, y: 280 },
{ x: 262, y: 280 },
{ x: 262, y: 220 },
{ x: 282, y: 220 }
]);
});
});
describe('gateway layout', function() {
it('should layout v:h after Gateway', inject(function() {

View File

@ -328,6 +328,17 @@ describe('features/modeling/rules - BpmnRules', function() {
});
}));
it('connect Task -> Task', inject(function() {
expectCanConnect('Task', 'Task', {
sequenceFlow: true,
messageFlow: false,
association: false,
dataAssociation: false
});
}));
});