fix(auto-resize): correctly auto-resize participant

Closes #390
This commit is contained in:
Nico Rehwaldt 2015-10-20 10:49:18 +02:00 committed by pedesen
parent d789342b10
commit e1cd32fa91
3 changed files with 23 additions and 16 deletions

View File

@ -134,7 +134,11 @@ function AutoResize(eventBus, canvas, modeling){
assign(newBounds, { width: bbox.x + bbox.width + OFFSET.right - newBounds.x });
}
if (is(target, 'bpmn:Participant')) {
modeling.resizeLane(target, newBounds);
} else {
modeling.resizeShape(target, newBounds);
}
var parent = target.parent;

View File

@ -1,11 +1,11 @@
<?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:participant id="Participant_Lanes" processRef="Process_Lanes" />
</bpmn:collaboration>
<bpmn:process id="Process_1" isExecutable="false">
<bpmn:process id="Process_Lanes" isExecutable="false">
<bpmn:laneSet>
<bpmn:lane id="Lane_1brtzvq">
<bpmn:lane id="Lane">
<bpmn:childLaneSet xsi:type="bpmn:tLaneSet">
<bpmn:lane id="Lane_Nested" name="Lane_Nested">
<bpmn:flowNodeRef>StartEvent_1</bpmn:flowNodeRef>
@ -24,7 +24,7 @@
</bpmn:process>
<bpmndi:BPMNDiagram id="BPMNDiagram_1">
<bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="Collaboration_1">
<bpmndi:BPMNShape id="Participant_1_di" bpmnElement="Participant_1">
<bpmndi:BPMNShape id="Participant_Lanes_di" bpmnElement="Participant_Lanes">
<dc:Bounds x="247" y="160" width="371" height="178" />
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="StartEvent_1_di" bpmnElement="StartEvent_1">
@ -43,7 +43,7 @@
<dc:Bounds x="370" y="239" width="90" height="20" />
</bpmndi:BPMNLabel>
</bpmndi:BPMNEdge>
<bpmndi:BPMNShape id="Lane_1brtzvq_di" bpmnElement="Lane_1brtzvq">
<bpmndi:BPMNShape id="Lane_di" bpmnElement="Lane">
<dc:Bounds x="277" y="160" width="341" height="178" />
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="Lane_Nested_di" bpmnElement="Lane_Nested">

View File

@ -206,6 +206,7 @@ describe('features/auto-resize', function() {
});
describe('after appending', function(){
it('should expand the bottom right edges', inject(function(modeling) {
@ -274,6 +275,7 @@ describe('features/auto-resize', function() {
});
describe('lane', function() {
var diagramXML = require('./AutoResize.lanes.bpmn');
@ -281,39 +283,40 @@ describe('features/auto-resize', function() {
beforeEach(bootstrapModeler(diagramXML, { modules: testModules }));
it('should auto-resize to fit new element', inject(function(elementRegistry, modeling) {
it('should fit new element', inject(function(elementRegistry, modeling) {
// given
var laneShape = elementRegistry.get('Lane_Nested');
var participantShape = elementRegistry.get('Participant_Lanes');
// when
modeling.createShape({ type: 'bpmn:Task' }, { x: 600, y: 320 }, laneShape);
modeling.createShape({ type: 'bpmn:Task' }, { x: 600, y: 320 }, participantShape);
// then
expect(laneShape).to.have.bounds({ x: 307, y: 160, width: 443, height: 260});
expect(participantShape).to.have.bounds({ x: 247, y: 160, width: 503, height: 260});
}));
it('should auto-resize to fit multiple moved elements', inject(function(elementRegistry, modeling) {
it('should fit multiple moved elements', inject(function(elementRegistry, modeling) {
// given
var laneShape = elementRegistry.get('Lane_Nested'),
var participantShape = elementRegistry.get('Participant_Lanes'),
taskShape = elementRegistry.get('Task_1'),
startEventShape = elementRegistry.get('StartEvent_1');
var originalBounds = getBounds(laneShape);
var originalBounds = getBounds(participantShape);
// when
modeling.moveElements([ taskShape, startEventShape ], { x: 200, y: 0 }, laneShape);
modeling.moveElements([ taskShape, startEventShape ], { x: 200, y: 0 }, participantShape);
// then
var expectedBounds = assign(originalBounds, { width: 565 });
var expectedBounds = assign(originalBounds, { width: 625 });
expect(laneShape).to.have.bounds(expectedBounds);
expect(participantShape).to.have.bounds(expectedBounds);
}));
});
describe('sub processes', function() {
var diagramXML = require('./AutoResize.sub-processes.bpmn');