|
@@ -31,10 +31,10 @@ import {
|
|
|
* A provider for BPMN 2.0 elements context pad
|
|
|
*/
|
|
|
export default function ContextPadProvider(
|
|
|
- config, injector, eventBus,
|
|
|
- contextPad, modeling, elementFactory,
|
|
|
- connect, create, popupMenu,
|
|
|
- canvas, rules, translate) {
|
|
|
+ config, injector, eventBus,
|
|
|
+ contextPad, modeling, elementFactory,
|
|
|
+ connect, create, popupMenu,
|
|
|
+ canvas, rules, translate) {
|
|
|
|
|
|
config = config || {};
|
|
|
|
|
@@ -56,9 +56,9 @@ export default function ContextPadProvider(
|
|
|
this._autoPlace = injector.get('autoPlace', false);
|
|
|
}
|
|
|
|
|
|
- eventBus.on('create.end', 250, function(event) {
|
|
|
+ eventBus.on('create.end', 250, function (event) {
|
|
|
var context = event.context,
|
|
|
- shape = context.shape;
|
|
|
+ shape = context.shape;
|
|
|
|
|
|
if (!hasPrimaryModifier(event) || !contextPad.isOpen(shape)) {
|
|
|
return;
|
|
@@ -87,7 +87,7 @@ ContextPadProvider.$inject = [
|
|
|
'translate'
|
|
|
];
|
|
|
|
|
|
-ContextPadProvider.prototype.getMultiElementContextPadEntries = function(elements) {
|
|
|
+ContextPadProvider.prototype.getMultiElementContextPadEntries = function (elements) {
|
|
|
var modeling = this._modeling;
|
|
|
|
|
|
var actions = {};
|
|
@@ -99,7 +99,7 @@ ContextPadProvider.prototype.getMultiElementContextPadEntries = function(element
|
|
|
className: 'bpmn-icon-trash',
|
|
|
title: this._translate('Remove'),
|
|
|
action: {
|
|
|
- click: function(event, elements) {
|
|
|
+ click: function (event, elements) {
|
|
|
modeling.removeElements(elements.slice());
|
|
|
}
|
|
|
}
|
|
@@ -114,14 +114,14 @@ ContextPadProvider.prototype.getMultiElementContextPadEntries = function(element
|
|
|
* @param {djs.model.Base[]} elements
|
|
|
* @return {boolean}
|
|
|
*/
|
|
|
-ContextPadProvider.prototype._isDeleteAllowed = function(elements) {
|
|
|
+ContextPadProvider.prototype._isDeleteAllowed = function (elements) {
|
|
|
|
|
|
var baseAllowed = this._rules.allowed('elements.delete', {
|
|
|
elements: elements
|
|
|
});
|
|
|
|
|
|
if (isArray(baseAllowed)) {
|
|
|
- return every(baseAllowed, function(element) {
|
|
|
+ return every(baseAllowed, function (element) {
|
|
|
return includes(baseAllowed, element);
|
|
|
});
|
|
|
}
|
|
@@ -129,18 +129,18 @@ ContextPadProvider.prototype._isDeleteAllowed = function(elements) {
|
|
|
return baseAllowed;
|
|
|
};
|
|
|
|
|
|
-ContextPadProvider.prototype.getContextPadEntries = function(element) {
|
|
|
+ContextPadProvider.prototype.getContextPadEntries = function (element) {
|
|
|
var contextPad = this._contextPad,
|
|
|
- modeling = this._modeling,
|
|
|
+ modeling = this._modeling,
|
|
|
|
|
|
- elementFactory = this._elementFactory,
|
|
|
- connect = this._connect,
|
|
|
- create = this._create,
|
|
|
- popupMenu = this._popupMenu,
|
|
|
- canvas = this._canvas,
|
|
|
- rules = this._rules,
|
|
|
- autoPlace = this._autoPlace,
|
|
|
- translate = this._translate;
|
|
|
+ elementFactory = this._elementFactory,
|
|
|
+ connect = this._connect,
|
|
|
+ create = this._create,
|
|
|
+ popupMenu = this._popupMenu,
|
|
|
+ canvas = this._canvas,
|
|
|
+ rules = this._rules,
|
|
|
+ autoPlace = this._autoPlace,
|
|
|
+ translate = this._translate;
|
|
|
|
|
|
var actions = {};
|
|
|
|
|
@@ -155,7 +155,7 @@ ContextPadProvider.prototype.getContextPadEntries = function(element) {
|
|
|
}
|
|
|
|
|
|
function removeElement(e, element) {
|
|
|
- modeling.removeElements([ element ]);
|
|
|
+ modeling.removeElements([element]);
|
|
|
}
|
|
|
|
|
|
function getReplaceMenuPosition(element) {
|
|
@@ -163,10 +163,10 @@ ContextPadProvider.prototype.getContextPadEntries = function(element) {
|
|
|
var Y_OFFSET = 5;
|
|
|
|
|
|
var diagramContainer = canvas.getContainer(),
|
|
|
- pad = contextPad.getPad(element).html;
|
|
|
+ pad = contextPad.getPad(element).html;
|
|
|
|
|
|
var diagramRect = diagramContainer.getBoundingClientRect(),
|
|
|
- padRect = pad.getBoundingClientRect();
|
|
|
+ padRect = pad.getBoundingClientRect();
|
|
|
|
|
|
var top = padRect.top - diagramRect.top;
|
|
|
var left = padRect.left - diagramRect.left;
|
|
@@ -206,7 +206,7 @@ ContextPadProvider.prototype.getContextPadEntries = function(element) {
|
|
|
}
|
|
|
|
|
|
|
|
|
- var append = autoPlace ? function(event, element) {
|
|
|
+ var append = autoPlace ? function (event, element) {
|
|
|
var shape = elementFactory.createShape(assign({ type: type }, options));
|
|
|
|
|
|
autoPlace.append(element, shape);
|
|
@@ -226,7 +226,7 @@ ContextPadProvider.prototype.getContextPadEntries = function(element) {
|
|
|
|
|
|
function splitLaneHandler(count) {
|
|
|
|
|
|
- return function(event, element) {
|
|
|
+ return function (event, element) {
|
|
|
|
|
|
// actual split
|
|
|
modeling.splitLane(element, count);
|
|
@@ -238,7 +238,7 @@ ContextPadProvider.prototype.getContextPadEntries = function(element) {
|
|
|
}
|
|
|
|
|
|
|
|
|
- if (isAny(businessObject, [ 'bpmn:Lane', 'bpmn:Participant' ]) && isExpanded(element)) {
|
|
|
+ if (isAny(businessObject, ['bpmn:Lane', 'bpmn:Participant']) && isExpanded(element)) {
|
|
|
|
|
|
var childLanes = getChildLanes(element);
|
|
|
|
|
@@ -248,7 +248,7 @@ ContextPadProvider.prototype.getContextPadEntries = function(element) {
|
|
|
className: 'bpmn-icon-lane-insert-above',
|
|
|
title: translate('Add Lane above'),
|
|
|
action: {
|
|
|
- click: function(event, element) {
|
|
|
+ click: function (event, element) {
|
|
|
modeling.addLane(element, 'top');
|
|
|
}
|
|
|
}
|
|
@@ -290,7 +290,7 @@ ContextPadProvider.prototype.getContextPadEntries = function(element) {
|
|
|
className: 'bpmn-icon-lane-insert-below',
|
|
|
title: translate('Add Lane below'),
|
|
|
action: {
|
|
|
- click: function(event, element) {
|
|
|
+ click: function (event, element) {
|
|
|
modeling.addLane(element, 'bottom');
|
|
|
}
|
|
|
}
|
|
@@ -336,10 +336,10 @@ ContextPadProvider.prototype.getContextPadEntries = function(element) {
|
|
|
});
|
|
|
} else
|
|
|
|
|
|
- if (isEventType(businessObject, 'bpmn:BoundaryEvent', 'bpmn:CompensateEventDefinition')) {
|
|
|
+ if (isEventType(businessObject, 'bpmn:BoundaryEvent', 'bpmn:CompensateEventDefinition')) {
|
|
|
|
|
|
- assign(actions, {
|
|
|
- 'append.compensation-activity':
|
|
|
+ assign(actions, {
|
|
|
+ 'append.compensation-activity':
|
|
|
appendAction(
|
|
|
'bpmn:Task',
|
|
|
'bpmn-icon-task',
|
|
@@ -348,37 +348,37 @@ ContextPadProvider.prototype.getContextPadEntries = function(element) {
|
|
|
isForCompensation: true
|
|
|
}
|
|
|
)
|
|
|
- });
|
|
|
- } else
|
|
|
-
|
|
|
- if (!is(businessObject, 'bpmn:EndEvent') &&
|
|
|
- !businessObject.isForCompensation &&
|
|
|
- !isEventType(businessObject, 'bpmn:IntermediateThrowEvent', 'bpmn:LinkEventDefinition') &&
|
|
|
- !isEventSubProcess(businessObject)) {
|
|
|
-
|
|
|
- assign(actions, {
|
|
|
- 'append.end-event': appendAction(
|
|
|
- 'bpmn:EndEvent',
|
|
|
- 'bpmn-icon-end-event-none',
|
|
|
- translate('Append EndEvent')
|
|
|
- ),
|
|
|
- 'append.gateway': appendAction(
|
|
|
- 'bpmn:ExclusiveGateway',
|
|
|
- 'bpmn-icon-gateway-none',
|
|
|
- translate('Append Gateway')
|
|
|
- ),
|
|
|
- 'append.append-task': appendAction(
|
|
|
- 'bpmn:Task',
|
|
|
- 'bpmn-icon-task',
|
|
|
- translate('Append Task')
|
|
|
- ),
|
|
|
- 'append.intermediate-event': appendAction(
|
|
|
- 'bpmn:IntermediateThrowEvent',
|
|
|
- 'bpmn-icon-intermediate-event-none',
|
|
|
- translate('Append Intermediate/Boundary Event')
|
|
|
- )
|
|
|
- });
|
|
|
- }
|
|
|
+ });
|
|
|
+ } else
|
|
|
+
|
|
|
+ if (!is(businessObject, 'bpmn:EndEvent') &&
|
|
|
+ !businessObject.isForCompensation &&
|
|
|
+ !isEventType(businessObject, 'bpmn:IntermediateThrowEvent', 'bpmn:LinkEventDefinition') &&
|
|
|
+ !isEventSubProcess(businessObject)) {
|
|
|
+
|
|
|
+ assign(actions, {
|
|
|
+ 'append.end-event': appendAction(
|
|
|
+ 'bpmn:EndEvent',
|
|
|
+ 'bpmn-icon-end-event-none',
|
|
|
+ translate('Append EndEvent')
|
|
|
+ ),
|
|
|
+ // 'append.gateway': appendAction(
|
|
|
+ // 'bpmn:ExclusiveGateway',
|
|
|
+ // 'bpmn-icon-gateway-none',
|
|
|
+ // translate('Append Gateway')
|
|
|
+ // ),
|
|
|
+ // 'append.append-task': appendAction(
|
|
|
+ // 'bpmn:Task',
|
|
|
+ // 'bpmn-icon-task',
|
|
|
+ // translate('Append Task')
|
|
|
+ // ),
|
|
|
+ // 'append.intermediate-event': appendAction(
|
|
|
+ // 'bpmn:IntermediateThrowEvent',
|
|
|
+ // 'bpmn-icon-intermediate-event-none',
|
|
|
+ // translate('Append Intermediate/Boundary Event')
|
|
|
+ // )
|
|
|
+ });
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
if (!popupMenu.isEmpty(element, 'bpmn-replace')) {
|
|
@@ -390,7 +390,7 @@ ContextPadProvider.prototype.getContextPadEntries = function(element) {
|
|
|
className: 'bpmn-icon-screw-wrench',
|
|
|
title: translate('Change type'),
|
|
|
action: {
|
|
|
- click: function(event, element) {
|
|
|
+ click: function (event, element) {
|
|
|
|
|
|
var position = assign(getReplaceMenuPosition(element), {
|
|
|
cursor: { x: event.x, y: event.y }
|
|
@@ -431,10 +431,10 @@ ContextPadProvider.prototype.getContextPadEntries = function(element) {
|
|
|
className: 'bpmn-icon-connection-multi',
|
|
|
title: translate(
|
|
|
'Connect using ' +
|
|
|
- (businessObject.isForCompensation
|
|
|
- ? ''
|
|
|
- : 'Sequence/MessageFlow or ') +
|
|
|
- 'Association'
|
|
|
+ (businessObject.isForCompensation
|
|
|
+ ? ''
|
|
|
+ : 'Sequence/MessageFlow or ') +
|
|
|
+ 'Association'
|
|
|
),
|
|
|
action: {
|
|
|
click: startConnect,
|
|
@@ -458,7 +458,7 @@ ContextPadProvider.prototype.getContextPadEntries = function(element) {
|
|
|
});
|
|
|
}
|
|
|
|
|
|
- if (isAny(businessObject, [ 'bpmn:DataObjectReference', 'bpmn:DataStoreReference' ])) {
|
|
|
+ if (isAny(businessObject, ['bpmn:DataObjectReference', 'bpmn:DataStoreReference'])) {
|
|
|
assign(actions, {
|
|
|
'connect': {
|
|
|
group: 'connect',
|
|
@@ -479,7 +479,7 @@ ContextPadProvider.prototype.getContextPadEntries = function(element) {
|
|
|
}
|
|
|
|
|
|
// delete element entry, only show if allowed by rules
|
|
|
- var deleteAllowed = rules.allowed('elements.delete', { elements: [ element ] });
|
|
|
+ var deleteAllowed = rules.allowed('elements.delete', { elements: [element] });
|
|
|
|
|
|
if (isArray(deleteAllowed)) {
|
|
|
|
|
@@ -512,7 +512,7 @@ function isEventType(eventBo, type, definition) {
|
|
|
var isDefinition = false;
|
|
|
|
|
|
var definitions = eventBo.eventDefinitions || [];
|
|
|
- forEach(definitions, function(def) {
|
|
|
+ forEach(definitions, function (def) {
|
|
|
if (def.$type === definition) {
|
|
|
isDefinition = true;
|
|
|
}
|