chore(context-pad): make lane actions available

Lanes are going to be modeled via the parents context-pad only.

This commit

* removes lanes from the palette
* adds lane actions to the context-pad

Related to #379
This commit is contained in:
Nico Rehwaldt 2015-10-10 01:28:04 +02:00 committed by pedesen
parent 0831cae843
commit 6a3bdd32ea
3 changed files with 76 additions and 31 deletions

View File

@ -4,6 +4,8 @@
var assign = require('lodash/object/assign'),
forEach = require('lodash/collection/forEach'),
is = require('../../util/ModelUtil').is,
isAny = require('../modeling/util/ModelingUtil').isAny,
getChildLanes = require('../modeling/util/LaneUtil').getChildLanes,
isEventSubProcess = require('../../util/DiUtil').isEventSubProcess;
@ -37,6 +39,9 @@ ContextPadProvider.$inject = [
'canvas'
];
module.exports = ContextPadProvider;
ContextPadProvider.prototype.getContextPadEntries = function(element) {
var contextPad = this._contextPad,
@ -54,7 +59,7 @@ ContextPadProvider.prototype.getContextPadEntries = function(element) {
return actions;
}
var bpmnElement = element.businessObject;
var businessObject = element.businessObject;
function startConnect(event, element, autoActivate) {
connect.start(event, element, autoActivate);
@ -111,12 +116,69 @@ ContextPadProvider.prototype.getContextPadEntries = function(element) {
};
}
if (is(bpmnElement, 'bpmn:FlowNode')) {
if (isAny(businessObject, [ 'bpmn:Lane', 'bpmn:Participant' ])) {
if (!is(bpmnElement, 'bpmn:EndEvent') &&
!is(bpmnElement, 'bpmn:EventBasedGateway') &&
!isEventType(bpmnElement, 'bpmn:IntermediateThrowEvent', 'bpmn:LinkEventDefinition') &&
!isEventSubProcess(bpmnElement)) {
var childLanes = getChildLanes(element);
assign(actions, {
'lane-insert-above': {
group: 'lane-insert-above',
className: 'icon-lane-insert-above',
title: 'Add Lane above',
action: {
click: function(event, element) {
modeling.addLane(element, 'top');
}
}
}
});
if (childLanes.length < 2) {
assign(actions, {
'lane-divide-two': {
group: 'lane-divide',
className: 'icon-lane-divide-two',
title: 'Divide into two Lanes',
action: {
click: function(event, element) {
modeling.splitLane(element, 2);
}
}
},
'lane-divide-three': {
group: 'lane-divide',
className: 'icon-lane-divide-three',
title: 'Divide into three Lanes',
action: {
click: function(event, element) {
modeling.splitLane(element, 3);
}
}
}
});
}
assign(actions, {
'lane-insert-below': {
group: 'lane-insert-below',
className: 'icon-lane-insert-below',
title: 'Add Lane below',
action: {
click: function(event, element) {
modeling.addLane(element, 'bottom');
}
}
}
});
}
if (is(businessObject, 'bpmn:FlowNode')) {
if (!is(businessObject, 'bpmn:EndEvent') &&
!is(businessObject, 'bpmn:EventBasedGateway') &&
!isEventType(businessObject, 'bpmn:IntermediateThrowEvent', 'bpmn:LinkEventDefinition') &&
!isEventSubProcess(businessObject)) {
assign(actions, {
'append.end-event': appendAction('bpmn:EndEvent', 'icon-end-event-none'),
@ -127,7 +189,7 @@ ContextPadProvider.prototype.getContextPadEntries = function(element) {
});
}
if (is(bpmnElement, 'bpmn:EventBasedGateway')) {
if (is(businessObject, 'bpmn:EventBasedGateway')) {
assign(actions, {
'append.receive-task': appendAction('bpmn:ReceiveTask', 'icon-receive-task'),
@ -147,9 +209,9 @@ ContextPadProvider.prototype.getContextPadEntries = function(element) {
}
}
if (is(bpmnElement, 'bpmn:FlowNode') ||
(is(bpmnElement, 'bpmn:SequenceFlow') && (is(bpmnElement.sourceRef, 'bpmn:Activity') ||
is(bpmnElement.sourceRef, 'bpmn:ExclusiveGateway') || is(bpmnElement.sourceRef, 'bpmn:InclusiveGateway')))) {
var replaceOptions = bpmnReplace.getReplaceOptions(element);
if (replaceOptions.length) {
// Replace menu entry
assign(actions, {
'replace': {
@ -165,8 +227,7 @@ ContextPadProvider.prototype.getContextPadEntries = function(element) {
});
}
if (is(bpmnElement, 'bpmn:FlowNode') ||
is(bpmnElement, 'bpmn:InteractionNode')) {
if (isAny(businessObject, [ 'bpmn:FlowNode', 'bpmn:InteractionNode' ])) {
assign(actions, {
'append.text-annotation': appendAction('bpmn:TextAnnotation', 'icon-text-annotation'),
@ -183,7 +244,7 @@ ContextPadProvider.prototype.getContextPadEntries = function(element) {
});
}
if (is(bpmnElement, 'bpmn:DataObjectReference')) {
if (is(businessObject, 'bpmn:DataObjectReference')) {
assign(actions, {
'connect': {
group: 'connect',
@ -226,7 +287,4 @@ function isEventType(eventBo, type, definition) {
});
return isType && isDefinition;
}
module.exports = ContextPadProvider;
}

View File

@ -58,10 +58,6 @@ PaletteProvider.prototype.getPaletteEntries = function(element) {
create.start(event, elementFactory.createParticipantShape(collapsed));
}
function createLane(event) {
create.start(event, elementFactory.createShape({ type: 'bpmn:Lane' }));
}
assign(actions, {
'lasso-tool': {
group: 'tools',
@ -117,15 +113,6 @@ PaletteProvider.prototype.getPaletteEntries = function(element) {
dragstart: createParticipant,
click: createParticipant
}
},
'create.lane': {
group: 'collaboration',
className: 'icon-lane',
title: 'Create Lane',
action: {
dragstart: createLane,
click: createLane
}
}
});

View File

@ -27,7 +27,7 @@ describe('features/palette', function() {
var entries = domQuery.all('.entry', paletteElement);
// then
expect(entries.length).to.equal(11);
expect(entries.length).to.equal(10);
}));
});