fix(auto-resize): do not resize on lane create / resize lanes, too

Related to #263
This commit is contained in:
Nico Rehwaldt 2015-08-31 15:35:32 +02:00
parent afa72ad5bd
commit ede384b5ac
4 changed files with 298 additions and 187 deletions

View File

@ -65,7 +65,18 @@ function AutoResize(eventBus, canvas, modeling){
* @param {Shape} target * @param {Shape} target
*/ */
function expand(shape, target) { function expand(shape, target) {
if (is(target, 'bpmn:Participant') && target === shape.parent) {
if (is(shape, 'bpmn:Lane')) {
return;
}
if (!is(target, 'bpmn:Participant') && !is(target, 'bpmn:Lane')) {
return;
}
if (target !== shape.parent) {
return;
}
var inbounds = isInbounds(shape, target, PADDING); var inbounds = isInbounds(shape, target, PADDING);
@ -92,7 +103,6 @@ function AutoResize(eventBus, canvas, modeling){
modeling.resizeShape(target, newBounds); modeling.resizeShape(target, newBounds);
} }
} }
}
AutoResize.$inject = [ 'eventBus', 'canvas', 'modeling' ]; AutoResize.$inject = [ 'eventBus', 'canvas', 'modeling' ];

View File

@ -0,0 +1,54 @@
<?xml version="1.0" encoding="UTF-8"?>
<bpmn:definitions xmlns:bpmn="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 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">
<bpmn:collaboration id="Collaboration_1">
<bpmn:participant id="Participant_1" processRef="Process_1" />
</bpmn:collaboration>
<bpmn:process id="Process_1" isExecutable="false">
<bpmn:laneSet>
<bpmn:lane id="Lane_1brtzvq">
<bpmn:childLaneSet xsi:type="bpmn:tLaneSet">
<bpmn:lane id="Lane_Nested" name="Lane_Nested">
<bpmn:flowNodeRef>StartEvent_1</bpmn:flowNodeRef>
<bpmn:flowNodeRef>Task_1</bpmn:flowNodeRef>
</bpmn:lane>
</bpmn:childLaneSet>
</bpmn:lane>
</bpmn:laneSet>
<bpmn:task id="Task_1">
<bpmn:incoming>SequenceFlow_1</bpmn:incoming>
</bpmn:task>
<bpmn:sequenceFlow id="SequenceFlow_1" sourceRef="StartEvent_1" targetRef="Task_1" />
<bpmn:startEvent id="StartEvent_1">
<bpmn:outgoing>SequenceFlow_1</bpmn:outgoing>
</bpmn:startEvent>
</bpmn:process>
<bpmndi:BPMNDiagram id="BPMNDiagram_1">
<bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="Collaboration_1">
<bpmndi:BPMNShape id="Participant_1_di" bpmnElement="Participant_1">
<dc:Bounds x="247" y="160" width="371" height="178" />
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="StartEvent_1_di" bpmnElement="StartEvent_1">
<dc:Bounds x="345" y="231" width="36" height="36" />
<bpmndi:BPMNLabel>
<dc:Bounds x="318" y="267" width="90" height="20" />
</bpmndi:BPMNLabel>
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="Task_1_di" bpmnElement="Task_1">
<dc:Bounds x="472" y="209" width="100" height="80" />
</bpmndi:BPMNShape>
<bpmndi:BPMNEdge id="SequenceFlow_1_di" bpmnElement="SequenceFlow_1">
<di:waypoint xsi:type="dc:Point" x="381" y="249" />
<di:waypoint xsi:type="dc:Point" x="472" y="249" />
<bpmndi:BPMNLabel>
<dc:Bounds x="370" y="239" width="90" height="20" />
</bpmndi:BPMNLabel>
</bpmndi:BPMNEdge>
<bpmndi:BPMNShape id="Lane_1brtzvq_di" bpmnElement="Lane_1brtzvq">
<dc:Bounds x="277" y="160" width="341" height="178" />
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="Lane_Nested_di" bpmnElement="Lane_Nested">
<dc:Bounds x="307" y="160" width="311" height="178" />
</bpmndi:BPMNShape>
</bpmndi:BPMNPlane>
</bpmndi:BPMNDiagram>
</bpmn:definitions>

View File

@ -16,11 +16,15 @@ function getBounds(shape) {
return pick(shape, ['x', 'y', 'width', 'height']); return pick(shape, ['x', 'y', 'width', 'height']);
} }
describe('features/auto-resize', function() { describe('features/auto-resize', function() {
var testModules = [coreModule, modelingModule, autoResizeModule, createModule ]; var testModules = [coreModule, modelingModule, autoResizeModule, createModule ];
var diagramXML = require('./AutoResize.collaboration.bpmn');
describe('participant', function() {
var diagramXML = require('./AutoResize.participant.bpmn');
var task, var task,
participant, participant,
@ -41,6 +45,7 @@ describe('features/auto-resize', function() {
})); }));
describe('after moving', function() { describe('after moving', function() {
it('should expand the right edge of the parent collaboration', it('should expand the right edge of the parent collaboration',
@ -163,6 +168,7 @@ describe('features/auto-resize', function() {
}); });
describe('after appending', function(){ describe('after appending', function(){
@ -216,4 +222,45 @@ describe('features/auto-resize', function() {
}); });
it('should not auto-resize when adding lane', inject(function(modeling) {
// given
var laneAttrs = {
type: 'bpmn:Lane',
width: 341,
height: 178
};
// when
modeling.createShape(laneAttrs, { x: 280, y: 200 }, participant);
// then
expect(getBounds(participant)).to.eql(expectedBounds);
}));
});
describe('lane', function() {
var diagramXML = require('./AutoResize.lanes.bpmn');
beforeEach(bootstrapModeler(diagramXML, { modules: testModules }));
it('should auto-resize to fit new element', inject(function(elementRegistry, modeling) {
// given
var laneShape = elementRegistry.get('Lane_Nested');
// when
modeling.createShape({ type: 'bpmn:Task' }, { x: 600, y: 320 }, laneShape);
// then
expect(getBounds(laneShape)).to.eql({ x: 307, y: 160, width: 443, height: 280});
}));
});
}); });