diff options
author | Yoav Schneiderman <yoav.schneiderman@intl.att.com> | 2019-12-12 16:11:59 +0200 |
---|---|---|
committer | Einat Vinouze <einat.vinouze@intl.att.com> | 2019-12-16 13:51:28 +0200 |
commit | f959829f573644c2b4d5ada940348ec4893d8a8c (patch) | |
tree | 3fb5ce8490e7998a073468489fd92d4e2c74bfdc /vid-webpack-master/src/app/shared/components/genericForm | |
parent | 17f0c14e91f9a76e18c86e529a477d4b2927ce8d (diff) |
When opening new VNF modal the modal should be empty.
Issue-ID: VID-727
Change-Id: I29a83ae7460c30661ad5d99860bcddda5a2936be
Signed-off-by: Yoav Schneiderman <yoav.schneiderman@intl.att.com>
Signed-off-by: Einat Vinouze <einat.vinouze@intl.att.com>
Diffstat (limited to 'vid-webpack-master/src/app/shared/components/genericForm')
6 files changed, 38 insertions, 13 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 077d849e6..7e2d3f942 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 @@ -1,9 +1,10 @@ import {getTestBed, TestBed} from '@angular/core/testing'; import {AaiService} from "../../../services/aaiService/aai.service"; -import {FormControlModel, ValidatorModel, ValidatorOptions} from "../../../models/formControlModels/formControl.model"; +import {FormControlModel} from "../../../models/formControlModels/formControl.model"; import {FeatureFlagsService} from "../../../services/featureFlag/feature-flags.service"; import {BasicControlGenerator} from "./basic.control.generator"; import {NgRedux} from '@angular-redux/store'; +import each from "jest-each"; import {HttpClientTestingModule, HttpTestingController} from '@angular/common/http/testing'; import {FileFormControl} from "../../../models/formControlModels/fileFormControl.model"; @@ -81,5 +82,27 @@ describe('Basic Control Generator', () => { "supplementaryFile_hidden_content" ]); }); -}); + each([ + [null, false], + [{}, true] + ]). + test('retrieveInstanceIfUpdateMode returns %s if update mode is %s', (expected, isUpdateModalMode) => { + //given + const store= <any>{ + getState() { + return { + global: { + isUpdateModalMode + } + }}}; + const instance = {}; + + //when + let retrievedInstance = service.retrieveInstanceIfUpdateMode (store, instance); + //then + expect(retrievedInstance).toEqual(expected); + + }); + +}); 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 7ab64753a..aff33982f 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 @@ -280,6 +280,10 @@ export class BasicControlGenerator { }) }; + retrieveInstanceIfUpdateMode(store: NgRedux<AppState>, instance: any): any{ + return store.getState().global.isUpdateModalMode ? instance : null; + } + private getOnDeleteForSupplementaryFile() { return (form: FormGroup) => { form.controls[SUPPLEMENTARY_FILE + "_hidden"].setValue(null); diff --git a/vid-webpack-master/src/app/shared/components/genericForm/formControlsServices/networkGenerator/network.control.generator.ts b/vid-webpack-master/src/app/shared/components/genericForm/formControlsServices/networkGenerator/network.control.generator.ts index 11c4561c2..19c85a1ff 100644 --- a/vid-webpack-master/src/app/shared/components/genericForm/formControlsServices/networkGenerator/network.control.generator.ts +++ b/vid-webpack-master/src/app/shared/components/genericForm/formControlsServices/networkGenerator/network.control.generator.ts @@ -73,8 +73,7 @@ export class NetworkControlGenerator { this._logService.error('should provide serviceId, networkName, networkStoreKey', serviceId); return []; } - - const networkInstance = this.getNetworkInstance(serviceId, networkStoreKey, isUpdateMode); + const networkInstance = this._basicControlGenerator.retrieveInstanceIfUpdateMode(this.store, this.getNetworkInstance(serviceId, networkStoreKey, isUpdateMode)); const networkModel = new NetworkModel(this.store.getState().service.serviceHierarchy[serviceId].networks[networkName]); let result: FormControlModel[] = []; @@ -99,7 +98,7 @@ export class NetworkControlGenerator { } let result: FormControlModel[] = []; - const networkInstance = this.getNetworkInstance(serviceId, networkStoreKey, isUpdateMode); + const networkInstance = this._basicControlGenerator.retrieveInstanceIfUpdateMode(this.store, this.getNetworkInstance(serviceId, networkStoreKey, isUpdateMode)); const networkModel = new NetworkModel(this.store.getState().service.serviceHierarchy[serviceId].networks[networkName]); if (!_.isNil(networkModel)) { 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 8919c0419..011f43447 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 @@ -92,7 +92,7 @@ export class VfModuleControlGenerator { } } - const vfModuleInstance = this.getVfModuleInstance(serviceId, vnfStoreKey, uuidData, isUpdateMode); + const vfModuleInstance = this._basicControlGenerator.retrieveInstanceIfUpdateMode(this.store, this.getVfModuleInstance(serviceId, vnfStoreKey, uuidData, isUpdateMode)); const vfModuleModel = this.vfModuleModel; const vnf: VnfInstance = this.store.getState().service.serviceInstance[serviceId].vnfs[vnfStoreKey]; const vnfModelName: string = vnf.originalName; @@ -126,11 +126,11 @@ export class VfModuleControlGenerator { return []; } } - const vnf: VnfInstance = this.store.getState().service.serviceInstance[serviceId].vnfs[vnfStoreKey]; + const vnf: VnfInstance = this.store.getState().service.serviceInstance[serviceId].vnfs[vnfStoreKey] ; const vnfModelName: string = vnf.originalName; const vnfModel = new VNFModel(this.store.getState().service.serviceHierarchy[serviceId].vnfs[vnfModelName]); - const vfModuleInstance = this.getVfModuleInstance(serviceId, vnfStoreKey, uuidData, isUpdateMode); + const vfModuleInstance = this._basicControlGenerator.retrieveInstanceIfUpdateMode(this.store, this.getVfModuleInstance(serviceId, vnfStoreKey, uuidData, isUpdateMode)); let result: FormControlModel[] = []; this.pushInstanceAndVGToForm(result, vfModuleInstance, serviceId, vnfModel, true); result.push(this.getLcpRegionControl(serviceId, vfModuleInstance, result)); diff --git a/vid-webpack-master/src/app/shared/components/genericForm/formControlsServices/vnfGenerator/vnf.control.generator.ts b/vid-webpack-master/src/app/shared/components/genericForm/formControlsServices/vnfGenerator/vnf.control.generator.ts index ff0a525b5..c45fa968f 100644 --- a/vid-webpack-master/src/app/shared/components/genericForm/formControlsServices/vnfGenerator/vnf.control.generator.ts +++ b/vid-webpack-master/src/app/shared/components/genericForm/formControlsServices/vnfGenerator/vnf.control.generator.ts @@ -73,8 +73,7 @@ export class VnfControlGenerator { this._logService.error('should provide serviceId, vnfName, vnfStoreKey', serviceId); return []; } - - const vnfInstance = this.getVnfInstance(serviceId, vnfStoreKey); + const vnfInstance = this._basicControlGenerator.retrieveInstanceIfUpdateMode(this.store,this.getVnfInstance(serviceId, vnfStoreKey)); const vnfModel = new VNFModel(this.store.getState().service.serviceHierarchy[serviceId].vnfs[vnfName]); let result: FormControlModel[] = []; const flags = this.store.getState().global.flags; @@ -99,7 +98,7 @@ export class VnfControlGenerator { } let result: FormControlModel[] = []; - const vnfInstance = this.getVnfInstance(serviceId, vnfStoreKey); + const vnfInstance = this._basicControlGenerator.retrieveInstanceIfUpdateMode(this.store,this.getVnfInstance(serviceId, vnfStoreKey)); const vnfModel = new VNFModel(this.store.getState().service.serviceHierarchy[serviceId].vnfs[vnfName]); if (!_.isNil(vnfModel)) { diff --git a/vid-webpack-master/src/app/shared/components/genericForm/formControlsServices/vnfGroupGenerator/vnfGroup.control.generator.ts b/vid-webpack-master/src/app/shared/components/genericForm/formControlsServices/vnfGroupGenerator/vnfGroup.control.generator.ts index e503f4d2a..45f5ffa63 100644 --- a/vid-webpack-master/src/app/shared/components/genericForm/formControlsServices/vnfGroupGenerator/vnfGroup.control.generator.ts +++ b/vid-webpack-master/src/app/shared/components/genericForm/formControlsServices/vnfGroupGenerator/vnfGroup.control.generator.ts @@ -52,7 +52,7 @@ export class VnfGroupControlGenerator { return []; } - const vnfGroupInstance = this.getVnfGroupInstance(serviceId, vnfGroupStoreKey); + const vnfGroupInstance = this._basicControlGenerator.retrieveInstanceIfUpdateMode(this.store, this.getVnfGroupInstance(serviceId, vnfGroupStoreKey)); const vnfGroupModel = new VnfGroupModel(this.store.getState().service.serviceHierarchy[serviceId].vnfGroups[vnfGroupName]); let result: FormControlModel[] = []; @@ -70,7 +70,7 @@ export class VnfGroupControlGenerator { } let result: FormControlModel[] = []; - const vnfGroupInstance = this.getVnfGroupInstance(serviceId, vnfGroupStoreKey); + const vnfGroupInstance = this._basicControlGenerator.retrieveInstanceIfUpdateMode(this.store, this.getVnfGroupInstance(serviceId, vnfGroupStoreKey)); const vnfGroupModel = new VnfGroupModel(this.store.getState().service.serviceHierarchy[serviceId].vnfGroups[vnfGroupName]); if (!_.isNil(vnfGroupModel)) { |