fix(rules): restrict movement on flow elements only
For the moment we allow moving flow elements in between diagrams, only.
This commit is contained in:
parent
2258642cb4
commit
3af41e2e7e
|
@ -53,6 +53,26 @@ ModelingRules.prototype.init = function() {
|
|||
}
|
||||
});
|
||||
|
||||
/**
|
||||
* Can an element be dropped into the target element
|
||||
*
|
||||
* @return {Boolean}
|
||||
*/
|
||||
function canDrop(businessObject, targetBusinessObject, targetDi) {
|
||||
|
||||
if (businessObject.$instanceOf('bpmn:FlowElement') &&
|
||||
targetBusinessObject.$instanceOf('bpmn:FlowElementsContainer')) {
|
||||
|
||||
// may not drop into collapsed sub processes
|
||||
if (targetDi.isExpanded === false) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
this.addRule('shapes.move', function(context) {
|
||||
|
||||
|
@ -60,7 +80,7 @@ ModelingRules.prototype.init = function() {
|
|||
shapes = context.shapes;
|
||||
|
||||
// only move if they have the same parent
|
||||
var sameParent = _.size(_.groupBy(shapes, function(s) { return s.parent && s.parent.id; }));
|
||||
var sameParent = _.size(_.groupBy(shapes, function(s) { return s.parent && s.parent.id; })) === 1;
|
||||
|
||||
if (!sameParent) {
|
||||
return false;
|
||||
|
@ -73,18 +93,9 @@ ModelingRules.prototype.init = function() {
|
|||
var targetBusinessObject = target.businessObject,
|
||||
targetDi = targetBusinessObject.di;
|
||||
|
||||
// allow to drop elements elements into sub processes
|
||||
// unless they are participants or lanes themselves
|
||||
|
||||
if (targetBusinessObject.$instanceOf('bpmn:SubProcess') && targetDi.isExpanded) {
|
||||
|
||||
return shapes.every(function(shape) {
|
||||
var bo = shape.businessObject;
|
||||
return !(bo.$instanceOf('bpmn:Participant') || bo.$instanceOf('bpmn:Lane'));
|
||||
return shapes.every(function(s) {
|
||||
return canDrop(s.businessObject, targetBusinessObject, targetDi);
|
||||
});
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
});
|
||||
|
||||
};
|
Loading…
Reference in New Issue