feat(modeling): I can morph tasks to expanded sub processes
* from expanded subprocesses to tasks or collapsed sub processes is not supported Closes #247
This commit is contained in:
parent
1b9ebfc993
commit
0731c9888b
|
@ -184,7 +184,9 @@ ReplaceMenuProvider.prototype.getEntries = function(element) {
|
|||
|
||||
var isTargetSubProcess = target.type === 'bpmn:SubProcess';
|
||||
|
||||
return isDifferentType(element, target) && !isTargetSubProcess;
|
||||
var isTargetExpanded = target.isExpanded === true;
|
||||
|
||||
return isDifferentType(element, target) && ( !isTargetSubProcess || isTargetExpanded );
|
||||
});
|
||||
|
||||
return this._createEntries(element, entries);
|
||||
|
|
|
@ -52,17 +52,31 @@ function BpmnReplace(bpmnFactory, replace, selection, modeling) {
|
|||
// initialize special properties defined in target definition
|
||||
assign(newBusinessObject, pick(target, CUSTOM_PROPERTIES));
|
||||
|
||||
// copy size (for activities only)
|
||||
if (is(oldBusinessObject, 'bpmn:Activity')) {
|
||||
if (is(oldBusinessObject, 'bpmn:SubProcess')) {
|
||||
|
||||
// TODO: need also to respect min/max Size
|
||||
|
||||
newElement.width = element.width;
|
||||
newElement.height = element.height;
|
||||
newElement.isExpanded = isExpanded(oldBusinessObject);
|
||||
}
|
||||
|
||||
if (is(oldBusinessObject, 'bpmn:SubProcess')) {
|
||||
newElement.isExpanded = isExpanded(oldBusinessObject);
|
||||
// preserve adhoc state while switching collapsed/expanded subprocess
|
||||
if (is(oldBusinessObject, 'bpmn:AdHocSubProcess') && target.isExpanded) {
|
||||
newElement.businessObject = bpmnFactory.create('bpmn:AdHocSubProcess');
|
||||
}
|
||||
|
||||
if (is(oldBusinessObject, 'bpmn:Activity')) {
|
||||
|
||||
// switch collapsed/expanded subprocesses
|
||||
if (target.isExpanded === true) {
|
||||
newElement.isExpanded = true;
|
||||
}
|
||||
|
||||
// TODO: need also to respect min/max Size
|
||||
// copy size, from an expanded subprocess to an expanded alternative subprocess
|
||||
// except bpmn:Task, because Task is always expanded
|
||||
if ((isExpanded(oldBusinessObject) && !is(oldBusinessObject, 'bpmn:Task')) && target.isExpanded) {
|
||||
newElement.width = element.width;
|
||||
newElement.height = element.height;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// transform collapsed/expanded pools
|
||||
|
|
|
@ -484,6 +484,15 @@ module.exports.TASK = [
|
|||
type: 'bpmn:SubProcess',
|
||||
isExpanded: false
|
||||
}
|
||||
},
|
||||
{
|
||||
label: 'Sub Process (expanded)',
|
||||
actionName: 'replace-with-expanded-subprocess',
|
||||
className: 'bpmn-icon-subprocess-expanded',
|
||||
target: {
|
||||
type: 'bpmn:SubProcess',
|
||||
isExpanded: true
|
||||
}
|
||||
}
|
||||
];
|
||||
|
||||
|
|
|
@ -772,6 +772,86 @@ describe('features/replace - bpmn replace', function() {
|
|||
|
||||
});
|
||||
|
||||
describe('morphing collapsed tasks / sub processes into expanded sub processes', function() {
|
||||
|
||||
var diagramXML = require('../../../fixtures/bpmn/features/replace/01_replace.bpmn');
|
||||
|
||||
beforeEach(bootstrapModeler(diagramXML, { modules: testModules }));
|
||||
|
||||
|
||||
it('should allow morphing task into expanded sub process', inject(function(bpmnReplace, elementRegistry) {
|
||||
|
||||
// given
|
||||
var element = elementRegistry.get('Task_1');
|
||||
var newElementData = {
|
||||
type: 'bpmn:SubProcess',
|
||||
isExpanded: true
|
||||
};
|
||||
|
||||
// when
|
||||
var newElement = bpmnReplace.replaceElement(element, newElementData);
|
||||
|
||||
// then
|
||||
expect(is(newElement, 'bpmn:SubProcess')).to.be.true;
|
||||
expect(isExpanded(newElement)).to.be.true;
|
||||
}));
|
||||
|
||||
|
||||
it('should allow morphing collapsed sup process into expanded sub process', inject(function(bpmnReplace, elementRegistry) {
|
||||
|
||||
// given
|
||||
var element = elementRegistry.get('SubProcessCollapsed');
|
||||
var newElementData = {
|
||||
type: 'bpmn:SubProcess',
|
||||
isExpanded: true
|
||||
};
|
||||
|
||||
// when
|
||||
var newElement = bpmnReplace.replaceElement(element, newElementData);
|
||||
|
||||
// then
|
||||
expect(is(newElement, 'bpmn:SubProcess')).to.be.true;
|
||||
expect(isExpanded(newElement)).to.be.true;
|
||||
}));
|
||||
|
||||
|
||||
it('should allow morphing collapsed ad hoc into expanded ad hoc', inject(function(bpmnReplace, elementRegistry) {
|
||||
|
||||
// given
|
||||
var element = elementRegistry.get('AdHocSubProcessCollapsed');
|
||||
var newElementData = {
|
||||
type: 'bpmn:SubProcess',
|
||||
isExpanded: true
|
||||
};
|
||||
|
||||
// when
|
||||
var newElement = bpmnReplace.replaceElement(element, newElementData);
|
||||
|
||||
// then
|
||||
expect(is(newElement, 'bpmn:AdHocSubProcess')).to.be.true;
|
||||
expect(isExpanded(newElement)).to.be.true;
|
||||
}));
|
||||
|
||||
|
||||
it('should keep boundary events', inject(function(bpmnReplace, elementRegistry) {
|
||||
|
||||
// given
|
||||
var element = elementRegistry.get('Task_1');
|
||||
var newElementData = {
|
||||
type: 'bpmn:SubProcess',
|
||||
isExpanded: true
|
||||
};
|
||||
|
||||
// when
|
||||
var newElement = bpmnReplace.replaceElement(element, newElementData);
|
||||
|
||||
// then
|
||||
expect(is(newElement, 'bpmn:SubProcess')).to.be.true;
|
||||
expect(isExpanded(newElement)).to.be.true;
|
||||
expect(newElement.attachers.length).to.be.equal(2);
|
||||
}));
|
||||
|
||||
});
|
||||
|
||||
describe('compensation activity', function() {
|
||||
|
||||
|
|
Loading…
Reference in New Issue