# all files / bpmn-js/lib/features/modeling/cmd/ IdClaimHandler.js

88.89% Statements 16/18
50% Branches 2/4
100% Functions 3/3
88.89% Lines 16/18

    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
    34
    35
    36
    37
    1189×

    1×

    1×
    176×
    176×
    176×
    176×

    176×

    176×

    1×
    32×
    32×
    32×
    32×

    32×

    32×

     export default function IdClaimHandler(moddle) {
      this._moddle = moddle;
    }

    IdClaimHandler.$inject = [ 'moddle' ];

    IdClaimHandler.prototype.execute = function(context) {
      var ids = this._moddle.ids,
          id = context.id,
          element = context.element,
          claiming = context.claiming;

      Iif (claiming) {
        ids.claim(id, element);
      } else {
        ids.unclaim(id);
      }
    };

    /**
     * Command revert implementation.
     */
    IdClaimHandler.prototype.revert = function(context) {
      var ids = this._moddle.ids,
          id = context.id,
          element = context.element,
          claiming = context.claiming;

      Iif (claiming) {
        ids.unclaim(id);
      } else {
        ids.claim(id, element);
      }
    };