mirror of
https://github.com/bpmn-io/bpmn-js.git
synced 2025-08-15 20:37:48 +08:00

* use ES6 import / export * UTILS: export individual utilities * TESTS: localize TestHelper includes BREAKING CHANGE: * all utilities export independent functions * library sources got ported to ES6. You must now use a ES module bundler such as Browserify + babelify or Webpack to consume this library (or parts of it).
59 lines
1.2 KiB
JavaScript
59 lines
1.2 KiB
JavaScript
'use strict';
|
|
|
|
import inherits from 'inherits';
|
|
|
|
import CommandInterceptor from 'diagram-js/lib/command/CommandInterceptor';
|
|
|
|
import {
|
|
getBusinessObject,
|
|
is
|
|
} from '../../../util/ModelUtil';
|
|
|
|
|
|
/**
|
|
* A behavior that unsets the Default property of
|
|
* sequence flow source on element delete, if the
|
|
* removed element is the Gateway or Task's default flow.
|
|
*
|
|
* @param {EventBus} eventBus
|
|
* @param {Modeling} modeling
|
|
*/
|
|
export default function DeleteSequenceFlowBehavior(eventBus, modeling) {
|
|
|
|
CommandInterceptor.call(this, eventBus);
|
|
|
|
|
|
this.preExecute('connection.delete', function(event) {
|
|
var context = event.context,
|
|
connection = context.connection,
|
|
source = connection.source;
|
|
|
|
if (isDefaultFlow(connection, source)) {
|
|
modeling.updateProperties(source, {
|
|
'default': null
|
|
});
|
|
}
|
|
});
|
|
}
|
|
|
|
inherits(DeleteSequenceFlowBehavior, CommandInterceptor);
|
|
|
|
DeleteSequenceFlowBehavior.$inject = [
|
|
'eventBus',
|
|
'modeling'
|
|
];
|
|
|
|
|
|
// helpers //////////////////////
|
|
|
|
function isDefaultFlow(connection, source) {
|
|
|
|
if (!is(connection, 'bpmn:SequenceFlow')) {
|
|
return false;
|
|
}
|
|
|
|
var sourceBo = getBusinessObject(source),
|
|
sequenceFlow = getBusinessObject(connection);
|
|
|
|
return sourceBo.get('default') === sequenceFlow;
|
|
} |