Nico Rehwaldt 0a03e59866 feat(modeling): add participant modeling behavior
This commit adds the ability to model participants from the palette.

* Empty diagrams can be used as a start for participant _AND_ process diagram
* Process diagrams can be converted to collaboration diagrams by dropping
  a participant onto them

Closes #128
2015-04-14 15:23:16 +02:00

34 lines
912 B
JavaScript

'use strict';
var forEach = require('lodash/collection/forEach'),
inherits = require('inherits');
var CommandInterceptor = require('diagram-js/lib/command/CommandInterceptor');
function DropBehavior(eventBus, modeling) {
CommandInterceptor.call(this, eventBus);
// remove sequence flows that should not be allowed
// after a move operation
this.postExecute('shapes.move', function(context) {
var closure = context.closure,
allConnections = closure.allConnections;
forEach(allConnections, function(c) {
// remove sequence flows having source / target on different parents
if (c.businessObject.$instanceOf('bpmn:SequenceFlow') && c.source.parent !== c.target.parent) {
modeling.removeConnection(c);
}
});
}, true);
}
inherits(DropBehavior, CommandInterceptor);
DropBehavior.$inject = [ 'eventBus', 'modeling' ];
module.exports = DropBehavior;