chore(layout): support { source, target } hints in BpmnLayouter

Closes #743
This commit is contained in:
Nico Rehwaldt 2017-12-22 11:08:49 +01:00 committed by merge-me[bot]
parent 883d6c8ad3
commit d90f048e8c
1 changed files with 5 additions and 9 deletions

View File

@ -31,8 +31,8 @@ inherits(BpmnLayouter, BaseLayouter);
BpmnLayouter.prototype.layoutConnection = function(connection, hints) { BpmnLayouter.prototype.layoutConnection = function(connection, hints) {
hints = hints || {}; hints = hints || {};
var source = connection.source, var source = hints.source || connection.source,
target = connection.target, target = hints.target || connection.target,
waypoints = connection.waypoints, waypoints = connection.waypoints,
start = hints.connectionStart, start = hints.connectionStart,
end = hints.connectionEnd; end = hints.connectionEnd;
@ -54,7 +54,7 @@ BpmnLayouter.prototype.layoutConnection = function(connection, hints) {
if (is(connection, 'bpmn:Association') || if (is(connection, 'bpmn:Association') ||
is(connection, 'bpmn:DataAssociation')) { is(connection, 'bpmn:DataAssociation')) {
if (waypoints && !isCompensationAssociation(connection)) { if (waypoints && !isCompensationAssociation(source, target)) {
return [].concat([ start ], waypoints.slice(1, -1), [ end ]); return [].concat([ start ], waypoints.slice(1, -1), [ end ]);
} }
} }
@ -75,7 +75,7 @@ BpmnLayouter.prototype.layoutConnection = function(connection, hints) {
// (3) loops from / to the same element // (3) loops from / to the same element
// //
if (is(connection, 'bpmn:SequenceFlow') || if (is(connection, 'bpmn:SequenceFlow') ||
isCompensationAssociation(connection)) { isCompensationAssociation(source, target)) {
if (source === target) { if (source === target) {
manhattanOptions = { manhattanOptions = {
@ -189,11 +189,7 @@ function getConnectionDocking(point, shape) {
return point ? (point.original || point) : getMid(shape); return point ? (point.original || point) : getMid(shape);
} }
function isCompensationAssociation(connection) { function isCompensationAssociation(source, target) {
var source = connection.source,
target = connection.target;
return is(target, 'bpmn:Activity') && return is(target, 'bpmn:Activity') &&
is(source, 'bpmn:BoundaryEvent') && is(source, 'bpmn:BoundaryEvent') &&
target.businessObject.isForCompensation; target.businessObject.isForCompensation;