mirror of
https://github.com/sartography/bpmn-js.git
synced 2025-01-11 17:44:12 +00:00
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:
parent
0831cae843
commit
6a3bdd32ea
@ -4,6 +4,8 @@
|
|||||||
var assign = require('lodash/object/assign'),
|
var assign = require('lodash/object/assign'),
|
||||||
forEach = require('lodash/collection/forEach'),
|
forEach = require('lodash/collection/forEach'),
|
||||||
is = require('../../util/ModelUtil').is,
|
is = require('../../util/ModelUtil').is,
|
||||||
|
isAny = require('../modeling/util/ModelingUtil').isAny,
|
||||||
|
getChildLanes = require('../modeling/util/LaneUtil').getChildLanes,
|
||||||
isEventSubProcess = require('../../util/DiUtil').isEventSubProcess;
|
isEventSubProcess = require('../../util/DiUtil').isEventSubProcess;
|
||||||
|
|
||||||
|
|
||||||
@ -37,6 +39,9 @@ ContextPadProvider.$inject = [
|
|||||||
'canvas'
|
'canvas'
|
||||||
];
|
];
|
||||||
|
|
||||||
|
module.exports = ContextPadProvider;
|
||||||
|
|
||||||
|
|
||||||
ContextPadProvider.prototype.getContextPadEntries = function(element) {
|
ContextPadProvider.prototype.getContextPadEntries = function(element) {
|
||||||
|
|
||||||
var contextPad = this._contextPad,
|
var contextPad = this._contextPad,
|
||||||
@ -54,7 +59,7 @@ ContextPadProvider.prototype.getContextPadEntries = function(element) {
|
|||||||
return actions;
|
return actions;
|
||||||
}
|
}
|
||||||
|
|
||||||
var bpmnElement = element.businessObject;
|
var businessObject = element.businessObject;
|
||||||
|
|
||||||
function startConnect(event, element, autoActivate) {
|
function startConnect(event, element, autoActivate) {
|
||||||
connect.start(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') &&
|
var childLanes = getChildLanes(element);
|
||||||
!is(bpmnElement, 'bpmn:EventBasedGateway') &&
|
|
||||||
!isEventType(bpmnElement, 'bpmn:IntermediateThrowEvent', 'bpmn:LinkEventDefinition') &&
|
assign(actions, {
|
||||||
!isEventSubProcess(bpmnElement)) {
|
'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, {
|
assign(actions, {
|
||||||
'append.end-event': appendAction('bpmn:EndEvent', 'icon-end-event-none'),
|
'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, {
|
assign(actions, {
|
||||||
'append.receive-task': appendAction('bpmn:ReceiveTask', 'icon-receive-task'),
|
'append.receive-task': appendAction('bpmn:ReceiveTask', 'icon-receive-task'),
|
||||||
@ -147,9 +209,9 @@ ContextPadProvider.prototype.getContextPadEntries = function(element) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (is(bpmnElement, 'bpmn:FlowNode') ||
|
var replaceOptions = bpmnReplace.getReplaceOptions(element);
|
||||||
(is(bpmnElement, 'bpmn:SequenceFlow') && (is(bpmnElement.sourceRef, 'bpmn:Activity') ||
|
|
||||||
is(bpmnElement.sourceRef, 'bpmn:ExclusiveGateway') || is(bpmnElement.sourceRef, 'bpmn:InclusiveGateway')))) {
|
if (replaceOptions.length) {
|
||||||
// Replace menu entry
|
// Replace menu entry
|
||||||
assign(actions, {
|
assign(actions, {
|
||||||
'replace': {
|
'replace': {
|
||||||
@ -165,8 +227,7 @@ ContextPadProvider.prototype.getContextPadEntries = function(element) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
if (is(bpmnElement, 'bpmn:FlowNode') ||
|
if (isAny(businessObject, [ 'bpmn:FlowNode', 'bpmn:InteractionNode' ])) {
|
||||||
is(bpmnElement, 'bpmn:InteractionNode')) {
|
|
||||||
|
|
||||||
assign(actions, {
|
assign(actions, {
|
||||||
'append.text-annotation': appendAction('bpmn:TextAnnotation', 'icon-text-annotation'),
|
'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, {
|
assign(actions, {
|
||||||
'connect': {
|
'connect': {
|
||||||
group: 'connect',
|
group: 'connect',
|
||||||
@ -226,7 +287,4 @@ function isEventType(eventBo, type, definition) {
|
|||||||
});
|
});
|
||||||
|
|
||||||
return isType && isDefinition;
|
return isType && isDefinition;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
module.exports = ContextPadProvider;
|
|
@ -58,10 +58,6 @@ PaletteProvider.prototype.getPaletteEntries = function(element) {
|
|||||||
create.start(event, elementFactory.createParticipantShape(collapsed));
|
create.start(event, elementFactory.createParticipantShape(collapsed));
|
||||||
}
|
}
|
||||||
|
|
||||||
function createLane(event) {
|
|
||||||
create.start(event, elementFactory.createShape({ type: 'bpmn:Lane' }));
|
|
||||||
}
|
|
||||||
|
|
||||||
assign(actions, {
|
assign(actions, {
|
||||||
'lasso-tool': {
|
'lasso-tool': {
|
||||||
group: 'tools',
|
group: 'tools',
|
||||||
@ -117,15 +113,6 @@ PaletteProvider.prototype.getPaletteEntries = function(element) {
|
|||||||
dragstart: createParticipant,
|
dragstart: createParticipant,
|
||||||
click: createParticipant
|
click: createParticipant
|
||||||
}
|
}
|
||||||
},
|
|
||||||
'create.lane': {
|
|
||||||
group: 'collaboration',
|
|
||||||
className: 'icon-lane',
|
|
||||||
title: 'Create Lane',
|
|
||||||
action: {
|
|
||||||
dragstart: createLane,
|
|
||||||
click: createLane
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -27,7 +27,7 @@ describe('features/palette', function() {
|
|||||||
var entries = domQuery.all('.entry', paletteElement);
|
var entries = domQuery.all('.entry', paletteElement);
|
||||||
|
|
||||||
// then
|
// then
|
||||||
expect(entries.length).to.equal(11);
|
expect(entries.length).to.equal(10);
|
||||||
}));
|
}));
|
||||||
|
|
||||||
});
|
});
|
||||||
|
Loading…
x
Reference in New Issue
Block a user