feat(popup-menu): allow morphing a task into a call activity
Closes #304
This commit is contained in:
parent
71a5c2e1ed
commit
6da0d166e3
|
@ -71,6 +71,8 @@ function BpmnReplace(bpmnFactory, moddle, popupMenu, replace, selection) {
|
||||||
// TODO: copy other elligable properties from old business object
|
// TODO: copy other elligable properties from old business object
|
||||||
businessObject.name = oldBusinessObject.name;
|
businessObject.name = oldBusinessObject.name;
|
||||||
|
|
||||||
|
businessObject.loopCharacteristics = oldBusinessObject.loopCharacteristics;
|
||||||
|
|
||||||
newElement = replace.replaceElement(element, newElement);
|
newElement = replace.replaceElement(element, newElement);
|
||||||
|
|
||||||
selection.select(newElement);
|
selection.select(newElement);
|
||||||
|
|
|
@ -403,5 +403,13 @@ module.exports.TASK = [
|
||||||
target: {
|
target: {
|
||||||
type: 'bpmn:ScriptTask'
|
type: 'bpmn:ScriptTask'
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: 'Call Activity',
|
||||||
|
actionName: 'replace-with-call-activity',
|
||||||
|
className: 'icon-call-activity',
|
||||||
|
target: {
|
||||||
|
type: 'bpmn:CallActivity'
|
||||||
|
}
|
||||||
}
|
}
|
||||||
];
|
];
|
|
@ -0,0 +1,31 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<bpmn2:definitions xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:bpmn2="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xsi:schemaLocation="http://www.omg.org/spec/BPMN/20100524/MODEL BPMN20.xsd" id="_opd4cBZiEeWgh4rX9Ivzlg" exporter="camunda modeler" exporterVersion="2.7.0" targetNamespace="http://activiti.org/bpmn">
|
||||||
|
<bpmn2:process id="Process_1" isExecutable="false">
|
||||||
|
<bpmn2:task id="ParallelTask" name="ParallelTask">
|
||||||
|
<bpmn2:multiInstanceLoopCharacteristics/>
|
||||||
|
</bpmn2:task>
|
||||||
|
<bpmn2:task id="SequentialTask" name="SequentialTask">
|
||||||
|
<bpmn2:multiInstanceLoopCharacteristics isSequential="true"/>
|
||||||
|
</bpmn2:task>
|
||||||
|
<bpmn2:task id="LoopTask" name="LoopTask">
|
||||||
|
<bpmn2:standardLoopCharacteristics/>
|
||||||
|
</bpmn2:task>
|
||||||
|
<bpmn2:task id="Task" name="Task"/>
|
||||||
|
</bpmn2:process>
|
||||||
|
<bpmndi:BPMNDiagram id="BPMNDiagram_1">
|
||||||
|
<bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="Process_1">
|
||||||
|
<bpmndi:BPMNShape id="_BPMNShape_Task_4" bpmnElement="ParallelTask">
|
||||||
|
<dc:Bounds height="80.0" width="100.0" x="100.0" y="100.0"/>
|
||||||
|
</bpmndi:BPMNShape>
|
||||||
|
<bpmndi:BPMNShape id="_BPMNShape_Task_5" bpmnElement="SequentialTask">
|
||||||
|
<dc:Bounds height="80.0" width="100.0" x="240.0" y="100.0"/>
|
||||||
|
</bpmndi:BPMNShape>
|
||||||
|
<bpmndi:BPMNShape id="_BPMNShape_Task_6" bpmnElement="LoopTask">
|
||||||
|
<dc:Bounds height="80.0" width="100.0" x="384.0" y="100.0"/>
|
||||||
|
</bpmndi:BPMNShape>
|
||||||
|
<bpmndi:BPMNShape id="_BPMNShape_Task_8" bpmnElement="Task">
|
||||||
|
<dc:Bounds height="80.0" width="100.0" x="528.0" y="100.0"/>
|
||||||
|
</bpmndi:BPMNShape>
|
||||||
|
</bpmndi:BPMNPlane>
|
||||||
|
</bpmndi:BPMNDiagram>
|
||||||
|
</bpmn2:definitions>
|
|
@ -0,0 +1,59 @@
|
||||||
|
'use strict';
|
||||||
|
|
||||||
|
/* global bootstrapModeler, inject */
|
||||||
|
|
||||||
|
var TestHelper = require('../../../TestHelper'),
|
||||||
|
coreModule = require('../../../../lib/core'),
|
||||||
|
popupMenuModule = require('diagram-js/lib/features/popup-menu'),
|
||||||
|
modelingModule = require('../../../../lib/features/modeling'),
|
||||||
|
replaceModule = require('../../../../lib/features/replace'),
|
||||||
|
domQuery = require('min-dom/lib/query'),
|
||||||
|
is = require('../../../../lib/util/ModelUtil').is;
|
||||||
|
|
||||||
|
function queryEntry(popupMenu, id) {
|
||||||
|
return queryPopup(popupMenu, '[data-id="' + id + '"]');
|
||||||
|
}
|
||||||
|
|
||||||
|
function queryPopup(popupMenu, selector) {
|
||||||
|
return domQuery(selector, popupMenu._current.container);
|
||||||
|
}
|
||||||
|
|
||||||
|
describe('features/popup-menu', function() {
|
||||||
|
|
||||||
|
var diagramXML = require('../../../fixtures/bpmn/draw/activity-markers-simple.bpmn');
|
||||||
|
|
||||||
|
var testModules = [ coreModule, modelingModule, popupMenuModule, replaceModule ];
|
||||||
|
|
||||||
|
beforeEach(bootstrapModeler(diagramXML, { modules: testModules }));
|
||||||
|
|
||||||
|
|
||||||
|
describe('replacing a task', function() {
|
||||||
|
|
||||||
|
it('should retain the loop characteristics for call activites',
|
||||||
|
inject(function(popupMenu, bpmnReplace, elementRegistry) {
|
||||||
|
|
||||||
|
// given
|
||||||
|
var task = elementRegistry.get('SequentialTask');
|
||||||
|
|
||||||
|
bpmnReplace.openChooser({ x: task.x + 100, y: task.y + 100 }, task);
|
||||||
|
|
||||||
|
var entry = queryEntry(popupMenu, 'replace-with-call-activity');
|
||||||
|
|
||||||
|
// when
|
||||||
|
// replacing the task with a call activity
|
||||||
|
popupMenu.trigger({ target: entry, preventDefault: function(){} });
|
||||||
|
|
||||||
|
// then
|
||||||
|
// get the send task from the registry
|
||||||
|
var callActivity = elementRegistry.filter(function(element, gfx) {
|
||||||
|
return element.type === 'bpmn:CallActivity';
|
||||||
|
})[0];
|
||||||
|
|
||||||
|
expect(callActivity.businessObject.loopCharacteristics).toBeDefined();
|
||||||
|
expect(is(callActivity.businessObject.loopCharacteristics, 'bpmn:MultiInstanceLoopCharacteristics')).toBe(true);
|
||||||
|
expect(callActivity.businessObject.loopCharacteristics.isSequential).toBe(true);
|
||||||
|
}));
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
});
|
Loading…
Reference in New Issue