From 7743372d29462f28428f21455e6a73fe19771389 Mon Sep 17 00:00:00 2001 From: Elizabeth Esswein Date: Fri, 1 Sep 2023 17:04:18 -0400 Subject: [PATCH] update iospec to include refs in input/output sets --- app/spiffworkflow/InputOutput/IoInterceptor.js | 10 +++++++--- test/spec/IOInterceptorSpec.js | 15 ++++++++++++++- 2 files changed, 21 insertions(+), 4 deletions(-) diff --git a/app/spiffworkflow/InputOutput/IoInterceptor.js b/app/spiffworkflow/InputOutput/IoInterceptor.js index 6ec92c2..7238e2b 100644 --- a/app/spiffworkflow/InputOutput/IoInterceptor.js +++ b/app/spiffworkflow/InputOutput/IoInterceptor.js @@ -30,7 +30,7 @@ export default class IoInterceptor extends CommandInterceptor { let process = context.parent.businessObject; let ioSpec = assureIOSpecificationExists(process, bpmnFactory); let di = context.shape.di; - let generator = new IdGenerator(type_name), ioSpecification = process.get('ioSpecification'); + let generator = new IdGenerator(type_name); let dataIO = bpmnFactory.create(type, { id: generator.next() }); context.shape.businessObject = dataIO; dataIO.$parent = ioSpec; @@ -40,9 +40,11 @@ export default class IoInterceptor extends CommandInterceptor { bpmnUpdater.updateBounds(context.shape); if (type == 'bpmn:DataInput') { - collectionAdd(ioSpecification.get('dataInputs'), dataIO); + collectionAdd(ioSpec.inputSets[0].get('dataInputRefs'), dataIO); + collectionAdd(ioSpec.get('dataInputs'), dataIO); } else { - collectionAdd(ioSpecification.get('dataOutputs'), dataIO); + collectionAdd(ioSpec.outputSets[0].get('dataOutputRefs'), dataIO); + collectionAdd(ioSpec.get('dataOutputs'), dataIO); } } }); @@ -54,8 +56,10 @@ export default class IoInterceptor extends CommandInterceptor { let process = context.shape.parent.businessObject; let ioSpec = assureIOSpecificationExists(process, bpmnFactory); if (type == 'bpmn:DataInput') { + collectionRemove(ioSpec.inputSets[0].get('dataInputRefs'), context.shape.businessObject); collectionRemove(ioSpec.get('dataInputs'), context.shape.businessObject); } else { + collectionRemove(ioSpec.outputSets[0].get('dataOutputRefs'), context.shape.businessObject); collectionRemove(ioSpec.get('dataOutputs'), context.shape.businessObject); } if (context.shape.di.$parent) { diff --git a/test/spec/IOInterceptorSpec.js b/test/spec/IOInterceptorSpec.js index 3701d7f..8648410 100644 --- a/test/spec/IOInterceptorSpec.js +++ b/test/spec/IOInterceptorSpec.js @@ -33,7 +33,8 @@ describe('Input/Output Interceptor', function() { // THEN - the process should now have an IO Specification const iospec = canvas.getRootElement().businessObject.ioSpecification; expect(iospec).to.not.be.null; - expect(iospec.dataInputs.length).to.equal(1) + expect(iospec.dataInputs.length).to.equal(1); + expect(iospec.inputSets[0].dataInputRefs.length).to.equal(1); })); @@ -60,4 +61,16 @@ describe('Input/Output Interceptor', function() { modeling.removeShape(dataInput) expect(canvas.getRootElement().businessObject.ioSpecification).to.be.null; })); + + it('deleting a data input should remove it from the input set', inject(function(canvas, modeling) { + let rootShape = canvas.getRootElement(); + const dataInput = modeling.createShape({type: 'bpmn:DataInput'}, + {x: 220, y: 220}, rootShape); + const dataOutput = modeling.createShape({type: 'bpmn:DataOutput'}, + {x: 240, y: 220}, rootShape); + modeling.removeShape(dataInput); + const iospec = canvas.getRootElement().businessObject.ioSpecification; + expect(iospec.dataInputs.length).to.equal(0); + expect(iospec.inputSets[0].dataInputRefs.length).to.equal(0); + })); });