parent
d8057a2acc
commit
a899df2a12
|
@ -17,31 +17,40 @@ ModelingRules.prototype = Object.create(RuleProvider.prototype);
|
||||||
|
|
||||||
ModelingRules.prototype.init = function() {
|
ModelingRules.prototype.init = function() {
|
||||||
|
|
||||||
|
function nonExistantOrLabel(element) {
|
||||||
|
return !element || element.labelTarget;
|
||||||
|
}
|
||||||
|
|
||||||
|
function isSame(a, b) {
|
||||||
|
return a === b;
|
||||||
|
}
|
||||||
|
|
||||||
// rules
|
// rules
|
||||||
|
|
||||||
function canConnect(source, target, connection) {
|
function canConnect(source, target, connection) {
|
||||||
|
|
||||||
if (!source || source.labelTarget || !target || target.labelTarget) {
|
if (nonExistantOrLabel(source) || nonExistantOrLabel(target)) {
|
||||||
return null;
|
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
|
// See https://github.com/bpmn-io/bpmn-js/issues/178
|
||||||
// as a workround we disallow connections with same
|
// as a workround we disallow connections with same
|
||||||
// target and source element.
|
// target and source element.
|
||||||
// This rule must be removed if a auto layout for this
|
// This rule must be removed if a auto layout for this
|
||||||
// connections is implemented.
|
// connections is implemented.
|
||||||
if (sourceBo === targetBo) {
|
if (isSame(source, target)) {
|
||||||
return false;
|
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 (connectionBo && connectionBo.$instanceOf('bpmn:SequenceFlow')) {
|
||||||
|
|
||||||
if (!sourceBo.$instanceOf('bpmn:FlowNode') ||
|
if (!sourceBo.$instanceOf('bpmn:FlowNode') ||
|
||||||
|
@ -165,7 +174,7 @@ ModelingRules.prototype.init = function() {
|
||||||
// into source
|
// into source
|
||||||
var t = target;
|
var t = target;
|
||||||
while (t) {
|
while (t) {
|
||||||
if (t === source) {
|
if (isSame(t, source)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue