From 420efffa52c1da25f7e332421913d8cadc7d3f80 Mon Sep 17 00:00:00 2001 From: Alexey Sandler Date: Tue, 26 Nov 2019 12:18:32 +0200 Subject: move SDN-C pre-load controller to basic control generator Issue-ID: VID-603 Change-Id: I2b70ab8e2437a8be3a8b3e37e9baa1bdd70cd0e5 Signed-off-by: Alexey Sandler --- .../formControlsServices/basic.control.generator.spec.ts | 7 +++++++ .../formControlsServices/basic.control.generator.ts | 12 ++++++++++++ .../vfModuleGenerator/vfModule.control.generator.spec.ts | 8 ++++---- .../vfModuleGenerator/vfModule.control.generator.ts | 14 +------------- 4 files changed, 24 insertions(+), 17 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 e97ed9ca3..64d553bfc 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 @@ -46,6 +46,13 @@ describe('Basic Control Generator', () => { expect(legacyRegionControl.isVisible).toBeFalsy(); }); + test('sdn-preload checkbox is visible', () => { + const instance = {}; + const sdncPreload: FileFormControl = service.getSDNCControl(instance); + expect (sdncPreload.displayName).toEqual('SDN-C pre-load'); + expect (sdncPreload.value).toBeFalsy(); + }); + test('given instance, get supp file from getSupplementaryFile ', () => { const instance = {}; const suppFileForInstance: FileFormControl = service.getSupplementaryFile(instance); 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 f7075e7d8..3e94b4b2c 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 @@ -22,8 +22,10 @@ import {Observable, of} from "rxjs"; import {NodeModel} from "../../../models/nodeModel"; import {Constants} from "../../../utils/constants"; import {FileUnit} from "../../formControls/component/file/fileUnit.enum"; +import {CheckboxFormControl} from "../../../models/formControlModels/checkboxFormControl.model"; const SUPPLEMENTARY_FILE = 'supplementaryFile'; +export const SDN_C_PRE_LOAD = 'sdncPreLoad'; @Injectable() export class BasicControlGenerator { @@ -244,6 +246,16 @@ export class BasicControlGenerator { return originalArray.concat([suppFileInput], suppFileInput.hiddenFile); } + getSDNCControl = (instance: any): FormControlModel => { + return new CheckboxFormControl({ + controlName: SDN_C_PRE_LOAD, + displayName: 'SDN-C pre-load', + dataTestId: 'sdncPreLoad', + value: instance ? instance.sdncPreLoad : false, + validations: [new ValidatorModel(ValidatorOptions.required, 'is required')] + }) + }; + 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.spec.ts b/vid-webpack-master/src/app/shared/components/genericForm/formControlsServices/vfModuleGenerator/vfModule.control.generator.spec.ts index 62c5ce3f4..28c92f565 100644 --- a/vid-webpack-master/src/app/shared/components/genericForm/formControlsServices/vfModuleGenerator/vfModule.control.generator.spec.ts +++ b/vid-webpack-master/src/app/shared/components/genericForm/formControlsServices/vfModuleGenerator/vfModule.control.generator.spec.ts @@ -1,7 +1,7 @@ import {getTestBed, TestBed} from '@angular/core/testing'; import {HttpClientTestingModule, HttpTestingController} from '@angular/common/http/testing'; import {NgRedux} from '@angular-redux/store'; -import {BasicControlGenerator} from "../basic.control.generator"; +import {BasicControlGenerator, SDN_C_PRE_LOAD} from "../basic.control.generator"; import {AaiService} from "../../../../services/aaiService/aai.service"; import {GenericFormService} from "../../generic-form.service"; import {FormBuilder} from "@angular/forms"; @@ -1062,7 +1062,7 @@ describe('VFModule Control Generator', () => { FormControlNames.LEGACY_REGION, FormControlNames.TENANT_ID, FormControlNames.ROLLBACK_ON_FAILURE, - FormControlNames.SDN_C_PRE_LOAD + SDN_C_PRE_LOAD, ]; expect(controls.length).toEqual(7); @@ -1097,7 +1097,7 @@ describe('VFModule Control Generator', () => { FormControlNames.TENANT_ID, // TENANT_ID must be after LEGACY_REGION FormControlNames.LEGACY_REGION, FormControlNames.ROLLBACK_ON_FAILURE, - FormControlNames.SDN_C_PRE_LOAD + SDN_C_PRE_LOAD, ]; for(let i = 0 ; i < orderedControls.length ; i++) { @@ -1154,7 +1154,7 @@ describe('VFModule Control Generator', () => { FormControlNames.LEGACY_REGION, FormControlNames.TENANT_ID, FormControlNames.ROLLBACK_ON_FAILURE, - FormControlNames.SDN_C_PRE_LOAD + SDN_C_PRE_LOAD, ]; for(let i = 0 ; i < orderedControls.length ; i++) { 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 762cb41dd..8919c0419 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 @@ -37,7 +37,6 @@ export enum FormControlNames { LEGACY_REGION = 'legacyRegion', TENANT_ID = 'tenantId', ROLLBACK_ON_FAILURE = 'rollbackOnFailure', - SDN_C_PRE_LOAD = 'sdncPreLoad', } @@ -138,7 +137,7 @@ export class VfModuleControlGenerator { result.push(this._basicControlGenerator.getLegacyRegion(vfModuleInstance)); result.push(this.getTenantControl(serviceId, vfModuleInstance, result)); result.push(this.getRollbackOnFailureControl(vfModuleInstance, result)); - result.push(this.getSDNCControl(vfModuleInstance, result)); + result.push(this._basicControlGenerator.getSDNCControl(vfModuleInstance)); if(this.store.getState().global.flags['FLAG_SUPPLEMENTARY_FILE']) { result = this._basicControlGenerator.concatSupplementaryFile(result, vfModuleInstance); } @@ -271,17 +270,6 @@ export class VfModuleControlGenerator { }) }; - getSDNCControl = (instance: any, controls: FormControlModel[]): CheckboxFormControl => { - return new CheckboxFormControl({ - type: FormControlType.CHECKBOX, - controlName: 'sdncPreLoad', - displayName: 'SDN-C pre-load', - dataTestId: 'sdncPreLoad', - value: instance ? instance.sdncPreLoad : false, - validations: [new ValidatorModel(ValidatorOptions.required, 'is required')] - }) - }; - getRollbackOnFailureControl = (instance: any, controls: FormControlModel[]): DropdownFormControl => { return new DropdownFormControl({ type: FormControlType.DROPDOWN, -- cgit 1.2.3-korg