# all files / Github/bpmn-js/lib/features/popup-menu/util/ TypeUtil.js

100% Statements 9/9
100% Branches 10/10
100% Functions 2/2
100% Lines 9/9

    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
    43
    44

    226×
    928×

    928×
    928×

    928×

    928×

    928×

    928×

    928×

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

    import {
      isExpanded
    } from '../../../util/DiUtil';

    /**
     * Returns true, if an element is from a different type
     * than a target definition. Takes into account the type,
     * event definition type and triggeredByEvent property.
     *
     * @param {djs.model.Base} element
     *
     * @return {Boolean}
     */
    export function isDifferentType(element) {

      return function(entry) {
        var target = entry.target;

        var businessObject = getBusinessObject(element),
            eventDefinition = businessObject.eventDefinitions && businessObject.eventDefinitions[0];

        var isTypeEqual = businessObject.$type === target.type;

        var isEventDefinitionEqual = (
          (eventDefinition && eventDefinition.$type) === target.eventDefinitionType
        );

        var isTriggeredByEventEqual = (
          businessObject.triggeredByEvent === target.triggeredByEvent
        );

        var isExpandedEqual = (
          target.isExpanded === undefined ||
          target.isExpanded === isExpanded(businessObject)
        );

        return !isTypeEqual || !isEventDefinitionEqual || !isTriggeredByEventEqual || !isExpandedEqual;
      };
    }