parent
d8057a2acc
commit
a899df2a12
|
@ -17,31 +17,40 @@ ModelingRules.prototype = Object.create(RuleProvider.prototype);
|
|||
|
||||
ModelingRules.prototype.init = function() {
|
||||
|
||||
function nonExistantOrLabel(element) {
|
||||
return !element || element.labelTarget;
|
||||
}
|
||||
|
||||
function isSame(a, b) {
|
||||
return a === b;
|
||||
}
|
||||
|
||||
// rules
|
||||
|
||||
function canConnect(source, target, connection) {
|
||||
|
||||
if (!source || source.labelTarget || !target || target.labelTarget) {
|
||||
if (nonExistantOrLabel(source) || nonExistantOrLabel(target)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
var sourceBo = source.businessObject,
|
||||
targetBo = target.businessObject,
|
||||
connectionBo = connection && connection.businessObject;
|
||||
|
||||
if (sourceBo.$parent !== targetBo.$parent) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// 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 (sourceBo === targetBo) {
|
||||
if (isSame(source, target)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// only move between the same parent
|
||||
if (!isSame(source.parent, target.parent)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
var sourceBo = source.businessObject,
|
||||
targetBo = target.businessObject,
|
||||
connectionBo = connection && connection.businessObject;
|
||||
|
||||
if (connectionBo && connectionBo.$instanceOf('bpmn:SequenceFlow')) {
|
||||
|
||||
if (!sourceBo.$instanceOf('bpmn:FlowNode') ||
|
||||
|
@ -165,7 +174,7 @@ ModelingRules.prototype.init = function() {
|
|||
// into source
|
||||
var t = target;
|
||||
while (t) {
|
||||
if (t === source) {
|
||||
if (isSame(t, source)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue