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

100% Statements 8/8
100% Branches 4/4
100% Functions 2/2
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
    34
    35
    36
    37
    38
    39
    40
    41
    42

    1128×

    1128×

    1128×
    1707×

    1707×

    128×

    1×

    1×
     import inherits from 'inherits';

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

    import {
      getBusinessObject
    } from '../../../util/ModelUtil';

    import {
      isAny
    } from '../util/ModelingUtil';

    /**
     * A component that makes sure that each created or updated
     * Pool and Lane is assigned an isHorizontal property set to true.
     *
     * @param {EventBus} eventBus
     */
    export default function IsHorizontalFix(eventBus) {

      CommandInterceptor.call(this, eventBus);

      var elementTypesToUpdate = [
        'bpmn:Participant',
        'bpmn:Lane'
      ];

      this.executed([ 'shape.move', 'shape.create', 'shape.resize' ], function(event) {
        var bo = getBusinessObject(event.context.shape);

        if (isAny(bo, elementTypesToUpdate) && !bo.di.get('isHorizontal')) {
          // set attribute directly to avoid modeling#updateProperty side effects
          bo.di.set('isHorizontal', true);
        }
      });

    }

    IsHorizontalFix.$inject = [ 'eventBus' ];

    inherits(IsHorizontalFix, CommandInterceptor);