feat(replace): model collapsed subprocesses using the replace menu

Closes #303
This commit is contained in:
pedesen 2015-07-03 10:48:32 +02:00 committed by Ricardo Matias
parent af991e89e9
commit 88f91d342b
8 changed files with 34 additions and 30 deletions

View File

@ -3,8 +3,7 @@
var assign = require('lodash/object/assign'),
forEach = require('lodash/collection/forEach'),
is = require('../../util/ModelUtil').is,
isExpanded = require('../../util/DiUtil').isExpanded;
is = require('../../util/ModelUtil').is;
/**
@ -147,20 +146,18 @@ ContextPadProvider.prototype.getContextPadEntries = function(element) {
// Replace menu entry
if (!(is(bpmnElement, 'bpmn:SubProcess') && !isExpanded(bpmnElement)) || is(bpmnElement, 'bpmn:Transaction')) {
assign(actions, {
'replace': {
group: 'edit',
className: 'icon-screw-wrench',
title: 'Change type',
action: {
click: function(event, element) {
bpmnReplace.openChooser(getReplaceMenuPosition(element), element);
}
assign(actions, {
'replace': {
group: 'edit',
className: 'icon-screw-wrench',
title: 'Change type',
action: {
click: function(event, element) {
bpmnReplace.openChooser(getReplaceMenuPosition(element), element);
}
}
});
}
}
});
}
if (is(bpmnElement, 'bpmn:FlowNode') ||

View File

@ -346,7 +346,7 @@ function canCreate(shape, target, source) {
function canResize(shape, newBounds) {
if (is(shape, 'bpmn:SubProcess')) {
return isExpanded(shape) && (
return (!!isExpanded(shape)) && (
!newBounds || (newBounds.width >= 100 && newBounds.height >= 80)
);
}

View File

@ -98,10 +98,6 @@ PaletteProvider.prototype.getPaletteEntries = function(element) {
'create.task': createAction(
'bpmn:Task', 'activity', 'icon-task'
),
'create.subprocess-collapsed': createAction(
'bpmn:SubProcess', 'activity', 'icon-subprocess-collapsed', 'Create collapsed Sub Process',
{ isExpanded: false }
),
'create.subprocess-expanded': createAction(
'bpmn:SubProcess', 'activity', 'icon-subprocess-expanded', 'Create expanded SubProcess',
{ isExpanded: true }

View File

@ -12,7 +12,7 @@ var startEventReplace = REPLACE_OPTIONS.START_EVENT,
endEventReplace = REPLACE_OPTIONS.END_EVENT,
gatewayReplace = REPLACE_OPTIONS.GATEWAY,
taskReplace = REPLACE_OPTIONS.TASK,
subProcessReplace = REPLACE_OPTIONS.SUBPROCESS,
subProcessExpandedReplace = REPLACE_OPTIONS.SUBPROCESS_EXPANDED,
transactionReplace = REPLACE_OPTIONS.TRANSACTION;
var is = require('../../util/ModelUtil').is,
@ -210,9 +210,9 @@ function BpmnReplace(bpmnFactory, moddle, popupMenu, replace, selection, modelin
addEntries(transactionReplace, filterEvents);
} else
if (is(businessObject, 'bpmn:SubProcess')) {
if (is(businessObject, 'bpmn:SubProcess') && isExpanded(businessObject)) {
addEntries(subProcessReplace, filterEvents);
addEntries(subProcessExpandedReplace, filterEvents);
} else
if (is(businessObject, 'bpmn:FlowNode')) {

View File

@ -338,7 +338,7 @@ module.exports.GATEWAY = [
// }
];
module.exports.SUBPROCESS = [
module.exports.SUBPROCESS_EXPANDED = [
{
label: 'Transaction',
actionName: 'replace-with-transaction',
@ -433,5 +433,14 @@ module.exports.TASK = [
target: {
type: 'bpmn:CallActivity'
}
},
{
label: 'Collapsed Sub Process',
actionName: 'replace-with-collapsed-subprocess',
className: 'icon-subprocess-collapsed',
target: {
type: 'bpmn:SubProcess',
isExpanded: false
}
}
];

View File

@ -5,13 +5,15 @@ var inherits = require('inherits');
var forEach = require('lodash/collection/forEach');
var getBoundingBox = require('diagram-js/lib/util/Elements').getBBox;
var is = require('../modeling/ModelingUtil').is;
var is = require('../modeling/ModelingUtil').is,
isExpanded = require('../../util/DiUtil').isExpanded;
var Snapping = require('diagram-js/lib/features/snapping/Snapping'),
SnapUtil = require('diagram-js/lib/features/snapping/SnapUtil');
var is = require('../../util/ModelUtil').is;
var mid = SnapUtil.mid,
topLeft = SnapUtil.topLeft,
bottomRight = SnapUtil.bottomRight;
@ -125,7 +127,7 @@ function BpmnSnapping(eventBus, canvas) {
var context = event.context,
shape = context.shape;
if (is(shape, 'bpmn:SubProcess')) {
if (is(shape, 'bpmn:SubProcess') && isExpanded(shape)) {
context.minDimensions = { width: 140, height: 120 };
}

View File

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