feat: add multi-element delete action
This commit is contained in:
parent
9b1096abbc
commit
8df8e0fcc5
|
@ -1,7 +1,8 @@
|
|||
import {
|
||||
assign,
|
||||
forEach,
|
||||
isArray
|
||||
isArray,
|
||||
every
|
||||
} from 'min-dash';
|
||||
|
||||
import {
|
||||
|
@ -86,9 +87,49 @@ ContextPadProvider.$inject = [
|
|||
'translate'
|
||||
];
|
||||
|
||||
ContextPadProvider.prototype.getMultiElementContextPadEntries = function(elements) {
|
||||
var modeling = this._modeling;
|
||||
|
||||
var actions = {};
|
||||
|
||||
if (this._isDeleteAllowed(elements)) {
|
||||
assign(actions, {
|
||||
'delete': {
|
||||
group: 'edit',
|
||||
className: 'bpmn-icon-trash',
|
||||
title: this._translate('Remove'),
|
||||
action: {
|
||||
click: function(event, elements) {
|
||||
modeling.removeElements(elements.slice());
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
return actions;
|
||||
};
|
||||
|
||||
/**
|
||||
* @param {djs.model.Base[]} elements
|
||||
* @return {boolean}
|
||||
*/
|
||||
ContextPadProvider.prototype._isDeleteAllowed = function(elements) {
|
||||
|
||||
var baseAllowed = this._rules.allowed('elements.delete', {
|
||||
elements: elements
|
||||
});
|
||||
|
||||
if (isArray(baseAllowed)) {
|
||||
return every(baseAllowed, function(element) {
|
||||
return includes(baseAllowed, element);
|
||||
});
|
||||
}
|
||||
|
||||
return baseAllowed;
|
||||
};
|
||||
|
||||
ContextPadProvider.prototype.getContextPadEntries = function(element) {
|
||||
|
||||
var contextPad = this._contextPad,
|
||||
modeling = this._modeling,
|
||||
|
||||
|
@ -470,3 +511,7 @@ function isEventType(eventBo, type, definition) {
|
|||
|
||||
return isType && isDefinition;
|
||||
}
|
||||
|
||||
function includes(array, item) {
|
||||
return array.indexOf(item) !== -1;
|
||||
}
|
Loading…
Reference in New Issue