2015-02-02 14:46:21 +01:00
|
|
|
'use strict';
|
|
|
|
|
2015-03-31 15:02:04 +02:00
|
|
|
var forEach = require('lodash/collection/forEach'),
|
|
|
|
inherits = require('inherits');
|
2014-11-21 09:19:35 +01:00
|
|
|
|
2015-03-31 15:02:04 +02:00
|
|
|
var CommandInterceptor = require('diagram-js/lib/command/CommandInterceptor');
|
2014-11-21 09:19:35 +01:00
|
|
|
|
|
|
|
function DropBehavior(eventBus, modeling) {
|
|
|
|
|
2015-03-31 15:02:04 +02:00
|
|
|
CommandInterceptor.call(this, eventBus);
|
2014-11-21 09:19:35 +01:00
|
|
|
|
2015-03-31 15:02:04 +02:00
|
|
|
// remove sequence flows that should not be allowed
|
|
|
|
// after a move operation
|
2014-11-21 09:19:35 +01:00
|
|
|
|
2015-03-31 15:02:04 +02:00
|
|
|
this.postExecute('shapes.move', function(context) {
|
|
|
|
|
|
|
|
var closure = context.closure,
|
2015-02-02 14:46:21 +01:00
|
|
|
allConnections = closure.allConnections;
|
2014-11-21 09:19:35 +01:00
|
|
|
|
2015-02-02 14:46:21 +01:00
|
|
|
forEach(allConnections, function(c) {
|
2014-11-21 09:19:35 +01:00
|
|
|
|
|
|
|
// remove sequence flows having source / target on different parents
|
|
|
|
if (c.businessObject.$instanceOf('bpmn:SequenceFlow') && c.source.parent !== c.target.parent) {
|
|
|
|
modeling.removeConnection(c);
|
|
|
|
}
|
|
|
|
});
|
2015-03-31 15:02:04 +02:00
|
|
|
}, true);
|
2014-11-21 09:19:35 +01:00
|
|
|
}
|
|
|
|
|
2015-03-31 15:02:04 +02:00
|
|
|
inherits(DropBehavior, CommandInterceptor);
|
|
|
|
|
2014-11-21 09:19:35 +01:00
|
|
|
DropBehavior.$inject = [ 'eventBus', 'modeling' ];
|
|
|
|
|
|
|
|
module.exports = DropBehavior;
|