fix(replace): do not resize on replace sub process with ad hoc
Requires bpmn-io/diagram-js#432 Closes #1231
This commit is contained in:
parent
f8ef569eb9
commit
dd3a139a29
|
@ -484,9 +484,15 @@ ReplaceMenuProvider.prototype._getAdHocEntry = function(element) {
|
|||
active: isAdHoc,
|
||||
action: function(event, entry) {
|
||||
if (isAdHoc) {
|
||||
return replaceElement(element, { type: 'bpmn:SubProcess' });
|
||||
return replaceElement(element, { type: 'bpmn:SubProcess' }, {
|
||||
autoResize: false,
|
||||
layoutConnection: false
|
||||
});
|
||||
} else {
|
||||
return replaceElement(element, { type: 'bpmn:AdHocSubProcess' });
|
||||
return replaceElement(element, { type: 'bpmn:AdHocSubProcess' }, {
|
||||
autoResize: false,
|
||||
layoutConnection: false
|
||||
});
|
||||
}
|
||||
}
|
||||
};
|
||||
|
|
|
@ -1,13 +1,95 @@
|
|||
<?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" id="Definitions_1" targetNamespace="http://bpmn.io/schema/bpmn" exporter="Camunda Modeler" exporterVersion="0.7.0-dev">
|
||||
<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" id="Definitions_1" targetNamespace="http://bpmn.io/schema/bpmn" exporter="Camunda Modeler" exporterVersion="3.3.5">
|
||||
<bpmn:process id="Process_1" isExecutable="false">
|
||||
<bpmn:subProcess id="Task_1" />
|
||||
<bpmn:subProcess id="SubProcess_1">
|
||||
<bpmn:outgoing>SequenceFlow_3</bpmn:outgoing>
|
||||
<bpmn:startEvent id="StartEvent_1">
|
||||
<bpmn:outgoing>SequenceFlow_1</bpmn:outgoing>
|
||||
</bpmn:startEvent>
|
||||
<bpmn:task id="Task_2">
|
||||
<bpmn:incoming>SequenceFlow_1</bpmn:incoming>
|
||||
<bpmn:outgoing>SequenceFlow_2</bpmn:outgoing>
|
||||
</bpmn:task>
|
||||
<bpmn:sequenceFlow id="SequenceFlow_1" sourceRef="StartEvent_1" targetRef="Task_2" />
|
||||
<bpmn:endEvent id="EndEvent_1">
|
||||
<bpmn:incoming>SequenceFlow_2</bpmn:incoming>
|
||||
</bpmn:endEvent>
|
||||
<bpmn:sequenceFlow id="SequenceFlow_2" sourceRef="Task_2" targetRef="EndEvent_1" />
|
||||
</bpmn:subProcess>
|
||||
<bpmn:endEvent id="EndEvent_2">
|
||||
<bpmn:incoming>SequenceFlow_3</bpmn:incoming>
|
||||
</bpmn:endEvent>
|
||||
<bpmn:sequenceFlow id="SequenceFlow_3" sourceRef="SubProcess_1" targetRef="EndEvent_2" />
|
||||
<bpmn:adHocSubProcess id="AdhocSubProcess_1">
|
||||
<bpmn:startEvent id="StartEvent_2">
|
||||
<bpmn:outgoing>SequenceFlow_4</bpmn:outgoing>
|
||||
</bpmn:startEvent>
|
||||
<bpmn:task id="Task_3">
|
||||
<bpmn:incoming>SequenceFlow_4</bpmn:incoming>
|
||||
<bpmn:outgoing>SequenceFlow_5</bpmn:outgoing>
|
||||
</bpmn:task>
|
||||
<bpmn:endEvent id="EndEvent_3">
|
||||
<bpmn:incoming>SequenceFlow_5</bpmn:incoming>
|
||||
</bpmn:endEvent>
|
||||
<bpmn:sequenceFlow id="SequenceFlow_4" sourceRef="StartEvent_2" targetRef="Task_3" />
|
||||
<bpmn:sequenceFlow id="SequenceFlow_5" sourceRef="Task_3" targetRef="EndEvent_3" />
|
||||
</bpmn:adHocSubProcess>
|
||||
</bpmn:process>
|
||||
<bpmndi:BPMNDiagram id="BPMNDiagram_1">
|
||||
<bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="Process_1">
|
||||
<bpmndi:BPMNShape id="SubProcess_0loe8m1_di" bpmnElement="Task_1">
|
||||
<dc:Bounds x="149" y="128" width="100" height="80" />
|
||||
</bpmndi:BPMNShape>
|
||||
<bpmndi:BPMNShape id="SubProcess_078mjn9_di" bpmnElement="SubProcess_1" isExpanded="false">
|
||||
<dc:Bounds x="485" y="128" width="100" height="80" />
|
||||
</bpmndi:BPMNShape>
|
||||
<bpmndi:BPMNShape id="StartEvent_06rrfr5_di" bpmnElement="StartEvent_1">
|
||||
<dc:Bounds x="400" y="150" width="36" height="36" />
|
||||
</bpmndi:BPMNShape>
|
||||
<bpmndi:BPMNShape id="Task_06m6q8n_di" bpmnElement="Task_2">
|
||||
<dc:Bounds x="490" y="128" width="100" height="80" />
|
||||
</bpmndi:BPMNShape>
|
||||
<bpmndi:BPMNEdge id="SequenceFlow_09ygyhb_di" bpmnElement="SequenceFlow_1">
|
||||
<di:waypoint x="436" y="168" />
|
||||
<di:waypoint x="490" y="168" />
|
||||
</bpmndi:BPMNEdge>
|
||||
<bpmndi:BPMNShape id="EndEvent_1sgr4mk_di" bpmnElement="EndEvent_1">
|
||||
<dc:Bounds x="652" y="150" width="36" height="36" />
|
||||
</bpmndi:BPMNShape>
|
||||
<bpmndi:BPMNEdge id="SequenceFlow_10kqeu3_di" bpmnElement="SequenceFlow_2">
|
||||
<di:waypoint x="590" y="168" />
|
||||
<di:waypoint x="652" y="168" />
|
||||
</bpmndi:BPMNEdge>
|
||||
<bpmndi:BPMNShape id="EndEvent_1tbfi2d_di" bpmnElement="EndEvent_2">
|
||||
<dc:Bounds x="762" y="232" width="36" height="36" />
|
||||
</bpmndi:BPMNShape>
|
||||
<bpmndi:BPMNEdge id="SequenceFlow_18gyvps_di" bpmnElement="SequenceFlow_3">
|
||||
<di:waypoint x="585" y="168" />
|
||||
<di:waypoint x="670" y="168" />
|
||||
<di:waypoint x="670" y="250" />
|
||||
<di:waypoint x="762" y="250" />
|
||||
</bpmndi:BPMNEdge>
|
||||
<bpmndi:BPMNShape id="StartEvent_1kebej2_di" bpmnElement="StartEvent_2">
|
||||
<dc:Bounds x="855" y="150" width="36" height="36" />
|
||||
</bpmndi:BPMNShape>
|
||||
<bpmndi:BPMNShape id="Task_1qnpo60_di" bpmnElement="Task_3">
|
||||
<dc:Bounds x="945" y="128" width="100" height="80" />
|
||||
</bpmndi:BPMNShape>
|
||||
<bpmndi:BPMNEdge id="SequenceFlow_1ffetd8_di" bpmnElement="SequenceFlow_4">
|
||||
<di:waypoint x="891" y="168" />
|
||||
<di:waypoint x="945" y="168" />
|
||||
</bpmndi:BPMNEdge>
|
||||
<bpmndi:BPMNShape id="EndEvent_0a4p737_di" bpmnElement="EndEvent_3">
|
||||
<dc:Bounds x="1107" y="150" width="36" height="36" />
|
||||
</bpmndi:BPMNShape>
|
||||
<bpmndi:BPMNEdge id="SequenceFlow_1qs2ip4_di" bpmnElement="SequenceFlow_5">
|
||||
<di:waypoint x="1045" y="168" />
|
||||
<di:waypoint x="1107" y="168" />
|
||||
</bpmndi:BPMNEdge>
|
||||
<bpmndi:BPMNShape id="AdHocSubProcess_0lfb35q_di" bpmnElement="AdhocSubProcess_1" isExpanded="false">
|
||||
<dc:Bounds x="940" y="128" width="100" height="80" />
|
||||
</bpmndi:BPMNShape>
|
||||
</bpmndi:BPMNPlane>
|
||||
</bpmndi:BPMNDiagram>
|
||||
</bpmn:definitions>
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
/* global sinon */
|
||||
|
||||
import {
|
||||
bootstrapModeler,
|
||||
getBpmnJS,
|
||||
|
@ -8,10 +10,11 @@ import {
|
|||
createEvent as globalEvent
|
||||
} from '../../../util/MockEvents';
|
||||
|
||||
import autoResizeModule from 'lib/features/auto-resize';
|
||||
import coreModule from 'lib/core';
|
||||
import customRulesModule from '../../../util/custom-rules';
|
||||
import modelingModule from 'lib/features/modeling';
|
||||
import replaceMenuProviderModule from 'lib/features/popup-menu';
|
||||
import customRulesModule from '../../../util/custom-rules';
|
||||
|
||||
import {
|
||||
query as domQuery,
|
||||
|
@ -58,6 +61,8 @@ function triggerAction(entries, id) {
|
|||
entry.action();
|
||||
}
|
||||
|
||||
var spy = sinon.spy;
|
||||
|
||||
|
||||
describe('features/popup-menu - replace menu provider', function() {
|
||||
|
||||
|
@ -1884,6 +1889,100 @@ describe('features/popup-menu - replace menu provider', function() {
|
|||
|
||||
});
|
||||
|
||||
|
||||
describe('adhoc sub process', function() {
|
||||
|
||||
var diagramXML = require('./ReplaceMenuProvider.collapsedSubProcess.bpmn');
|
||||
|
||||
beforeEach(bootstrapModeler(diagramXML, {
|
||||
modules: testModules.concat(autoResizeModule)
|
||||
}));
|
||||
|
||||
|
||||
describe('sub process -> adhoc', function() {
|
||||
|
||||
it('should not resize', inject(function(elementRegistry, modeling, popupMenu) {
|
||||
|
||||
// given
|
||||
var subProcess = elementRegistry.get('SubProcess_1');
|
||||
|
||||
var resizeShapeSpy = spy(modeling, 'resizeShape');
|
||||
|
||||
// when
|
||||
openPopup(subProcess);
|
||||
|
||||
var adHocEntry = queryEntry(popupMenu, 'toggle-adhoc');
|
||||
|
||||
popupMenu.trigger(globalEvent(adHocEntry, { x: 0, y: 0 }));
|
||||
|
||||
// then
|
||||
expect(resizeShapeSpy).not.to.have.been.called;
|
||||
}));
|
||||
|
||||
|
||||
it('should not lay out connection', inject(function(elementRegistry, modeling, popupMenu) {
|
||||
|
||||
// given
|
||||
var subProcess = elementRegistry.get('SubProcess_1');
|
||||
|
||||
var layoutConnectionSpy = spy(modeling, 'layoutConnection');
|
||||
|
||||
// when
|
||||
openPopup(subProcess);
|
||||
|
||||
var adHocEntry = queryEntry(popupMenu, 'toggle-adhoc');
|
||||
|
||||
popupMenu.trigger(globalEvent(adHocEntry, { x: 0, y: 0 }));
|
||||
|
||||
// then
|
||||
expect(layoutConnectionSpy).not.to.have.been.called;
|
||||
}));
|
||||
|
||||
});
|
||||
|
||||
describe('adhoc -> sub process', function() {
|
||||
|
||||
it('should not resize', inject(function(elementRegistry, modeling, popupMenu) {
|
||||
|
||||
// given
|
||||
var adhocSubProcess = elementRegistry.get('AdhocSubProcess_1');
|
||||
|
||||
var resizeShapeSpy = spy(modeling, 'resizeShape');
|
||||
|
||||
// when
|
||||
openPopup(adhocSubProcess);
|
||||
|
||||
var adHocEntry = queryEntry(popupMenu, 'toggle-adhoc');
|
||||
|
||||
popupMenu.trigger(globalEvent(adHocEntry, { x: 0, y: 0 }));
|
||||
|
||||
// then
|
||||
expect(resizeShapeSpy).not.to.have.been.called;
|
||||
}));
|
||||
|
||||
|
||||
it('should not lay out connection', inject(function(elementRegistry, modeling, popupMenu) {
|
||||
|
||||
// given
|
||||
var adhocSubProcess = elementRegistry.get('AdhocSubProcess_1');
|
||||
|
||||
var layoutConnectionSpy = spy(modeling, 'layoutConnection');
|
||||
|
||||
// when
|
||||
openPopup(adhocSubProcess);
|
||||
|
||||
var adHocEntry = queryEntry(popupMenu, 'toggle-adhoc');
|
||||
|
||||
popupMenu.trigger(globalEvent(adHocEntry, { x: 0, y: 0 }));
|
||||
|
||||
// then
|
||||
expect(layoutConnectionSpy).not.to.have.been.called;
|
||||
}));
|
||||
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue