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 | |
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')
8 files changed, 47 insertions, 16 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)) { diff --git a/vid-webpack-master/src/app/shared/components/genericFormPopup/generic-form-popup.component.html b/vid-webpack-master/src/app/shared/components/genericFormPopup/generic-form-popup.component.html index f9a11eab1..2b2c2a75d 100644 --- a/vid-webpack-master/src/app/shared/components/genericFormPopup/generic-form-popup.component.html +++ b/vid-webpack-master/src/app/shared/components/genericFormPopup/generic-form-popup.component.html @@ -3,7 +3,7 @@ <div class="modal-header"> <button type="button" class="close" - (click)="formPopupDetails?.onCancel(formPopupDetails.that,dynamicForm)">× + (click)="formPopupDetails?.onCancel(formPopupDetails.that,dynamicForm);clearModalIsUpdateMode()">× </button> <span [attr.data-tests-id]="'create-modal-title'" class="modal-title">{{formPopupDetails?.title}} @@ -70,14 +70,14 @@ <button [attr.data-tests-id]="'cancelButton'" type="button" class="btn btn-default cancel" - (click)="formPopupDetails.onCancel(formPopupDetails.that, dynamicForm)"><span>Cancel</span></button> + (click)="formPopupDetails.onCancel(formPopupDetails.that, dynamicForm); clearModalIsUpdateMode()"><span>Cancel</span></button> <input type="submit" value="Set" data-tests-id="form-set" class="btn btn-success submit" [disabled]="!dynamicForm?.valid" - (click)="formPopupDetails.onSubmit(formPopupDetails.that, dynamicForm, servicesQty)"> + (click)="formPopupDetails.onSubmit(formPopupDetails.that, dynamicForm, servicesQty);clearModalIsUpdateMode()"> </div> </div> </div> diff --git a/vid-webpack-master/src/app/shared/components/genericFormPopup/generic-form-popup.component.ts b/vid-webpack-master/src/app/shared/components/genericFormPopup/generic-form-popup.component.ts index 3939e44ff..3cd633de6 100644 --- a/vid-webpack-master/src/app/shared/components/genericFormPopup/generic-form-popup.component.ts +++ b/vid-webpack-master/src/app/shared/components/genericFormPopup/generic-form-popup.component.ts @@ -15,6 +15,7 @@ import {FormControlModel} from "../../models/formControlModels/formControl.model import {FormGeneralErrorsService} from "../formGeneralErrors/formGeneralErrors.service"; import {FeatureFlagsService, Features} from "../../services/featureFlag/feature-flags.service"; import {InstantiationTemplatesModalComponent} from "./instantiationTemplatesModal/instantiation.templates.modal.component"; +import {updateCurrentModalModeAction} from "../../storeUtil/utils/global/global.actions"; export interface PopupModel { @@ -80,7 +81,12 @@ export class GenericFormPopupComponent extends DialogComponent<PopupModel, boole return this.formPopupDetails && this.formPopupDetails.UUIDData['bulkSize'] > 1 } + clearModalIsUpdateMode() : void { + this._store.dispatch(updateCurrentModalModeAction(null)); + } + ngOnInit(): void { + this._store.dispatch(updateCurrentModalModeAction(this.isUpdateMode)); this._route .queryParams .subscribe(params => { |