feat(BpmnReplace): morphing between expanded sub processes and transactions
Closes #223
This commit is contained in:
parent
af5354e337
commit
af991e89e9
|
@ -2,7 +2,9 @@
|
|||
|
||||
|
||||
var assign = require('lodash/object/assign'),
|
||||
forEach = require('lodash/collection/forEach');
|
||||
forEach = require('lodash/collection/forEach'),
|
||||
is = require('../../util/ModelUtil').is,
|
||||
isExpanded = require('../../util/DiUtil').isExpanded;
|
||||
|
||||
|
||||
/**
|
||||
|
@ -109,10 +111,10 @@ ContextPadProvider.prototype.getContextPadEntries = function(element) {
|
|||
};
|
||||
}
|
||||
|
||||
if (bpmnElement.$instanceOf('bpmn:FlowNode')) {
|
||||
if (is(bpmnElement, 'bpmn:FlowNode')) {
|
||||
|
||||
if (!bpmnElement.$instanceOf('bpmn:EndEvent') &&
|
||||
!bpmnElement.$instanceOf('bpmn:EventBasedGateway') &&
|
||||
if (!is(bpmnElement, 'bpmn:EndEvent') &&
|
||||
!is(bpmnElement, 'bpmn:EventBasedGateway') &&
|
||||
!isEventType(bpmnElement, 'bpmn:IntermediateThrowEvent', 'bpmn:LinkEventDefinition')) {
|
||||
|
||||
assign(actions, {
|
||||
|
@ -124,7 +126,7 @@ ContextPadProvider.prototype.getContextPadEntries = function(element) {
|
|||
});
|
||||
}
|
||||
|
||||
if (bpmnElement.$instanceOf('bpmn:EventBasedGateway')) {
|
||||
if (is(bpmnElement, 'bpmn:EventBasedGateway')) {
|
||||
|
||||
assign(actions, {
|
||||
'append.receive-task': appendAction('bpmn:ReceiveTask', 'icon-receive-task'),
|
||||
|
@ -145,7 +147,7 @@ ContextPadProvider.prototype.getContextPadEntries = function(element) {
|
|||
|
||||
|
||||
// Replace menu entry
|
||||
if (!bpmnElement.$instanceOf('bpmn:SubProcess')) {
|
||||
if (!(is(bpmnElement, 'bpmn:SubProcess') && !isExpanded(bpmnElement)) || is(bpmnElement, 'bpmn:Transaction')) {
|
||||
assign(actions, {
|
||||
'replace': {
|
||||
group: 'edit',
|
||||
|
@ -161,8 +163,8 @@ ContextPadProvider.prototype.getContextPadEntries = function(element) {
|
|||
}
|
||||
}
|
||||
|
||||
if (bpmnElement.$instanceOf('bpmn:FlowNode') ||
|
||||
bpmnElement.$instanceOf('bpmn:InteractionNode')) {
|
||||
if (is(bpmnElement, 'bpmn:FlowNode') ||
|
||||
is(bpmnElement, 'bpmn:InteractionNode')) {
|
||||
|
||||
assign(actions, {
|
||||
'append.text-annotation': appendAction('bpmn:TextAnnotation', 'icon-text-annotation'),
|
||||
|
|
|
@ -1,7 +1,9 @@
|
|||
'use strict';
|
||||
|
||||
var forEach = require('lodash/collection/forEach'),
|
||||
filter = require('lodash/collection/filter');
|
||||
var forEach = require('lodash/collection/forEach'),
|
||||
filter = require('lodash/collection/filter'),
|
||||
is = require('../../util/ModelUtil').is,
|
||||
isExpanded = require('../../util/DiUtil').isExpanded;
|
||||
|
||||
var REPLACE_OPTIONS = require ('./ReplaceOptions');
|
||||
|
||||
|
@ -9,7 +11,9 @@ var startEventReplace = REPLACE_OPTIONS.START_EVENT,
|
|||
intermediateEventReplace = REPLACE_OPTIONS.INTERMEDIATE_EVENT,
|
||||
endEventReplace = REPLACE_OPTIONS.END_EVENT,
|
||||
gatewayReplace = REPLACE_OPTIONS.GATEWAY,
|
||||
taskReplace = REPLACE_OPTIONS.TASK;
|
||||
taskReplace = REPLACE_OPTIONS.TASK,
|
||||
subProcessReplace = REPLACE_OPTIONS.SUBPROCESS,
|
||||
transactionReplace = REPLACE_OPTIONS.TRANSACTION;
|
||||
|
||||
var is = require('../../util/ModelUtil').is,
|
||||
getBusinessObject = require('../../util/ModelUtil').getBusinessObject;
|
||||
|
@ -63,7 +67,7 @@ function BpmnReplace(bpmnFactory, moddle, popupMenu, replace, selection, modelin
|
|||
}
|
||||
|
||||
// copy size (for activities only)
|
||||
if (oldBusinessObject.$instanceOf('bpmn:Activity')) {
|
||||
if (is(oldBusinessObject, 'bpmn:Activity')) {
|
||||
|
||||
// TODO: need also to respect min/max Size
|
||||
|
||||
|
@ -71,6 +75,10 @@ function BpmnReplace(bpmnFactory, moddle, popupMenu, replace, selection, modelin
|
|||
newElement.height = element.height;
|
||||
}
|
||||
|
||||
if (is(oldBusinessObject, 'bpmn:SubProcess')) {
|
||||
newElement.isExpanded = isExpanded(oldBusinessObject);
|
||||
}
|
||||
|
||||
// TODO: copy other elligable properties from old business object
|
||||
businessObject.name = oldBusinessObject.name;
|
||||
businessObject.loopCharacteristics = oldBusinessObject.loopCharacteristics;
|
||||
|
@ -174,22 +182,22 @@ function BpmnReplace(bpmnFactory, moddle, popupMenu, replace, selection, modelin
|
|||
var menuEntries = [];
|
||||
var businessObject = element.businessObject;
|
||||
|
||||
if (businessObject.$instanceOf('bpmn:StartEvent')) {
|
||||
if (is(businessObject, 'bpmn:StartEvent')) {
|
||||
addEntries(startEventReplace, filterEvents);
|
||||
} else
|
||||
|
||||
if (businessObject.$instanceOf('bpmn:IntermediateCatchEvent') ||
|
||||
businessObject.$instanceOf('bpmn:IntermediateThrowEvent')) {
|
||||
if (is(businessObject, 'bpmn:IntermediateCatchEvent') ||
|
||||
is(businessObject, 'bpmn:IntermediateThrowEvent')) {
|
||||
|
||||
addEntries(intermediateEventReplace, filterEvents);
|
||||
} else
|
||||
|
||||
if (businessObject.$instanceOf('bpmn:EndEvent')) {
|
||||
if (is(businessObject, 'bpmn:EndEvent')) {
|
||||
|
||||
addEntries(endEventReplace, filterEvents);
|
||||
} else
|
||||
|
||||
if (businessObject.$instanceOf('bpmn:Gateway')) {
|
||||
if (is(businessObject, 'bpmn:Gateway')) {
|
||||
|
||||
addEntries(gatewayReplace, function(entry) {
|
||||
|
||||
|
@ -197,7 +205,17 @@ function BpmnReplace(bpmnFactory, moddle, popupMenu, replace, selection, modelin
|
|||
});
|
||||
} else
|
||||
|
||||
if (businessObject.$instanceOf('bpmn:FlowNode')) {
|
||||
if (is(businessObject, 'bpmn:Transaction')) {
|
||||
|
||||
addEntries(transactionReplace, filterEvents);
|
||||
} else
|
||||
|
||||
if (is(businessObject, 'bpmn:SubProcess')) {
|
||||
|
||||
addEntries(subProcessReplace, filterEvents);
|
||||
} else
|
||||
|
||||
if (is(businessObject, 'bpmn:FlowNode')) {
|
||||
addEntries(taskReplace, function(entry) {
|
||||
return entry.target.type !== businessObject.$type;
|
||||
});
|
||||
|
|
|
@ -338,6 +338,28 @@ module.exports.GATEWAY = [
|
|||
// }
|
||||
];
|
||||
|
||||
module.exports.SUBPROCESS = [
|
||||
{
|
||||
label: 'Transaction',
|
||||
actionName: 'replace-with-transaction',
|
||||
className: 'icon-transaction',
|
||||
target: {
|
||||
type: 'bpmn:Transaction',
|
||||
isExpanded: true
|
||||
}
|
||||
}
|
||||
];
|
||||
|
||||
module.exports.TRANSACTION = [
|
||||
{
|
||||
label: 'Sub Process',
|
||||
actionName: 'replace-with-subprocess',
|
||||
className: 'icon-subprocess-expanded',
|
||||
target: {
|
||||
type: 'bpmn:SubProcess'
|
||||
}
|
||||
}
|
||||
];
|
||||
|
||||
module.exports.TASK = [
|
||||
{
|
||||
|
|
|
@ -1,30 +1,38 @@
|
|||
<?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:definitions xmlns:bpmn2="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" id="_opd4cBZiEeWgh4rX9Ivzlg" targetNamespace="http://activiti.org/bpmn" exporter="camunda modeler" exporterVersion="2.7.0" xsi:schemaLocation="http://www.omg.org/spec/BPMN/20100524/MODEL BPMN20.xsd">
|
||||
<bpmn2:process id="Process_1" isExecutable="false">
|
||||
<bpmn2:task id="ParallelTask" name="ParallelTask">
|
||||
<bpmn2:multiInstanceLoopCharacteristics/>
|
||||
<bpmn2:multiInstanceLoopCharacteristics />
|
||||
</bpmn2:task>
|
||||
<bpmn2:task id="SequentialTask" name="SequentialTask">
|
||||
<bpmn2:multiInstanceLoopCharacteristics isSequential="true"/>
|
||||
<bpmn2:multiInstanceLoopCharacteristics isSequential="true" />
|
||||
</bpmn2:task>
|
||||
<bpmn2:task id="LoopTask" name="LoopTask">
|
||||
<bpmn2:standardLoopCharacteristics/>
|
||||
<bpmn2:standardLoopCharacteristics />
|
||||
</bpmn2:task>
|
||||
<bpmn2:task id="Task" name="Task"/>
|
||||
<bpmn2:task id="Task" name="Task" />
|
||||
<bpmn2:subProcess id="SubProcess" />
|
||||
<bpmn2:transaction id="Transaction" />
|
||||
</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"/>
|
||||
<dc:Bounds x="100" y="100" width="100" height="80" />
|
||||
</bpmndi:BPMNShape>
|
||||
<bpmndi:BPMNShape id="_BPMNShape_Task_5" bpmnElement="SequentialTask">
|
||||
<dc:Bounds height="80.0" width="100.0" x="240.0" y="100.0"/>
|
||||
<dc:Bounds x="240" y="100" width="100" height="80" />
|
||||
</bpmndi:BPMNShape>
|
||||
<bpmndi:BPMNShape id="_BPMNShape_Task_6" bpmnElement="LoopTask">
|
||||
<dc:Bounds height="80.0" width="100.0" x="384.0" y="100.0"/>
|
||||
<dc:Bounds x="384" y="100" width="100" height="80" />
|
||||
</bpmndi:BPMNShape>
|
||||
<bpmndi:BPMNShape id="_BPMNShape_Task_8" bpmnElement="Task">
|
||||
<dc:Bounds height="80.0" width="100.0" x="528.0" y="100.0"/>
|
||||
<dc:Bounds x="528" y="100" width="100" height="80" />
|
||||
</bpmndi:BPMNShape>
|
||||
<bpmndi:BPMNShape id="SubProcess_di" bpmnElement="SubProcess" isExpanded="true">
|
||||
<dc:Bounds x="101" y="224" width="350" height="200" />
|
||||
</bpmndi:BPMNShape>
|
||||
<bpmndi:BPMNShape id="Transaction__di" bpmnElement="Transaction" isExpanded="true">
|
||||
<dc:Bounds x="496" y="224" width="350" height="200" />
|
||||
</bpmndi:BPMNShape>
|
||||
</bpmndi:BPMNPlane>
|
||||
</bpmndi:BPMNDiagram>
|
||||
|
|
|
@ -1,12 +1,5 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<bpmn:definitions xmlns:bpmn="http://www.omg.org/spec/BPMN/20100524/MODEL"
|
||||
xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI"
|
||||
xmlns:di="http://www.omg.org/spec/DD/20100524/DI"
|
||||
xmlns:dc="http://www.omg.org/spec/DD/20100524/DC"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
id="Definitions_1"
|
||||
targetNamespace="http://bpmn.io/schema/bpmn">
|
||||
|
||||
<bpmn:definitions xmlns:bpmn="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" id="Definitions_1" targetNamespace="http://bpmn.io/schema/bpmn">
|
||||
<bpmn:process id="Process_1" isExecutable="false">
|
||||
<bpmn:startEvent id="StartEvent_1">
|
||||
<bpmn:outgoing>SequenceFlow_0fn1a6r</bpmn:outgoing>
|
||||
|
@ -25,6 +18,8 @@
|
|||
<bpmn:incoming>SequenceFlow_0rxcijf</bpmn:incoming>
|
||||
</bpmn:endEvent>
|
||||
<bpmn:sequenceFlow id="SequenceFlow_0rxcijf" sourceRef="ExclusiveGateway_1" targetRef="EndEvent_1" />
|
||||
<bpmn:subProcess id="SubProcess_1" />
|
||||
<bpmn:transaction id="Transaction_1" />
|
||||
</bpmn:process>
|
||||
<bpmndi:BPMNDiagram id="BPMNDiagram_1">
|
||||
<bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="Process_1">
|
||||
|
@ -44,7 +39,7 @@
|
|||
<dc:Bounds x="311" y="179" width="90" height="20" />
|
||||
</bpmndi:BPMNLabel>
|
||||
</bpmndi:BPMNEdge>
|
||||
<bpmndi:BPMNShape id="ExclusiveGateway_1_di" bpmnElement="ExclusiveGateway_1">
|
||||
<bpmndi:BPMNShape id="ExclusiveGateway_1_di" bpmnElement="ExclusiveGateway_1" isMarkerVisible="true">
|
||||
<dc:Bounds x="573" y="164" width="50" height="50" />
|
||||
<bpmndi:BPMNLabel>
|
||||
<dc:Bounds x="553" y="214" width="90" height="20" />
|
||||
|
@ -70,6 +65,12 @@
|
|||
<dc:Bounds x="789.5" y="179" width="90" height="20" />
|
||||
</bpmndi:BPMNLabel>
|
||||
</bpmndi:BPMNEdge>
|
||||
<bpmndi:BPMNShape id="SubProcess_1_di" bpmnElement="SubProcess_1" isExpanded="true">
|
||||
<dc:Bounds x="173" y="275" width="350" height="200" />
|
||||
</bpmndi:BPMNShape>
|
||||
<bpmndi:BPMNShape id="Transaction_1xhhubx_di" bpmnElement="Transaction_1" isExpanded="true">
|
||||
<dc:Bounds x="562" y="275" width="350" height="200" />
|
||||
</bpmndi:BPMNShape>
|
||||
</bpmndi:BPMNPlane>
|
||||
</bpmndi:BPMNDiagram>
|
||||
</bpmn:definitions>
|
||||
|
|
|
@ -2,14 +2,20 @@
|
|||
|
||||
/* global bootstrapModeler, inject */
|
||||
|
||||
var TestHelper = require('../../../TestHelper'),
|
||||
coreModule = require('../../../../lib/core'),
|
||||
var TestHelper = require('../../../TestHelper');
|
||||
|
||||
var Events = require('diagram-js/test/util/Events.js');
|
||||
|
||||
var 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'),
|
||||
domClasses = require('min-dom/lib/classes'),
|
||||
is = require('../../../../lib/util/ModelUtil').is;
|
||||
replaceModule = require('../../../../lib/features/replace');
|
||||
|
||||
var domQuery = require('min-dom/lib/query'),
|
||||
domClasses = require('min-dom/lib/classes');
|
||||
|
||||
var is = require('../../../../lib/util/ModelUtil').is,
|
||||
isExpanded = require('../../../../lib/util/DiUtil').isExpanded;
|
||||
|
||||
function queryEntry(popupMenu, id) {
|
||||
return queryPopup(popupMenu, '[data-id="' + id + '"]');
|
||||
|
@ -37,7 +43,7 @@ describe('features/popup-menu', function() {
|
|||
|
||||
// when
|
||||
bpmnReplace.openChooser({ x: task.x + 100, y: task.y + 100 }, task);
|
||||
|
||||
|
||||
// then
|
||||
expect(is(loopCharacteristics, 'bpmn:MultiInstanceLoopCharacteristics')).toBe(true);
|
||||
expect(loopCharacteristics.isSequential).not.toBe(undefined);
|
||||
|
@ -54,10 +60,10 @@ describe('features/popup-menu', function() {
|
|||
|
||||
// when
|
||||
bpmnReplace.openChooser({ x: task.x + 100, y: task.y + 100 }, task);
|
||||
|
||||
|
||||
// then
|
||||
expect(is(loopCharacteristics, 'bpmn:MultiInstanceLoopCharacteristics')).toBe(true);
|
||||
expect(loopCharacteristics.isSequential).toBe(true);
|
||||
expect(loopCharacteristics.isSequential).toBe(true);
|
||||
expect(popupMenu._getEntry('toggle-sequential-mi').active).toBe(true);
|
||||
}));
|
||||
|
||||
|
@ -70,10 +76,10 @@ describe('features/popup-menu', function() {
|
|||
|
||||
// when
|
||||
bpmnReplace.openChooser({ x: task.x + 100, y: task.y + 100 }, task);
|
||||
|
||||
|
||||
// then
|
||||
expect(is(loopCharacteristics, 'bpmn:MultiInstanceLoopCharacteristics')).toBe(false);
|
||||
expect(loopCharacteristics.isSequential).toBe(undefined);
|
||||
expect(loopCharacteristics.isSequential).toBe(undefined);
|
||||
expect(popupMenu._getEntry('toggle-loop').active).toBe(true);
|
||||
}));
|
||||
});
|
||||
|
@ -82,17 +88,17 @@ describe('features/popup-menu', function() {
|
|||
describe('parallel toggle button', function(){
|
||||
|
||||
it('should toggle parallel marker off', inject(function(popupMenu, bpmnReplace, elementRegistry) {
|
||||
|
||||
|
||||
// given
|
||||
var task = elementRegistry.get('ParallelTask');
|
||||
|
||||
bpmnReplace.openChooser({ x: task.x + 100, y: task.y + 100 }, task);
|
||||
|
||||
var entry = queryEntry(popupMenu, 'toggle-parallel-mi'),
|
||||
evt = { target: entry, preventDefault: function(){} };
|
||||
var entry = queryEntry(popupMenu, 'toggle-parallel-mi');
|
||||
|
||||
// when
|
||||
popupMenu.trigger(evt);
|
||||
popupMenu.trigger(Events.create(entry, { x: 0, y: 0 }));
|
||||
|
||||
var parallelEntry = queryEntry(popupMenu, 'toggle-parallel-mi');
|
||||
|
||||
// then
|
||||
|
@ -102,17 +108,17 @@ describe('features/popup-menu', function() {
|
|||
|
||||
|
||||
it('should toggle parallel marker on', inject(function(popupMenu, bpmnReplace, elementRegistry) {
|
||||
|
||||
|
||||
// given
|
||||
var task = elementRegistry.get('Task');
|
||||
|
||||
bpmnReplace.openChooser({ x: task.x + 100, y: task.y + 100 }, task);
|
||||
|
||||
var entry = queryEntry(popupMenu, 'toggle-parallel-mi'),
|
||||
evt = { target: entry, preventDefault: function(){} };
|
||||
var entry = queryEntry(popupMenu, 'toggle-parallel-mi');
|
||||
|
||||
// when
|
||||
popupMenu.trigger(evt);
|
||||
popupMenu.trigger(Events.create(entry, { x: 0, y: 0 }));
|
||||
|
||||
var parallelEntry = queryEntry(popupMenu, 'toggle-parallel-mi');
|
||||
|
||||
// then
|
||||
|
@ -128,11 +134,11 @@ describe('features/popup-menu', function() {
|
|||
var task = elementRegistry.get('SequentialTask');
|
||||
|
||||
bpmnReplace.openChooser({ x: task.x + 100, y: task.y + 100 }, task);
|
||||
|
||||
|
||||
var entry = queryEntry(popupMenu, 'toggle-parallel-mi');
|
||||
|
||||
// when
|
||||
popupMenu.trigger({ target: entry, preventDefault: function(){} });
|
||||
popupMenu.trigger(Events.create(entry, { x: 0, y: 0 }));
|
||||
|
||||
var sequentialEntry = queryEntry(popupMenu, 'toggle-sequential-mi');
|
||||
|
||||
|
@ -145,13 +151,13 @@ describe('features/popup-menu', function() {
|
|||
|
||||
// given
|
||||
var task = elementRegistry.get('LoopTask');
|
||||
|
||||
|
||||
bpmnReplace.openChooser({ x: task.x + 100, y: task.y + 100 }, task);
|
||||
|
||||
|
||||
var entry = queryEntry(popupMenu, 'toggle-parallel-mi');
|
||||
|
||||
// when
|
||||
popupMenu.trigger({ target: entry, preventDefault: function(){} });
|
||||
popupMenu.trigger(Events.create(entry, { x: 0, y: 0 }));
|
||||
|
||||
var loopEntry = queryEntry(popupMenu, 'toggle-loop');
|
||||
|
||||
|
@ -164,17 +170,17 @@ describe('features/popup-menu', function() {
|
|||
describe('sequential toggle button', function(){
|
||||
|
||||
it('should toggle sequential marker off', 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, 'toggle-sequential-mi'),
|
||||
evt = { target: entry, preventDefault: function(){} };
|
||||
var entry = queryEntry(popupMenu, 'toggle-sequential-mi');
|
||||
|
||||
// when
|
||||
popupMenu.trigger(evt);
|
||||
popupMenu.trigger(Events.create(entry, { x: 0, y: 0 }));
|
||||
|
||||
var sequentialEntry = queryEntry(popupMenu, 'toggle-sequential-mi');
|
||||
|
||||
// then
|
||||
|
@ -184,17 +190,16 @@ describe('features/popup-menu', function() {
|
|||
|
||||
|
||||
it('should toggle sequential marker on', inject(function(popupMenu, bpmnReplace, elementRegistry) {
|
||||
|
||||
|
||||
// given
|
||||
var task = elementRegistry.get('Task');
|
||||
|
||||
bpmnReplace.openChooser({ x: task.x + 100, y: task.y + 100 }, task);
|
||||
|
||||
var entry = queryEntry(popupMenu, 'toggle-sequential-mi'),
|
||||
evt = { target: entry, preventDefault: function(){} };
|
||||
var entry = queryEntry(popupMenu, 'toggle-sequential-mi');
|
||||
|
||||
// when
|
||||
popupMenu.trigger(evt);
|
||||
popupMenu.trigger(Events.create(entry, { x: 0, y: 0 }));
|
||||
var sequentialEntry = queryEntry(popupMenu, 'toggle-sequential-mi');
|
||||
|
||||
// then
|
||||
|
@ -210,11 +215,11 @@ describe('features/popup-menu', function() {
|
|||
var task = elementRegistry.get('LoopTask');
|
||||
|
||||
bpmnReplace.openChooser({ x: task.x + 100, y: task.y + 100 }, task);
|
||||
|
||||
|
||||
var entry = queryEntry(popupMenu, 'toggle-sequential-mi');
|
||||
|
||||
// when
|
||||
popupMenu.trigger({ target: entry, preventDefault: function(){} });
|
||||
popupMenu.trigger(Events.create(entry, { x: 0, y: 0 }));
|
||||
|
||||
var loopEntry = queryEntry(popupMenu, 'toggle-loop');
|
||||
|
||||
|
@ -229,12 +234,12 @@ describe('features/popup-menu', function() {
|
|||
var task = elementRegistry.get('ParallelTask');
|
||||
|
||||
bpmnReplace.openChooser({ x: task.x + 100, y: task.y + 100 }, task);
|
||||
|
||||
|
||||
var entry = queryEntry(popupMenu, 'toggle-sequential-mi');
|
||||
|
||||
// when
|
||||
popupMenu.trigger({ target: entry, preventDefault: function(){} });
|
||||
|
||||
popupMenu.trigger(Events.create(entry, { x: 0, y: 0 }));
|
||||
|
||||
var parallelEntry = queryEntry(popupMenu, 'toggle-parallel-mi');
|
||||
|
||||
// then
|
||||
|
@ -246,17 +251,16 @@ describe('features/popup-menu', function() {
|
|||
describe('loop toggle button', function(){
|
||||
|
||||
it('should toggle loop marker off', inject(function(popupMenu, bpmnReplace, elementRegistry) {
|
||||
|
||||
|
||||
// given
|
||||
var task = elementRegistry.get('LoopTask');
|
||||
|
||||
bpmnReplace.openChooser({ x: task.x + 100, y: task.y + 100 }, task);
|
||||
|
||||
var entry = queryEntry(popupMenu, 'toggle-loop'),
|
||||
evt = { target: entry, preventDefault: function(){} };
|
||||
|
||||
var entry = queryEntry(popupMenu, 'toggle-loop');
|
||||
// when
|
||||
popupMenu.trigger(evt);
|
||||
popupMenu.trigger(Events.create(entry, { x: 0, y: 0 }));
|
||||
|
||||
var loopEntry = queryEntry(popupMenu, 'toggle-loop');
|
||||
|
||||
// then
|
||||
|
@ -266,17 +270,17 @@ describe('features/popup-menu', function() {
|
|||
|
||||
|
||||
it('should toggle loop marker on', inject(function(popupMenu, bpmnReplace, elementRegistry){
|
||||
|
||||
|
||||
// given
|
||||
var task = elementRegistry.get('Task');
|
||||
|
||||
bpmnReplace.openChooser({ x: task.x + 100, y: task.y + 100 }, task);
|
||||
|
||||
var entry = queryEntry(popupMenu, 'toggle-loop'),
|
||||
evt = { target: entry, preventDefault: function(){} };
|
||||
var entry = queryEntry(popupMenu, 'toggle-loop');
|
||||
|
||||
// when
|
||||
popupMenu.trigger(evt);
|
||||
popupMenu.trigger(Events.create(entry, { x: 0, y: 0 }));
|
||||
|
||||
var loopEntry = queryEntry(popupMenu, 'toggle-loop');
|
||||
|
||||
// then
|
||||
|
@ -291,12 +295,12 @@ describe('features/popup-menu', function() {
|
|||
var task = elementRegistry.get('SequentialTask');
|
||||
|
||||
bpmnReplace.openChooser({ x: task.x + 100, y: task.y + 100 }, task);
|
||||
|
||||
|
||||
var entry = queryEntry(popupMenu, 'toggle-loop');
|
||||
|
||||
// when
|
||||
popupMenu.trigger({ target: entry, preventDefault: function(){} });
|
||||
|
||||
popupMenu.trigger(Events.create(entry, { x: 0, y: 0 }));
|
||||
|
||||
var sequentialEntry = queryEntry(popupMenu, 'toggle-sequential-mi');
|
||||
|
||||
// then
|
||||
|
@ -310,12 +314,12 @@ describe('features/popup-menu', function() {
|
|||
var task = elementRegistry.get('ParallelTask');
|
||||
|
||||
bpmnReplace.openChooser({ x: task.x + 100, y: task.y + 100 }, task);
|
||||
|
||||
|
||||
var entry = queryEntry(popupMenu, 'toggle-loop');
|
||||
|
||||
// when
|
||||
popupMenu.trigger({ target: entry, preventDefault: function(){} });
|
||||
|
||||
popupMenu.trigger(Events.create(entry, { x: 0, y: 0 }));
|
||||
|
||||
var parallelEntry = queryEntry(popupMenu, 'toggle-parallel-mi');
|
||||
|
||||
// then
|
||||
|
@ -324,7 +328,7 @@ describe('features/popup-menu', function() {
|
|||
});
|
||||
|
||||
|
||||
describe('replacing a task', function() {
|
||||
describe('replacing', function() {
|
||||
|
||||
it('should retain the loop characteristics', inject(function(popupMenu, bpmnReplace, elementRegistry) {
|
||||
|
||||
|
@ -337,7 +341,7 @@ describe('features/popup-menu', function() {
|
|||
|
||||
// when
|
||||
// replacing the task with a send task
|
||||
popupMenu.trigger({ target: entry, preventDefault: function(){} });
|
||||
popupMenu.trigger(Events.create(entry, { x: 0, y: 0 }));
|
||||
|
||||
// then
|
||||
// get the send task from the registry
|
||||
|
@ -348,7 +352,7 @@ describe('features/popup-menu', function() {
|
|||
expect(sendTask.businessObject.loopCharacteristics.isSequential).toBe(true);
|
||||
}));
|
||||
|
||||
|
||||
|
||||
it('should retain the loop characteristics for call activites',
|
||||
inject(function(popupMenu, bpmnReplace, elementRegistry) {
|
||||
|
||||
|
@ -361,7 +365,7 @@ describe('features/popup-menu', function() {
|
|||
|
||||
// when
|
||||
// replacing the task with a call activity
|
||||
popupMenu.trigger({ target: entry, preventDefault: function(){} });
|
||||
popupMenu.trigger(Events.create(entry, { x: 0, y: 0 }));
|
||||
|
||||
// then
|
||||
// get the send task from the registry
|
||||
|
@ -375,6 +379,56 @@ describe('features/popup-menu', function() {
|
|||
|
||||
}));
|
||||
|
||||
|
||||
it('should retain expanded status for sub processes',
|
||||
inject(function(popupMenu, bpmnReplace, elementRegistry) {
|
||||
|
||||
// given
|
||||
var subProcess = elementRegistry.get('SubProcess');
|
||||
|
||||
bpmnReplace.openChooser({ x: subProcess.x + 100, y: subProcess.y + 100 }, subProcess);
|
||||
|
||||
var entry = queryEntry(popupMenu, 'replace-with-transaction');
|
||||
|
||||
// when
|
||||
// replacing the expanded sub process with a transaction
|
||||
popupMenu.trigger(Events.create(entry, { x: 0, y: 0 }));
|
||||
|
||||
// then
|
||||
// get the morphed transacion from the registry
|
||||
var transaction = elementRegistry.filter(function(element, gfx) {
|
||||
return element.x === subProcess.x && element.y === subProcess.y;
|
||||
})[0];
|
||||
|
||||
expect(isExpanded(transaction)).toBe(isExpanded(subProcess));
|
||||
|
||||
}));
|
||||
|
||||
|
||||
it('should retain the loop characteristics and the expanded status for transactions',
|
||||
inject(function(popupMenu, bpmnReplace, elementRegistry) {
|
||||
|
||||
// given
|
||||
var transaction = elementRegistry.get('Transaction');
|
||||
|
||||
bpmnReplace.openChooser({ x: transaction.x + 100, y: transaction.y + 100 }, transaction);
|
||||
|
||||
var entry = queryEntry(popupMenu, 'replace-with-subprocess');
|
||||
|
||||
// when
|
||||
// replacing the expanded sub process with a transaction
|
||||
popupMenu.trigger(Events.create(entry, { x: 0, y: 0 }));
|
||||
|
||||
// then
|
||||
// get the morphed transacion from the registry
|
||||
var subProcess = elementRegistry.filter(function(element, gfx) {
|
||||
return element.x === transaction.x && element.y === transaction.y;
|
||||
})[0];
|
||||
|
||||
expect(isExpanded(subProcess)).toBe(isExpanded(transaction));
|
||||
|
||||
}));
|
||||
|
||||
});
|
||||
|
||||
});
|
||||
|
|
|
@ -6,8 +6,8 @@ var TestHelper = require('../../../TestHelper');
|
|||
|
||||
var modelingModule = require('../../../../lib/features/modeling'),
|
||||
replaceModule = require('../../../../lib/features/replace'),
|
||||
coreModule = require('../../../../lib/core');
|
||||
|
||||
coreModule = require('../../../../lib/core'),
|
||||
is = require('../../../../lib/util/ModelUtil').is;
|
||||
|
||||
|
||||
describe('features/replace', function() {
|
||||
|
@ -36,7 +36,7 @@ describe('features/replace', function() {
|
|||
var businessObject = newElement.businessObject;
|
||||
|
||||
expect(newElement).toBeDefined();
|
||||
expect(businessObject.$instanceOf('bpmn:UserTask')).toBe(true);
|
||||
expect(is(businessObject, 'bpmn:UserTask')).toBe(true);
|
||||
}));
|
||||
|
||||
|
||||
|
@ -56,7 +56,42 @@ describe('features/replace', function() {
|
|||
var businessObject = newElement.businessObject;
|
||||
|
||||
expect(newElement).toBeDefined();
|
||||
expect(businessObject.$instanceOf('bpmn:InclusiveGateway')).toBe(true);
|
||||
expect(is(businessObject, 'bpmn:InclusiveGateway')).toBe(true);
|
||||
}));
|
||||
|
||||
|
||||
it('expanded sub process', inject(function(elementRegistry, modeling, bpmnReplace, canvas) {
|
||||
|
||||
// given
|
||||
var subProcess = elementRegistry.get('SubProcess_1'),
|
||||
newElementData = {
|
||||
type: 'bpmn:Transaction',
|
||||
isExpanded: true
|
||||
};
|
||||
|
||||
// when
|
||||
var newElement = bpmnReplace.replaceElement(subProcess, newElementData);
|
||||
|
||||
// then
|
||||
expect(newElement).toBeDefined();
|
||||
expect(is(newElement.businessObject, 'bpmn:Transaction')).toBe(true);
|
||||
|
||||
}));
|
||||
|
||||
|
||||
it('transaction', inject(function(elementRegistry, modeling, bpmnReplace, canvas) {
|
||||
|
||||
var transaction = elementRegistry.get('Transaction_1'),
|
||||
newElementData = {
|
||||
type: 'bpmn:SubProcess',
|
||||
isExpanded: true
|
||||
};
|
||||
|
||||
var newElement = bpmnReplace.replaceElement(transaction, newElementData);
|
||||
|
||||
expect(newElement).toBeDefined();
|
||||
expect(is(newElement.businessObject, 'bpmn:SubProcess')).toBe(true);
|
||||
|
||||
}));
|
||||
|
||||
});
|
||||
|
@ -144,7 +179,7 @@ describe('features/replace', function() {
|
|||
businessObject = target.businessObject;
|
||||
|
||||
expect(target).toBeDefined();
|
||||
expect(businessObject.$instanceOf('bpmn:Task')).toBe(true);
|
||||
expect(is(businessObject, 'bpmn:Task')).toBe(true);
|
||||
}));
|
||||
|
||||
|
||||
|
@ -173,7 +208,7 @@ describe('features/replace', function() {
|
|||
var businessObject = servicetask.businessObject;
|
||||
|
||||
expect(servicetask).toBeDefined();
|
||||
expect(businessObject.$instanceOf('bpmn:ServiceTask')).toBe(true);
|
||||
expect(is(businessObject, 'bpmn:ServiceTask')).toBe(true);
|
||||
}));
|
||||
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue