mirror of
https://github.com/sartography/bpmn-js.git
synced 2025-02-26 15:40:46 +00:00
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
48 lines
1.1 KiB
JavaScript
48 lines
1.1 KiB
JavaScript
'use strict';
|
|
|
|
var inherits = require('inherits');
|
|
|
|
var CommandInterceptor = require('diagram-js/lib/command/CommandInterceptor');
|
|
|
|
/**
|
|
* BPMN specific remove behavior
|
|
*/
|
|
function RemoveBehavior(eventBus, modeling) {
|
|
|
|
CommandInterceptor.call(this, eventBus);
|
|
|
|
|
|
/**
|
|
* morph collaboration diagram into process diagram
|
|
* after the last participant has been removed
|
|
*/
|
|
|
|
this.preExecute('shape.delete', function(context) {
|
|
|
|
var shape = context.shape,
|
|
parent = shape.parent;
|
|
|
|
// activate the behavior if the shape to be removed
|
|
// is a participant
|
|
if (shape.businessObject.$instanceOf('bpmn:Participant')) {
|
|
context.collaborationRoot = parent;
|
|
}
|
|
}, true);
|
|
|
|
this.postExecute('shape.delete', function(context) {
|
|
|
|
var collaborationRoot = context.collaborationRoot;
|
|
|
|
if (collaborationRoot && collaborationRoot.businessObject.participants.length < 2) {
|
|
// replace empty collaboration with process diagram
|
|
modeling.makeProcess();
|
|
}
|
|
}, true);
|
|
|
|
}
|
|
|
|
RemoveBehavior.$inject = [ 'eventBus', 'modeling' ];
|
|
|
|
inherits(RemoveBehavior, CommandInterceptor);
|
|
|
|
module.exports = RemoveBehavior; |