Skip to content

Commit

Permalink
feat: support coloring multiple elements
Browse files Browse the repository at this point in the history
Closes #13
  • Loading branch information
nikku committed Dec 6, 2022
1 parent 7594ba2 commit ce50b33
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 9 deletions.
27 changes: 20 additions & 7 deletions colors/ColorContextPadProvider.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,34 +25,47 @@ ColorContextPadProvider.$inject = [


ColorContextPadProvider.prototype.getContextPadEntries = function(element) {
var self = this;
return this._createPopupAction([ element ]);
};


ColorContextPadProvider.prototype.getMultiElementContextPadEntries = function(elements) {

return this._createPopupAction(elements);
};

ColorContextPadProvider.prototype._createPopupAction = function(elements) {

const canvas = this._canvas;
const translate = this._translate;
const contextPad = this._contextPad;
const popupMenu = this._popupMenu;

var actions = {
return {
'set-color': {
group: 'edit',
className: 'bpmn-icon-color',
title: self._translate('Set Color'),
title: translate('Set Color'),
imageUrl: colorImageUrl,
action: {
click: function(event, element) {
click: (event, element) => {

// get start popup draw start position
var position = {
...getStartPosition(self._canvas, self._contextPad, element),
...getStartPosition(canvas, contextPad, elements[0]),
cursor: {
x: event.x,
y: event.y
}
};

// open new color-picker popup
self._popupMenu.open(element, 'color-picker', position);
popupMenu.open(elements, 'color-picker', position);
}
}
}
};

return actions;
};


Expand Down
4 changes: 2 additions & 2 deletions colors/ColorPopupProvider.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ ColorPopupProvider.$inject = [
];


ColorPopupProvider.prototype.getEntries = function(element) {
ColorPopupProvider.prototype.getEntries = function(elements) {
var self = this;

var entries = this._colors.map(function(color) {
Expand All @@ -53,7 +53,7 @@ ColorPopupProvider.prototype.getEntries = function(element) {
title: self._translate(color.label),
id: color.label.toLowerCase() + '-color',
className: 'color-icon-' + color.label.toLowerCase(),
action: createAction(self._modeling, element, color)
action: createAction(self._modeling, elements, color)
};
});

Expand Down

0 comments on commit ce50b33

Please sign in to comment.