feat(modeling/BpmnLayouter): layout Element -> Element loops
Closes #824
This commit is contained in:
parent
220c0a73f3
commit
e637a8e57b
|
@ -105,10 +105,17 @@ BpmnLayouter.prototype.layoutConnection = function(connection, hints) {
|
||||||
//
|
//
|
||||||
// (1) outgoing of BoundaryEvents -> layout based on attach orientation and target orientation
|
// (1) outgoing of BoundaryEvents -> layout based on attach orientation and target orientation
|
||||||
// (2) incoming / outgoing of Gateway -> v:h (outgoing), h:v (incoming)
|
// (2) incoming / outgoing of Gateway -> v:h (outgoing), h:v (incoming)
|
||||||
|
// (3) loops from / to the same element
|
||||||
//
|
//
|
||||||
if (is(connection, 'bpmn:SequenceFlow') ||
|
if (is(connection, 'bpmn:SequenceFlow') ||
|
||||||
isCompensationAssociation(connection)) {
|
isCompensationAssociation(connection)) {
|
||||||
|
|
||||||
|
if (source === target) {
|
||||||
|
manhattanOptions = {
|
||||||
|
preferredLayouts: [ 'b:l' ]
|
||||||
|
};
|
||||||
|
} else
|
||||||
|
|
||||||
if (is(source, 'bpmn:BoundaryEvent')) {
|
if (is(source, 'bpmn:BoundaryEvent')) {
|
||||||
|
|
||||||
manhattanOptions = {
|
manhattanOptions = {
|
||||||
|
@ -136,6 +143,7 @@ BpmnLayouter.prototype.layoutConnection = function(connection, hints) {
|
||||||
preferredLayouts: [ 'h:h' ]
|
preferredLayouts: [ 'h:h' ]
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (manhattanOptions) {
|
if (manhattanOptions) {
|
||||||
|
|
|
@ -378,15 +378,6 @@ function canConnect(source, target, connection) {
|
||||||
return null;
|
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 (!is(connection, 'bpmn:DataAssociation')) {
|
||||||
|
|
||||||
if (canConnectMessageFlow(source, target)) {
|
if (canConnectMessageFlow(source, target)) {
|
||||||
|
|
|
@ -18,7 +18,6 @@ import coreModule from 'lib/core';
|
||||||
|
|
||||||
describe('features/modeling - layout', function() {
|
describe('features/modeling - layout', function() {
|
||||||
|
|
||||||
|
|
||||||
describe.skip('overall experience, flow elements', function() {
|
describe.skip('overall experience, flow elements', function() {
|
||||||
|
|
||||||
var diagramXML = require('./LayoutSequenceFlowSpec.flowElements.bpmn');
|
var diagramXML = require('./LayoutSequenceFlowSpec.flowElements.bpmn');
|
||||||
|
@ -177,6 +176,26 @@ describe('features/modeling - layout', function() {
|
||||||
beforeEach(bootstrapModeler(diagramXML, { modules: testModules }));
|
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() {
|
describe('gateway layout', function() {
|
||||||
|
|
||||||
it('should layout v:h after Gateway', inject(function() {
|
it('should layout v:h after Gateway', inject(function() {
|
||||||
|
|
|
@ -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
|
||||||
|
});
|
||||||
|
}));
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue