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

94.44% Statements 17/18
80% Branches 8/10
100% Functions 4/4
94.44% Lines 17/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
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51

    1×
    1×

    2×

    1128×
    2×
    2×
    2×

    2×

    1128×
    2×
    2×
    2×

    2×
    1×

    2×
    1×

    1×

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

    var COLLAB_ERR_MSG = 'flow elements must be children of pools/participants',
        PROCESS_ERR_MSG = 'participants cannot be pasted onto a non-empty process diagram';

    export default function ModelingFeedback(eventBus, tooltips, translate) {

      function showError(position, message, timeout) {
        tooltips.add({
          position: {
            x: position.x + 5,
            y: position.y + 5
          },
          type: 'error',
          timeout: timeout || 2000,
          html: '<div>' + message + '</div>'
        });
      }

      eventBus.on([ 'shape.move.rejected', 'create.rejected' ], function(event) {
        var context = event.context,
            shape = context.shape,
            target = context.target;

        Iif (is(target, 'bpmn:Collaboration') && is(shape, 'bpmn:FlowNode')) {
          showError(event, translate(COLLAB_ERR_MSG));
        }
      });

      eventBus.on([ 'elements.paste.rejected' ], function(event) {
        var context = event.context,
            position = context.position,
            target = context.target;

        if (is(target, 'bpmn:Collaboration')) {
          showError(position, translate(COLLAB_ERR_MSG));
        }

        if (is(target, 'bpmn:Process')) {
          showError(position, translate(PROCESS_ERR_MSG), 3000);
        }
      });
    }

    ModelingFeedback.$inject = [
      'eventBus',
      'tooltips',
      'translate'
    ];