summaryrefslogtreecommitdiffstats
path: root/vid-webpack-master
diff options
context:
space:
mode:
authorIttay Stern <ittay.stern@att.com>2019-11-26 08:50:23 +0000
committerGerrit Code Review <gerrit@onap.org>2019-11-26 08:50:23 +0000
commita6b33add4f81a2c70aaf6172dd7184eeb8fb323d (patch)
tree864aba1458ff86f208e5566df7ad62f76e2ddac1 /vid-webpack-master
parentc01c192ef8d52a6c228f7cb261620890f5c3319d (diff)
parent358dda975be66999db4abbe185e348763cdb24f9 (diff)
Merge "Extract concatSupplementaryFile out of VFM controller"
Diffstat (limited to 'vid-webpack-master')
-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 {