aboutsummaryrefslogtreecommitdiffstats
path: root/vid-webpack-master/src/app/shared
diff options
context:
space:
mode:
authorEylon Malin <eylon.malin@intl.att.com>2019-11-26 10:18:03 +0200
committerEylon Malin <eylon.malin@intl.att.com>2019-11-26 10:18:03 +0200
commit358dda975be66999db4abbe185e348763cdb24f9 (patch)
treec852dea8b7829d11ffba9b6761c6dc1575c38e2d /vid-webpack-master/src/app/shared
parent3347f70dcd726595e8eef7f65fb80abf13f62845 (diff)
Extract concatSupplementaryFile out of VFM controller
Issue-ID: VID-603 Signed-off-by: Eylon Malin <eylon.malin@intl.att.com> Change-Id: I7522442e5ae3109ac1abeca1f82b2a980a10e30d
Diffstat (limited to 'vid-webpack-master/src/app/shared')
-rw-r--r--vid-webpack-master/src/app/shared/components/genericForm/formControlsServices/basic.control.generator.spec.ts21
-rw-r--r--vid-webpack-master/src/app/shared/components/genericForm/formControlsServices/basic.control.generator.ts5
-rw-r--r--vid-webpack-master/src/app/shared/components/genericForm/formControlsServices/vfModuleGenerator/vfModule.control.generator.ts9
3 files changed, 28 insertions, 7 deletions
diff --git a/vid-webpack-master/src/app/shared/components/genericForm/formControlsServices/basic.control.generator.spec.ts b/vid-webpack-master/src/app/shared/components/genericForm/formControlsServices/basic.control.generator.spec.ts
index 8705fa8ff..e97ed9ca3 100644
--- a/vid-webpack-master/src/app/shared/components/genericForm/formControlsServices/basic.control.generator.spec.ts
+++ b/vid-webpack-master/src/app/shared/components/genericForm/formControlsServices/basic.control.generator.spec.ts
@@ -53,5 +53,26 @@ describe('Basic Control Generator', () => {
expect(suppFileForInstance.hiddenFile.length).toBeGreaterThanOrEqual(1);
expect(suppFileForInstance.hiddenFile[0].validations[0].validatorName).toEqual("isFileTooBig");
});
+
+ test('concatSupplementaryFile add SupplementaryFile control and hidden file', () => {
+
+ //given
+ const instance = {};
+ const controls = [service.getLegacyRegion(instance)];
+ expect(controls).toHaveLength(1);
+
+ //when
+ const result = service.concatSupplementaryFile(controls, instance);
+
+ //then
+ expect(controls).toHaveLength(1); //original controls remain the same
+
+ expect(result.map((control) => {return control.controlName})).toEqual([
+ "legacyRegion",
+ "supplementaryFile",
+ "supplementaryFile_hidden",
+ "supplementaryFile_hidden_content"
+ ]);
+ });
});
diff --git a/vid-webpack-master/src/app/shared/components/genericForm/formControlsServices/basic.control.generator.ts b/vid-webpack-master/src/app/shared/components/genericForm/formControlsServices/basic.control.generator.ts
index 0261a72a4..f7075e7d8 100644
--- a/vid-webpack-master/src/app/shared/components/genericForm/formControlsServices/basic.control.generator.ts
+++ b/vid-webpack-master/src/app/shared/components/genericForm/formControlsServices/basic.control.generator.ts
@@ -239,6 +239,11 @@ export class BasicControlGenerator {
return initialInstanceName;
}
+ concatSupplementaryFile(originalArray: FormControlModel[], vfModuleInstance): FormControlModel[] {
+ let suppFileInput: FileFormControl = <FileFormControl>(this.getSupplementaryFile(vfModuleInstance));
+ return originalArray.concat([suppFileInput], suppFileInput.hiddenFile);
+ }
+
getSupplementaryFile(instance: any): FileFormControl {
return new FileFormControl({
controlName: SUPPLEMENTARY_FILE,
diff --git a/vid-webpack-master/src/app/shared/components/genericForm/formControlsServices/vfModuleGenerator/vfModule.control.generator.ts b/vid-webpack-master/src/app/shared/components/genericForm/formControlsServices/vfModuleGenerator/vfModule.control.generator.ts
index a2dd52197..762cb41dd 100644
--- a/vid-webpack-master/src/app/shared/components/genericForm/formControlsServices/vfModuleGenerator/vfModule.control.generator.ts
+++ b/vid-webpack-master/src/app/shared/components/genericForm/formControlsServices/vfModuleGenerator/vfModule.control.generator.ts
@@ -105,9 +105,7 @@ export class VfModuleControlGenerator {
result = this.pushInstanceAndVGToForm(result, vfModuleInstance, serviceId, vnfModel, false);
}
if(this.store.getState().global.flags['FLAG_SUPPLEMENTARY_FILE']) {
- let suppFileInput:FileFormControl = <FileFormControl>(this._basicControlGenerator.getSupplementaryFile(vfModuleInstance));
- result.push(suppFileInput);
- result = result.concat(suppFileInput.hiddenFile);
+ result = this._basicControlGenerator.concatSupplementaryFile(result, vfModuleInstance);
}
return result;
}
@@ -142,12 +140,9 @@ export class VfModuleControlGenerator {
result.push(this.getRollbackOnFailureControl(vfModuleInstance, result));
result.push(this.getSDNCControl(vfModuleInstance, result));
if(this.store.getState().global.flags['FLAG_SUPPLEMENTARY_FILE']) {
- let suppFileInput:FileFormControl = <FileFormControl>(this._basicControlGenerator.getSupplementaryFile(vfModuleInstance));
- result.push(suppFileInput);
- result = result.concat(suppFileInput.hiddenFile);
+ result = this._basicControlGenerator.concatSupplementaryFile(result, vfModuleInstance);
}
return result;
-
}
getInstanceName(instance: any, serviceId: string, isEcompGeneratedNaming: boolean): FormControlModel {