Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(modeling): calculate appropriate new bounds on subprocess collapse #1052

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 12 additions & 4 deletions lib/features/modeling/behavior/SubProcessBehavior.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,10 @@ import CommandInterceptor from 'diagram-js/lib/command/CommandInterceptor';

import { is } from '../../../util/ModelUtil';

import { expandedBounds } from './ToggleElementCollapseBehaviour';
import {
expandedBounds,
collapsedBounds
} from './ToggleElementCollapseBehaviour';


export default function SubProcessBehavior(elementFactory, eventBus, modeling) {
Expand Down Expand Up @@ -41,13 +44,18 @@ export default function SubProcessBehavior(elementFactory, eventBus, modeling) {
newBounds;

if (!is(shape, 'bpmn:SubProcess') ||
shape.collapsed ||
!hasIncomingSequenceFlows(shape) ||
hasOutgoingSequenceFlows(shape)) {
return;
}

newBounds = expandedBounds(shape, defaultSize);
if (shape.collapsed) {
newBounds = collapsedBounds(shape, defaultSize);
}

if (!shape.collapsed) {
newBounds = expandedBounds(shape, defaultSize);
}

modeling.moveShape(shape, {
x: shape.x - newBounds.x,
Expand Down Expand Up @@ -88,4 +96,4 @@ function hasOutgoingSequenceFlows(shape) {

function isSequenceFlow(connection) {
return is(connection, 'bpmn:SequenceFlow');
}
}
14 changes: 10 additions & 4 deletions test/spec/features/modeling/behavior/SubProcessBehaviorSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -188,17 +188,23 @@ describe('features/modeling/behavior - sub process', function() {

describe('expanded sub process -> collapsed sub process', function() {

it('should NOT move', inject(function(elementRegistry, modeling) {
it('should move', inject(function(elementRegistry, modeling) {

// given
var subProcess = elementRegistry.get('SubProcess_4'),
subProcessMid = getMid(subProcess);
var subProcess = elementRegistry.get('SubProcess_4');

// when
modeling.toggleCollapse(subProcess);

// then
expect(getMid(subProcess)).to.eql(subProcessMid);
var expectedBounds = {
x: 525,
y: 360,
width: 100,
height: 80
};

expect(subProcess).to.have.bounds(expectedBounds);
}));

});
Expand Down