# all files / Github/bpmn-js/lib/features/modeling/behavior/ UnclaimIdBehavior.js

100% Statements 8/8
100% Branches 0/0
100% Functions 3/3
100% Lines 8/8

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33

    1128×

    1128×
    27×
    27×

    27×
    32×

    1×

    1×import {
      forEach
    } from 'min-dash';

    import inherits from 'inherits';

    import CommandInterceptor from 'diagram-js/lib/command/CommandInterceptor';

    /**
     * Unclaims model IDs on element deletion.
     *
     * @param {EventBus} eventBus
     * @param {Modeling} modeling
     */
    export default function UnclaimIdBehavior(eventBus, modeling) {

      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);

    UnclaimIdBehavior.$inject = [ 'eventBus', 'modeling' ];