2018-04-02 19:01:53 +00:00
|
|
|
import {
|
|
|
|
forEach
|
|
|
|
} from 'min-dash';
|
2016-04-18 14:15:00 +00:00
|
|
|
|
2018-04-02 19:01:53 +00:00
|
|
|
import inherits from 'inherits';
|
2016-04-18 14:15:00 +00:00
|
|
|
|
2018-04-02 19:01:53 +00:00
|
|
|
import CommandInterceptor from 'diagram-js/lib/command/CommandInterceptor';
|
2016-04-18 14:15:00 +00:00
|
|
|
|
2018-04-02 19:01:53 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Unclaims model IDs on element deletion.
|
|
|
|
*
|
|
|
|
* @param {EventBus} eventBus
|
|
|
|
* @param {Modeling} modeling
|
|
|
|
*/
|
|
|
|
export default function UnclaimIdBehavior(eventBus, modeling) {
|
2016-04-18 14:15:00 +00:00
|
|
|
|
|
|
|
CommandInterceptor.call(this, eventBus);
|
|
|
|
|
|
|
|
this.preExecute('elements.delete', function(event) {
|
|
|
|
var context = event.context,
|
|
|
|
elements = context.elements;
|
|
|
|
|
|
|
|
forEach(elements, function(element) {
|
|
|
|
modeling.unclaimId(element.businessObject.id, element.businessObject);
|
|
|
|
});
|
|
|
|
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
inherits(UnclaimIdBehavior, CommandInterceptor);
|
|
|
|
|
2018-04-02 19:01:53 +00:00
|
|
|
UnclaimIdBehavior.$inject = [ 'eventBus', 'modeling' ];
|