From 29187fc161058afd00ba38917ed3d62ed41f1d4c Mon Sep 17 00:00:00 2001 From: Einat Vinouze Date: Wed, 25 Mar 2020 14:00:10 +0200 Subject: Revert "VNF's LCP regions found by Line-of-business (and owning-entity)" This reverts commit e2a7abb45b953d405fc5aa1917f74e2da9f188c0. Issue-ID: VID-788 Change-Id: I72fb7ab9d19df9157c25f635188cb3d0b1fda2cb Signed-off-by: Einat Vinouze --- .../sharedControlles/shared.controllers.service.ts | 143 ++++----------------- 1 file changed, 24 insertions(+), 119 deletions(-) (limited to 'vid-webpack-master/src/app/shared/components/genericForm/formControlsServices/sharedControlles') diff --git a/vid-webpack-master/src/app/shared/components/genericForm/formControlsServices/sharedControlles/shared.controllers.service.ts b/vid-webpack-master/src/app/shared/components/genericForm/formControlsServices/sharedControlles/shared.controllers.service.ts index d82ba36a9..d589efa14 100644 --- a/vid-webpack-master/src/app/shared/components/genericForm/formControlsServices/sharedControlles/shared.controllers.service.ts +++ b/vid-webpack-master/src/app/shared/components/genericForm/formControlsServices/sharedControlles/shared.controllers.service.ts @@ -16,8 +16,6 @@ import {Constants} from "../../../../utils/constants"; import {CheckboxFormControl} from "../../../../models/formControlModels/checkboxFormControl.model"; import {InputFormControl} from "../../../../models/formControlModels/inputFormControl.model"; import {NodeModel} from "../../../../models/nodeModel"; -import {LcpRegion} from "../../../../models/lcpRegion"; -import {Tenant} from "../../../../models/tenant"; import {MultiselectFormControl} from "../../../../models/formControlModels/multiselectFormControl.model"; import {MultiSelectItem} from "../../../formControls/component/multiselect/multiselect.model"; @@ -29,30 +27,6 @@ export class SharedControllersService { getLineOfBusinessControl = (instance?: any): DropdownFormControl => { - return this.getLineOfBusinessControlInternal(undefined, instance); - }; - - getMultiSelectLineOfBusinessControl = (instance: any, isMultiSelected: boolean): MultiselectFormControl => { - return this.getLobMultiselectControl(instance, isMultiSelected); - }; - - getLineOfBusinessByOwningEntityControl = (instance?: any, serviceId?: string, controls?: FormControlModel[]): DropdownFormControl => { - const service = this._store.getState().service.serviceInstance[serviceId]; - const owningEntityName: string = service.owningEntityName; - - const changeLcpRegionOptionsOnChange = (lineOfBusinessNameParam: string, form: FormGroup) => { - form.controls['lcpCloudRegionId'].enable(); - form.controls['lcpCloudRegionId'].reset(); - this._basicControlGenerator.getSubscribeInitResult( - this._aaiService.getLcpRegionsByOwningEntityAndLineOfBusiness.bind(this, owningEntityName, lineOfBusinessNameParam), - controls.find(item => item.controlName === 'lcpCloudRegionId') as DropdownFormControl, form - ).subscribe() - }; - - return this.getLineOfBusinessControlInternal(changeLcpRegionOptionsOnChange, instance); - }; - - private getLineOfBusinessControlInternal = (onChange: Function, instance?: any): DropdownFormControl => { return new DropdownFormControl({ type: FormControlType.DROPDOWN, controlName: 'lineOfBusiness', @@ -64,29 +38,18 @@ export class SharedControllersService { value: instance ? instance.lineOfBusiness : null, validations: [new ValidatorModel(ValidatorOptions.required, 'is required')], onInitSelectedField: ['lineOfBusinessList'], - onChange, onInit: this._basicControlGenerator.getSubscribeInitResult.bind(null, this._aaiService.getCategoryParameters) }) }; + getMultiSelectLineOfBusinessControl = (instance: any, isMultiSelected: boolean): MultiselectFormControl => { + return this.getLobMultiselectControl(instance, isMultiSelected); + }; + getTenantControl = (serviceId: string, instance?: any): DropdownFormControl => { const service = this._store.getState().service.serviceInstance[serviceId]; const globalCustomerId: string = service.globalSubscriberId; const serviceType: string = service.subscriptionServiceType; - - const onInit = instance - ? this._basicControlGenerator.getSubscribeInitResult.bind( - this._aaiService, - this._aaiService.getLcpRegionsAndTenants.bind(this, globalCustomerId, serviceType)) - : () => {}; - return this.getTenantControlInternal(onInit, instance); - }; - - getTenantByLcpRegionControl = (serviceId: string, instance?: any): DropdownFormControl => { - return this.getTenantControlInternal(() => {}, instance); - }; - - private getTenantControlInternal = (onInit: Function, instance?: any): DropdownFormControl => { return new DropdownFormControl({ type: FormControlType.DROPDOWN, controlName: 'tenantId', @@ -98,7 +61,10 @@ export class SharedControllersService { onInitSelectedField: instance ? ['lcpRegionsTenantsMap', instance.lcpCloudRegionId] : null, value: instance ? instance.tenantId : null, validations: [new ValidatorModel(ValidatorOptions.required, 'is required')], - onInit, + onInit: instance ? this._basicControlGenerator.getSubscribeInitResult.bind( + this._aaiService, + this._aaiService.getLcpRegionsAndTenants.bind(this, globalCustomerId, serviceType)) : () => { + } }) }; @@ -133,70 +99,6 @@ export class SharedControllersService { const service = this._store.getState().service.serviceInstance[serviceId]; const globalCustomerId: string = service.globalSubscriberId; const serviceType: string = service.subscriptionServiceType; - - const onInit = this._basicControlGenerator.getSubscribeInitResult.bind( - this._aaiService, - this._aaiService.getLcpRegionsAndTenants.bind(this, globalCustomerId, serviceType) - ); - - const changeTenantsOptionsByServiceTypeOnChange = ( - (globalCustomerId, serviceType, lcpCloudRegionIdParam) => { - if (!_.isNil(globalCustomerId) && !_.isNil(serviceType)) { - this._basicControlGenerator.getSubscribeResult.bind(this, - this._aaiService.getLcpRegionsAndTenants(globalCustomerId, serviceType) - .subscribe(res => this.setTenantsOptions(controls, res.lcpRegionsTenantsMap[lcpCloudRegionIdParam]))); - } - - } - ).bind(this, globalCustomerId, serviceType); - - return this.getLcpRegionControlInternal(instance, controls, - false, onInit, ['lcpRegionList'], changeTenantsOptionsByServiceTypeOnChange) - }; - - getLcpRegionByLineOfBusinessControl = (serviceId: string, instance: any, controls: FormControlModel[]): DropdownFormControl => { - const service = this._store.getState().service.serviceInstance[serviceId]; - const owningEntityName: string = service.owningEntityName; - - const changeTenantsOptions = (controls: FormControlModel[], cloudRegionId, lcpRegionList: LcpRegion[]) => { - const lcpRegionOption = (_.isNil(lcpRegionList) || _.isNil(cloudRegionId)) - ? null : lcpRegionList.find(({id}) => id === cloudRegionId); - - if (!_.isNil(lcpRegionOption)) { - this._aaiService.getTenantsByCloudOwnerAndCloudRegionId(lcpRegionOption.cloudOwner, lcpRegionOption.id) - .subscribe(res => this.setTenantsOptions(controls, res)); - } - }; - - const lcpRegionOptionsList = (controls: FormControlModel[]): LcpRegion[] => { - const lcpCloudRegionIdControl = _.isNil(controls) - ? null : controls.find(({controlName}) => controlName === 'lcpCloudRegionId'); - - return _.isNil(lcpCloudRegionIdControl) ? null : lcpCloudRegionIdControl['options$']; - }; - - const loadLcpRegionOptionsOnInit = (_.isNil(instance) || _.isNil(instance.lineOfBusiness)) - ? () => {} - : this._basicControlGenerator.getSubscribeInitResult.bind( - this, () => { - return this._aaiService.getLcpRegionsByOwningEntityAndLineOfBusiness(owningEntityName, instance.lineOfBusiness) - .do(res => changeTenantsOptions(controls, instance.lcpCloudRegionId, res)); - } - ); - - const changeTenantsOptionsByCloudRegionIdOnChange = ( - (controls, lcpCloudRegionIdParam) => changeTenantsOptions(controls, lcpCloudRegionIdParam, lcpRegionOptionsList(controls)) - ).bind(this, controls); - - return this.getLcpRegionControlInternal(instance, controls, - _.isNil(instance) || _.isNil(instance.lineOfBusiness), - loadLcpRegionOptionsOnInit, null, changeTenantsOptionsByCloudRegionIdOnChange - ) - }; - - private getLcpRegionControlInternal = (instance: any, controls: FormControlModel[], isDisabled: boolean, - onInit: Function, onInitSelectedField: string[], changeTenantsOptionsOnChange: Function - ): DropdownFormControl => { return new DropdownFormControl({ type: FormControlType.DROPDOWN, controlName: 'lcpCloudRegionId', @@ -204,19 +106,26 @@ export class SharedControllersService { dataTestId: 'lcpRegion', placeHolder: 'Select LCP Region', name: "lcpRegion", - isDisabled, + isDisabled: false, value: instance ? instance.lcpCloudRegionId : null, validations: [new ValidatorModel(ValidatorOptions.required, 'is required')], - onInitSelectedField, - onInit, - - onChange: (lcpCloudRegionIdParam: string, form: FormGroup) => { + onInitSelectedField: ['lcpRegionList'], + onInit: this._basicControlGenerator.getSubscribeInitResult.bind( + this._aaiService, + this._aaiService.getLcpRegionsAndTenants.bind(this, globalCustomerId, serviceType)), + onChange: (param: string, form: FormGroup) => { form.controls['tenantId'].enable(); form.controls['tenantId'].reset(); + if (!_.isNil(globalCustomerId) && !_.isNil(serviceType)) { + this._basicControlGenerator.getSubscribeResult.bind(this, this._aaiService.getLcpRegionsAndTenants(globalCustomerId, serviceType).subscribe(res => { + controls.find(item => item.controlName === 'tenantId')['options$'] = res.lcpRegionsTenantsMap[param]; + if (res.lcpRegionsTenantsMap[param]) { + controls.find(item => item.controlName === 'tenantId')['hasEmptyOptions'] = res.lcpRegionsTenantsMap[param].length === 0; + } + })); + } - changeTenantsOptionsOnChange(lcpCloudRegionIdParam); - - if (Constants.LegacyRegion.MEGA_REGION.indexOf(lcpCloudRegionIdParam) !== -1) { + if (Constants.LegacyRegion.MEGA_REGION.indexOf(param) !== -1) { form.controls['legacyRegion'].enable(); controls.find(item => item.controlName === 'legacyRegion').isVisible = true; @@ -230,11 +139,7 @@ export class SharedControllersService { }) }; - private setTenantsOptions = (controls: FormControlModel[], tenants: Tenant[]) => { - const tenantsControl = controls.find(item => item.controlName === 'tenantId'); - tenantsControl['options$'] = tenants; - tenantsControl['hasEmptyOptions'] = tenants && tenants.length === 0; - }; + getSDNCControl = (instance: any, checkedByDefault: boolean, extraContents? : object[]): FormControlModel => { -- cgit 1.2.3-korg