From 960a085d4c4f8f4a97aedeac1bcb009271e7c2cf Mon Sep 17 00:00:00 2001 From: Nico Rehwaldt Date: Fri, 27 Mar 2020 23:55:44 +0100 Subject: [PATCH 1/7] fix(modeling): do not resize label target when setting empty label This prevents a bug that cause the label target to be accidentally resized if the user updates the label value to an empty string (or null). Closes #1294 --- .../label-editing/cmd/UpdateLabelHandler.js | 10 ++++----- .../spec/features/modeling/UpdateLabelSpec.js | 21 +++++++++++++++++++ 2 files changed, 26 insertions(+), 5 deletions(-) diff --git a/lib/features/label-editing/cmd/UpdateLabelHandler.js b/lib/features/label-editing/cmd/UpdateLabelHandler.js index 6d12a2e9..63678b93 100644 --- a/lib/features/label-editing/cmd/UpdateLabelHandler.js +++ b/lib/features/label-editing/cmd/UpdateLabelHandler.js @@ -88,6 +88,11 @@ export default function UpdateLabelHandler(modeling, textRenderer) { newBounds = ctx.newBounds, hints = ctx.hints || {}; + // ignore internal labels for elements except text annotations + if (!isLabel(label) && !is(label, 'bpmn:TextAnnotation')) { + return; + } + if (isLabel(label) && isEmptyText(newLabel)) { if (hints.removeShape !== false) { @@ -97,11 +102,6 @@ export default function UpdateLabelHandler(modeling, textRenderer) { return; } - // ignore internal labels for elements except text annotations - if (!isLabelExternal(element) && !is(element, 'bpmn:TextAnnotation')) { - return; - } - var text = getLabel(label); // resize element based on label _or_ pre-defined bounds diff --git a/test/spec/features/modeling/UpdateLabelSpec.js b/test/spec/features/modeling/UpdateLabelSpec.js index 6f8259d4..8c39be93 100644 --- a/test/spec/features/modeling/UpdateLabelSpec.js +++ b/test/spec/features/modeling/UpdateLabelSpec.js @@ -50,6 +50,27 @@ describe('features/modeling - update label', function() { )); + it('should not create label on empty text', inject( + function(modeling, elementRegistry) { + + // given + var startEvent_2 = elementRegistry.get('StartEvent_2'); + + // when + modeling.updateLabel(startEvent_2, ''); + + // then + expect(startEvent_2.businessObject.name).to.equal(''); + expect(startEvent_2.label).not.to.exist; + + expect(startEvent_2).to.have.dimensions({ + width: 36, + height: 36 + }); + } + )); + + describe('should delete label', function() { it('when setting null', inject( From 305477b9d1fe15eda79c5eff53d3b4881afde9d4 Mon Sep 17 00:00:00 2001 From: Nico Rehwaldt Date: Mon, 30 Mar 2020 11:07:50 +0200 Subject: [PATCH 2/7] chore(CHANGELOG): update to v6.3.5 --- CHANGELOG.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 34526afe..97872ec3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,10 @@ All notable changes to [bpmn-js](https://github.com/bpmn-io/bpmn-js) are documen ___Note:__ Yet to be released changes appear here._ +## 6.3.5 + +* `FIX`: correct accidental resizing of label target ([#1294](https://github.com/bpmn-io/bpmn-js/issues/1294)) + ## 6.3.4 * `FIX`: export BPMNDI in correct order ([#985](https://github.com/bpmn-io/bpmn-js/issues/985)) From 814a23a7df8a53a4b9d3b857cd140bb0516ba1bc Mon Sep 17 00:00:00 2001 From: Nico Rehwaldt Date: Mon, 30 Mar 2020 11:26:53 +0200 Subject: [PATCH 3/7] 6.3.5 --- 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 70f6963a..bed82826 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "bpmn-js", - "version": "6.3.4", + "version": "6.3.5", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/package.json b/package.json index adf23f58..534223e4 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "bpmn-js", - "version": "6.3.4", + "version": "6.3.5", "description": "A bpmn 2.0 toolkit and web modeler", "scripts": { "all": "run-s lint test distro test:distro", From bf436bef1ecb7cb33a5225749b758b6f9312b5cc Mon Sep 17 00:00:00 2001 From: Nico Rehwaldt Date: Thu, 26 Mar 2020 21:11:54 +0100 Subject: [PATCH 4/7] feat(replace): create bpmn:LinkEventDefinition with empty name Closes https://github.com/bpmn-io/bpmn-js/issues/1296 --- lib/features/modeling/ElementFactory.js | 2 +- lib/features/replace/BpmnReplace.js | 1 + lib/features/replace/ReplaceOptions.js | 10 +++++-- .../features/modeling/ElementFactorySpec.js | 28 +++++++++++++++++++ 4 files changed, 38 insertions(+), 3 deletions(-) diff --git a/lib/features/modeling/ElementFactory.js b/lib/features/modeling/ElementFactory.js index 8f310cf5..d40fcaed 100644 --- a/lib/features/modeling/ElementFactory.js +++ b/lib/features/modeling/ElementFactory.js @@ -117,7 +117,7 @@ ElementFactory.prototype.createBpmnElement = function(elementType, attrs) { if (attrs.eventDefinitionType) { eventDefinitions = businessObject.get('eventDefinitions') || []; - newEventDefinition = this._bpmnFactory.create(attrs.eventDefinitionType); + newEventDefinition = this._bpmnFactory.create(attrs.eventDefinitionType, attrs.eventDefinitionAttrs); if (attrs.eventDefinitionType === 'bpmn:ConditionalEventDefinition') { newEventDefinition.condition = this._bpmnFactory.create('bpmn:FormalExpression'); diff --git a/lib/features/replace/BpmnReplace.js b/lib/features/replace/BpmnReplace.js index da750921..5547d467 100644 --- a/lib/features/replace/BpmnReplace.js +++ b/lib/features/replace/BpmnReplace.js @@ -173,6 +173,7 @@ export default function BpmnReplace( // i.e. because we copied it if (!hasEventDefinition(newBusinessObject, target.eventDefinitionType)) { newElement.eventDefinitionType = target.eventDefinitionType; + newElement.eventDefinitionAttrs = target.eventDefinitionAttrs; } } diff --git a/lib/features/replace/ReplaceOptions.js b/lib/features/replace/ReplaceOptions.js index 04cb6ab2..07bd2772 100644 --- a/lib/features/replace/ReplaceOptions.js +++ b/lib/features/replace/ReplaceOptions.js @@ -137,7 +137,10 @@ export var INTERMEDIATE_EVENT = [ className: 'bpmn-icon-intermediate-event-catch-link', target: { type: 'bpmn:IntermediateCatchEvent', - eventDefinitionType: 'bpmn:LinkEventDefinition' + eventDefinitionType: 'bpmn:LinkEventDefinition', + eventDefinitionAttrs: { + name: '' + } } }, { @@ -146,7 +149,10 @@ export var INTERMEDIATE_EVENT = [ className: 'bpmn-icon-intermediate-event-throw-link', target: { type: 'bpmn:IntermediateThrowEvent', - eventDefinitionType: 'bpmn:LinkEventDefinition' + eventDefinitionType: 'bpmn:LinkEventDefinition', + eventDefinitionAttrs: { + name: '' + } } }, { diff --git a/test/spec/features/modeling/ElementFactorySpec.js b/test/spec/features/modeling/ElementFactorySpec.js index f69c96fe..5d2a9bbb 100644 --- a/test/spec/features/modeling/ElementFactorySpec.js +++ b/test/spec/features/modeling/ElementFactorySpec.js @@ -73,6 +73,34 @@ describe('features - element factory', function() { })); + it('should create with link event definition', inject(function(elementFactory) { + + // when + var intermediateThrowEvent = elementFactory.createShape({ + type: 'bpmn:IntermediateThrowEvent', + eventDefinitionType: 'bpmn:LinkEventDefinition', + eventDefinitionAttrs: { + name: '' + } + }); + + // then + expect(intermediateThrowEvent).to.exist; + expect(is(intermediateThrowEvent, 'bpmn:IntermediateThrowEvent')).to.be.true; + + var intermediateThrowEventBo = getBusinessObject(intermediateThrowEvent), + eventDefinitions = intermediateThrowEventBo.eventDefinitions; + + expect(eventDefinitions).to.exist; + expect(eventDefinitions).to.have.length(1); + + var eventDefinition = eventDefinitions[ 0 ]; + + expect(is(eventDefinition, 'bpmn:LinkEventDefinition')).to.be.true; + expect(eventDefinition.name).to.eql(''); + })); + + describe('integration', function() { it('should create event definition with ID', inject(function(elementFactory) { From 6bfecfa71ee81e75588eb51d4f92240bdafbc682 Mon Sep 17 00:00:00 2001 From: Maciej Barelkowski Date: Fri, 27 Mar 2020 07:57:56 +0100 Subject: [PATCH 5/7] test(popup-menu): verify if linked events have name --- .../ReplaceMenuProvider.events.bpmn | 29 ++++++++ .../popup-menu/ReplaceMenuProviderSpec.js | 68 +++++++++++++++++++ 2 files changed, 97 insertions(+) create mode 100644 test/spec/features/popup-menu/ReplaceMenuProvider.events.bpmn diff --git a/test/spec/features/popup-menu/ReplaceMenuProvider.events.bpmn b/test/spec/features/popup-menu/ReplaceMenuProvider.events.bpmn new file mode 100644 index 00000000..6e03bcb3 --- /dev/null +++ b/test/spec/features/popup-menu/ReplaceMenuProvider.events.bpmn @@ -0,0 +1,29 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/test/spec/features/popup-menu/ReplaceMenuProviderSpec.js b/test/spec/features/popup-menu/ReplaceMenuProviderSpec.js index bd63ca5d..3383248f 100644 --- a/test/spec/features/popup-menu/ReplaceMenuProviderSpec.js +++ b/test/spec/features/popup-menu/ReplaceMenuProviderSpec.js @@ -1750,6 +1750,74 @@ describe('features/popup-menu - replace menu provider', function() { }); + + describe('events', function() { + + var diagramXML = require('./ReplaceMenuProvider.events.bpmn'); + + beforeEach(bootstrapModeler(diagramXML, { + modules: testModules + })); + + + it('should set default link name for a link catch event', inject(function(elementRegistry) { + + // given + var event = elementRegistry.get('IntermediateEvent'); + + // when + openPopup(event); + + triggerAction('replace-with-link-intermediate-catch'); + + // then + event = elementRegistry.get('IntermediateEvent'); + + expect(event).to.exist; + expect(is(event, 'bpmn:IntermediateCatchEvent'), 'is not a catch event').to.be.true; + + var eventBo = event.businessObject, + eventDefinitions = eventBo.eventDefinitions; + + expect(eventDefinitions).to.exist; + expect(eventDefinitions).to.have.length(1); + + var eventDefinition = eventDefinitions[ 0 ]; + + expect(is(eventDefinition, 'bpmn:LinkEventDefinition')).to.be.true; + expect(eventDefinition.name, 'name is not set').to.eql(''); + })); + + + it('should set default link name for a link throw event', inject(function(elementRegistry) { + + // given + var event = elementRegistry.get('IntermediateEvent'); + + // when + openPopup(event); + + triggerAction('replace-with-link-intermediate-throw'); + + // then + event = elementRegistry.get('IntermediateEvent'); + + expect(event).to.exist; + expect(is(event, 'bpmn:IntermediateThrowEvent'), 'is not a throw event').to.be.true; + + var eventBo = event.businessObject, + eventDefinitions = eventBo.eventDefinitions; + + expect(eventDefinitions).to.exist; + expect(eventDefinitions).to.have.length(1); + + var eventDefinition = eventDefinitions[ 0 ]; + + expect(is(eventDefinition, 'bpmn:LinkEventDefinition')).to.be.true; + expect(eventDefinition.name, 'name is not set').to.eql(''); + })); + }); + }); From e3e59b239c40147fcae91235fd0f6b98b50b89c5 Mon Sep 17 00:00:00 2001 From: Nico Rehwaldt Date: Mon, 30 Mar 2020 11:37:51 +0200 Subject: [PATCH 6/7] chore(CHANGELOG): update to v6.4.0 --- CHANGELOG.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 97872ec3..938a1a77 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,10 @@ All notable changes to [bpmn-js](https://github.com/bpmn-io/bpmn-js) are documen ___Note:__ Yet to be released changes appear here._ +## 6.4.0 + +* `FEAT`: serialize link events with an empty name ([#1296](https://github.com/bpmn-io/bpmn-js/issues/1296)) + ## 6.3.5 * `FIX`: correct accidental resizing of label target ([#1294](https://github.com/bpmn-io/bpmn-js/issues/1294)) From 9ef9dd356fb206feaae5cde8486f1eeb22c406d1 Mon Sep 17 00:00:00 2001 From: Nico Rehwaldt Date: Mon, 30 Mar 2020 11:50:10 +0200 Subject: [PATCH 7/7] 6.4.0 --- 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 bed82826..573394c5 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "bpmn-js", - "version": "6.3.5", + "version": "6.4.0", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/package.json b/package.json index 534223e4..daf3aa62 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "bpmn-js", - "version": "6.3.5", + "version": "6.4.0", "description": "A bpmn 2.0 toolkit and web modeler", "scripts": { "all": "run-s lint test distro test:distro",