mirror of
https://github.com/bpmn-io/bpmn-js.git
synced 2025-08-16 04:41:02 +08:00
feat(modeling): combining two sequence flows when removing an element
combines only if removed element has one outgoing and one incoming sequence flow Closes #433
This commit is contained in:
40
lib/features/modeling/behavior/RemoveElementBehavior.js
Normal file
40
lib/features/modeling/behavior/RemoveElementBehavior.js
Normal file
@ -0,0 +1,40 @@
|
||||
'use strict';
|
||||
|
||||
var inherits = require('inherits');
|
||||
|
||||
var CommandInterceptor = require('diagram-js/lib/command/CommandInterceptor');
|
||||
|
||||
function RemoveElementBehavior(eventBus, bpmnRules, modeling) {
|
||||
|
||||
CommandInterceptor.call(this, eventBus);
|
||||
|
||||
/**
|
||||
* Combine sequence flows when deleting an element
|
||||
* if there is one incoming and one outgoing
|
||||
* sequence flow
|
||||
*/
|
||||
|
||||
this.preExecute('shape.delete', function(e) {
|
||||
|
||||
var shape = e.context.shape;
|
||||
|
||||
if (shape.incoming.length == 1 && shape.outgoing.length == 1) {
|
||||
|
||||
var inConnection = shape.incoming[0],
|
||||
outConnection = shape.outgoing[0];
|
||||
|
||||
var docking = outConnection.waypoints[outConnection.waypoints.length - 1];
|
||||
|
||||
if (bpmnRules.canConnect(inConnection.source, outConnection.target, inConnection)) {
|
||||
modeling.reconnectEnd(inConnection, outConnection.target, docking);
|
||||
}
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
inherits(RemoveElementBehavior, CommandInterceptor);
|
||||
|
||||
RemoveElementBehavior.$inject = [ 'eventBus', 'bpmnRules', 'modeling' ];
|
||||
|
||||
module.exports = RemoveElementBehavior;
|
Reference in New Issue
Block a user