From f81f9e534b8aac98d6550731daa00e7aa90942e2 Mon Sep 17 00:00:00 2001 From: Beatriz Mendes Date: Thu, 9 Jun 2022 11:02:16 +0200 Subject: [PATCH] fix(replace): change from standard to multi loop characteristics Closes #1673 --- .../popup-menu/ReplaceMenuProvider.js | 13 +++-- .../popup-menu/ReplaceMenuProviderSpec.js | 57 +++++++++++++++++++ 2 files changed, 64 insertions(+), 6 deletions(-) diff --git a/lib/features/popup-menu/ReplaceMenuProvider.js b/lib/features/popup-menu/ReplaceMenuProvider.js index aa30567d..6ba9a859 100644 --- a/lib/features/popup-menu/ReplaceMenuProvider.js +++ b/lib/features/popup-menu/ReplaceMenuProvider.js @@ -427,18 +427,19 @@ ReplaceMenuProvider.prototype._getLoopEntries = function(element) { var translate = this._translate; function toggleLoopEntry(event, entry) { - var loopCharacteristics = getBusinessObject(element).loopCharacteristics; + var newLoopCharacteristics = getBusinessObject(element).loopCharacteristics; if (entry.active) { - loopCharacteristics = undefined; + newLoopCharacteristics = undefined; } else { - if (isUndefined(entry.options.isSequential) || !loopCharacteristics) { - loopCharacteristics = self._moddle.create(entry.options.loopCharacteristics); + if (isUndefined(entry.options.isSequential) || !newLoopCharacteristics + || !is(newLoopCharacteristics, entry.options.loopCharacteristics)) { + newLoopCharacteristics = self._moddle.create(entry.options.loopCharacteristics); } - loopCharacteristics.isSequential = entry.options.isSequential; + newLoopCharacteristics.isSequential = entry.options.isSequential; } - self._modeling.updateProperties(element, { loopCharacteristics: loopCharacteristics }); + self._modeling.updateProperties(element, { loopCharacteristics: newLoopCharacteristics }); } var businessObject = getBusinessObject(element), diff --git a/test/spec/features/popup-menu/ReplaceMenuProviderSpec.js b/test/spec/features/popup-menu/ReplaceMenuProviderSpec.js index c40cd8a9..eb30cf11 100644 --- a/test/spec/features/popup-menu/ReplaceMenuProviderSpec.js +++ b/test/spec/features/popup-menu/ReplaceMenuProviderSpec.js @@ -511,6 +511,25 @@ describe('features/popup-menu - replace menu provider', function() { })); + it('should set loop characteristics type', inject(function(bpmnReplace, elementRegistry) { + + // given + var task = elementRegistry.get('LoopTask'), + businessObject = getBusinessObject(task); + + openPopup(task); + + // when + triggerAction('toggle-parallel-mi'); + + // then + var newLoopCharacteristics = businessObject.loopCharacteristics; + + expect(is(newLoopCharacteristics, 'bpmn:MultiInstanceLoopCharacteristics')).to.be.true; + expect(newLoopCharacteristics.isSequential).to.be.false; + })); + + it('should keep sequential properties', inject(function(elementRegistry) { // given @@ -617,6 +636,25 @@ describe('features/popup-menu - replace menu provider', function() { })); + it('should set loop characteristics type', inject(function(bpmnReplace, elementRegistry) { + + // given + var task = elementRegistry.get('LoopTask'), + businessObject = getBusinessObject(task); + + openPopup(task); + + // when + triggerAction('toggle-sequential-mi'); + + // then + var newLoopCharacteristics = businessObject.loopCharacteristics; + + expect(is(newLoopCharacteristics, 'bpmn:MultiInstanceLoopCharacteristics')).to.be.true; + expect(newLoopCharacteristics.isSequential).to.be.true; + })); + + it('should keep parallel properties', inject(function(elementRegistry) { // given @@ -720,6 +758,25 @@ describe('features/popup-menu - replace menu provider', function() { // then expect(domClasses(parallelEntry).has('active')).to.be.false; })); + + + it('should set loop characteristics type', inject(function(bpmnReplace, elementRegistry) { + + // given + var task = elementRegistry.get('SequentialTask'), + businessObject = getBusinessObject(task); + + openPopup(task); + + // when + triggerAction('toggle-loop'); + + // then + var newLoopCharacteristics = businessObject.loopCharacteristics; + + expect(is(newLoopCharacteristics, 'bpmn:StandardLoopCharacteristics')).to.be.true; + expect(newLoopCharacteristics.isSequential).to.be.undefined; + })); }); });