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

100% Statements 14/14
100% Branches 6/6
100% Functions 3/3
100% Lines 14/14

    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

    1×

    1189×

    1×

    1×
    45×
    45×

    45×

    45×

    45×
    33×

    45×
    30×

    45×

    63×

     import {
      assign,
      forEach
    } from 'min-dash';

    var DEFAULT_COLORS = {
      fill: undefined,
      stroke: undefined
    };

    export default function SetColorHandler(commandStack) {
      this._commandStack = commandStack;
    }

    SetColorHandler.$inject = [
      'commandStack'
    ];

    SetColorHandler.prototype.postExecute = function(context) {
      var elements = context.elements,
          colors = context.colors || DEFAULT_COLORS;

      var self = this;

      var di = {};

      if ('fill' in colors) {
        assign(di, { fill: colors.fill });
      }

      if ('stroke' in colors) {
        assign(di, { stroke: colors.stroke });
      }

      forEach(elements, function(element) {

        self._commandStack.execute('element.updateProperties', {
          element: element,
          properties: {
            di: di
          }
        });
      });

    };