From 5d5f33c38b6266f1a55224bca76da7d05027c807 Mon Sep 17 00:00:00 2001 From: Niklas Kiefer Date: Mon, 5 Aug 2019 09:49:00 +0200 Subject: [PATCH 1/4] fix(create-participant-behavior): ensure available children * Ensure there are leftover children to calculate createConstraints Closes #1133 --- .../behavior/CreateParticipantBehavior.js | 5 +++ .../behavior/CreateParticipantBehaviorSpec.js | 33 +++++++++++++++++++ 2 files changed, 38 insertions(+) diff --git a/lib/features/modeling/behavior/CreateParticipantBehavior.js b/lib/features/modeling/behavior/CreateParticipantBehavior.js index ec2fff75..c241f206 100644 --- a/lib/features/modeling/behavior/CreateParticipantBehavior.js +++ b/lib/features/modeling/behavior/CreateParticipantBehavior.js @@ -48,6 +48,11 @@ export default function CreateParticipantBehavior(canvas, eventBus, modeling) { !isConnection(element); }); + // ensure for available children to calculate bounds + if (!children.length) { + return; + } + var childrenBBox = getBBox(children); var participantBounds = getParticipantBounds(shape, childrenBBox); diff --git a/test/spec/features/modeling/behavior/CreateParticipantBehaviorSpec.js b/test/spec/features/modeling/behavior/CreateParticipantBehaviorSpec.js index d76a09a6..2bf284a7 100644 --- a/test/spec/features/modeling/behavior/CreateParticipantBehaviorSpec.js +++ b/test/spec/features/modeling/behavior/CreateParticipantBehaviorSpec.js @@ -342,6 +342,39 @@ describe('features/modeling - create participant', function() { }); + + describe('fitting participant (only groups)', function() { + + var processDiagramXML = require('../../../../fixtures/bpmn/collaboration/process-empty.bpmn'); + + beforeEach(bootstrapModeler(processDiagramXML, { modules: testModules })); + + it('should fit participant', inject( + function(canvas, create, dragging, elementFactory, modeling) { + + // given + var process = canvas.getRootElement(), + processGfx = canvas.getGraphics(process), + participant = elementFactory.createParticipantShape(), + participantBo = participant.businessObject, + groupElement = elementFactory.createShape({ type: 'bpmn:Group' }); + + modeling.createShape(groupElement, { x: 100, y: 100 }, process); + + // when + create.start(canvasEvent({ x: 100, y: 100 }), participant); + dragging.hover({ element: process, gfx: processGfx }); + + // then + var defaultSize = elementFactory._getDefaultSize(participantBo); + + expect(participant.width).to.equal(defaultSize.width); + expect(participant.height).to.equal(defaultSize.height); + } + )); + + }); + }); From 0459283b34ce8fd69c191c09f41d84452b5f7d20 Mon Sep 17 00:00:00 2001 From: Nico Rehwaldt Date: Mon, 5 Aug 2019 13:51:45 +0200 Subject: [PATCH 2/4] chore(project): bump to diagram-js@4.0.3 --- package-lock.json | 6 +++--- package.json | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/package-lock.json b/package-lock.json index 345baaf3..0ededc83 100644 --- a/package-lock.json +++ b/package-lock.json @@ -2160,9 +2160,9 @@ "dev": true }, "diagram-js": { - "version": "4.0.2", - "resolved": "https://registry.npmjs.org/diagram-js/-/diagram-js-4.0.2.tgz", - "integrity": "sha512-lPi6ldA04oIrLDd9xYZjoPeoZHjVNP0RWlKlVXNPKvYROLaPk2ifC7tVnCyMRo7ZvLh0RE9N1bPM7VJsCRzrww==", + "version": "4.0.3", + "resolved": "https://registry.npmjs.org/diagram-js/-/diagram-js-4.0.3.tgz", + "integrity": "sha512-BzcWUEnRfO2tpdc8XHvG/wsX+GrE/7qGRDf1khn5b0UrzrqqLhj1yiguvpgb0rQSTPeBtkot6PUA4wB2QAQutA==", "requires": { "css.escape": "^1.5.1", "didi": "^4.0.0", diff --git a/package.json b/package.json index 2553656c..ae06d6c3 100644 --- a/package.json +++ b/package.json @@ -81,7 +81,7 @@ "bpmn-font": "^0.9.3", "bpmn-moddle": "^5.2.0", "css.escape": "^1.5.1", - "diagram-js": "^4.0.2", + "diagram-js": "^4.0.3", "diagram-js-direct-editing": "^1.5.0", "ids": "^1.0.0", "inherits": "^2.0.1", From 41a6e5d89d7530b0df023cfc74e3910b1d6cf483 Mon Sep 17 00:00:00 2001 From: Nico Rehwaldt Date: Mon, 5 Aug 2019 13:51:56 +0200 Subject: [PATCH 3/4] chore(CHANGELOG): update to v4.0.4 --- CHANGELOG.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6f0203bc..9b52c59c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,11 @@ All notable changes to [bpmn-js](https://github.com/bpmn-io/bpmn-js) are documen ___Note:__ Yet to be released changes appear here._ +## 4.0.4 + +* `FIX`: creating `bpmn:Participant` on single `bpmn:Group` throwing error ([#1133](https://github.com/bpmn-io/bpmn-js/issues/1133)) +* `CHORE`: bump to `diagram-js@4.0.3` + ## 4.0.3 * `FIX`: prevent dropping on labels and `bpmn:Group` elements ([#1131](https://github.com/bpmn-io/bpmn-js/pull/1131)) From 36f3393c31343f0427b77c2a419efb206bcd37db Mon Sep 17 00:00:00 2001 From: Nico Rehwaldt Date: Mon, 5 Aug 2019 14:05:24 +0200 Subject: [PATCH 4/4] 4.0.4 --- package-lock.json | 2 +- package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/package-lock.json b/package-lock.json index 0ededc83..f389524b 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "bpmn-js", - "version": "4.0.3", + "version": "4.0.4", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/package.json b/package.json index ae06d6c3..6b7ba18f 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "bpmn-js", - "version": "4.0.3", + "version": "4.0.4", "description": "A bpmn 2.0 toolkit and web modeler", "scripts": { "all": "run-s lint test distro test:distro",