aboutsummaryrefslogtreecommitdiffstats
path: root/vid-webpack-master/src/app/shared/components/genericForm
diff options
context:
space:
mode:
authorEinat Vinouze <einat.vinouze@intl.att.com>2020-03-03 16:15:39 +0200
committerEinat Vinouze <einat.vinouze@intl.att.com>2020-03-08 11:43:12 +0200
commit742d6d369b761220e565f39f2fa09413141ad93f (patch)
treec3f48794abab6cedb5d698b75b2fe525a56c7958 /vid-webpack-master/src/app/shared/components/genericForm
parentf7c41b1c4aeea09e67c8bb88f39d15e02cd1708f (diff)
allow platform multi-selection for network
Issue-ID: VID-785 Change-Id: I4e6a4c2f0dc8c0e11f2571eec0789ad5672a9147 Signed-off-by: Einat Vinouze <einat.vinouze@intl.att.com>
Diffstat (limited to 'vid-webpack-master/src/app/shared/components/genericForm')
-rw-r--r--vid-webpack-master/src/app/shared/components/genericForm/formControlsServices/networkGenerator/network.control.generator.spec.ts7
-rw-r--r--vid-webpack-master/src/app/shared/components/genericForm/formControlsServices/networkGenerator/network.control.generator.ts25
-rw-r--r--vid-webpack-master/src/app/shared/components/genericForm/formControlsServices/sharedControlles/shared.controllers.service.spec.ts13
-rw-r--r--vid-webpack-master/src/app/shared/components/genericForm/formControlsServices/sharedControlles/shared.controllers.service.ts30
-rw-r--r--vid-webpack-master/src/app/shared/components/genericForm/formControlsServices/vnfGenerator/vnf.control.generator.spec.ts14
-rw-r--r--vid-webpack-master/src/app/shared/components/genericForm/formControlsServices/vnfGenerator/vnf.control.generator.ts44
6 files changed, 57 insertions, 76 deletions
diff --git a/vid-webpack-master/src/app/shared/components/genericForm/formControlsServices/networkGenerator/network.control.generator.spec.ts b/vid-webpack-master/src/app/shared/components/genericForm/formControlsServices/networkGenerator/network.control.generator.spec.ts
index b5277b48d..3fadd34ff 100644
--- a/vid-webpack-master/src/app/shared/components/genericForm/formControlsServices/networkGenerator/network.control.generator.spec.ts
+++ b/vid-webpack-master/src/app/shared/components/genericForm/formControlsServices/networkGenerator/network.control.generator.spec.ts
@@ -7,10 +7,15 @@ import {GenericFormService} from "../../generic-form.service";
import {FormBuilder} from "@angular/forms";
import {LogService} from "../../../../utils/log/log.service";
import {FormControlNames, NetworkControlGenerator} from "./network.control.generator";
-import {FormControlModel, ValidatorModel, ValidatorOptions} from "../../../../models/formControlModels/formControl.model";
+import {
+ FormControlModel,
+ ValidatorModel,
+ ValidatorOptions
+} from "../../../../models/formControlModels/formControl.model";
import {FeatureFlagsService} from "../../../../services/featureFlag/feature-flags.service";
import {SharedControllersService} from "../sharedControlles/shared.controllers.service";
+
class MockAppStore<T> {
getState(){
return {
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 a7f16db4b..e0418fcfa 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
@@ -9,12 +9,11 @@ import * as _ from 'lodash';
import {FormControlModel,} from "../../../../models/formControlModels/formControl.model";
import {LogService} from "../../../../utils/log/log.service";
import {AppState} from "../../../../store/reducers";
-import {DropdownFormControl} from "../../../../models/formControlModels/dropdownFormControl.model";
-import {FormControlType} from "../../../../models/formControlModels/formControlTypes.enum";
import {NetworkInstance} from "../../../../models/networkInstance";
import {NetworkModel} from "../../../../models/networkModel";
import {SharedControllersService} from "../sharedControlles/shared.controllers.service";
+
export enum FormControlNames {
INSTANCE_NAME = 'instanceName',
PRODUCT_FAMILY_ID = 'productFamilyId',
@@ -56,6 +55,7 @@ export class NetworkControlGenerator {
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[] = [];
+ const flags = this.store.getState().global.flags;
if (!_.isNil(networkModel)) {
result.push(this.getInstanceName(networkInstance, serviceId, networkName, networkModel.isEcompGeneratedNaming));
@@ -63,7 +63,7 @@ export class NetworkControlGenerator {
result.push(this._sharedControllersService.getLcpRegionControl(serviceId, networkInstance, result));
result.push(this._sharedControllersService.getLegacyRegion(networkInstance));
result.push(this._sharedControllersService.getTenantControl(serviceId, networkInstance));
- result.push(this.getPlatformControl(networkInstance));
+ result.push(this._sharedControllersService.getPlatformMultiselectControl(networkInstance, result, flags['FLAG_2006_NETWORK_PLATFORM_MULTI_SELECT']));
result.push(this._sharedControllersService.getLineOfBusinessControl(networkInstance));
}
return result;
@@ -80,6 +80,7 @@ export class NetworkControlGenerator {
let result: FormControlModel[] = [];
const networkInstance = this._basicControlGenerator.retrieveInstanceIfUpdateMode(this.store, this.getNetworkInstance(serviceId, networkStoreKey, isUpdateMode));
const networkModel = new NetworkModel(this.store.getState().service.serviceHierarchy[serviceId].networks[networkName]);
+ const flags = this.store.getState().global.flags;
if (!_.isNil(networkModel)) {
result.push(this.getInstanceName(networkInstance, serviceId, networkName, networkModel.isEcompGeneratedNaming));
@@ -87,7 +88,7 @@ export class NetworkControlGenerator {
result.push(this._sharedControllersService.getLcpRegionControl(serviceId, networkInstance, result));
result.push(this._sharedControllersService.getLegacyRegion(networkInstance));
result.push(this._sharedControllersService.getTenantControl(serviceId, networkInstance));
- result.push(this.getPlatformControl(networkInstance));
+ result.push(this._sharedControllersService.getPlatformMultiselectControl(networkInstance, result, flags['FLAG_2006_NETWORK_PLATFORM_MULTI_SELECT']));
result.push(this._sharedControllersService.getLineOfBusinessControl(networkInstance));
result.push(this._sharedControllersService.getRollbackOnFailureControl(networkInstance));
}
@@ -99,20 +100,4 @@ export class NetworkControlGenerator {
const networkModel: NetworkModel = this.store.getState().service.serviceHierarchy[serviceId].networks[networkName];
return this._sharedControllersService.getInstanceNameController(instance, serviceId, isEcompGeneratedNaming, networkModel);
}
-
- getPlatformControl = (instance: any): DropdownFormControl => {
- return new DropdownFormControl({
- type: FormControlType.DROPDOWN,
- controlName: 'platformName',
- displayName: 'Platform',
- dataTestId: 'platform',
- placeHolder: 'Select Platform',
- isDisabled: false,
- name: "platform",
- value: instance ? instance.platformName : null,
- validations: [],
- onInitSelectedField: ['platformList'],
- onInit: this._basicControlGenerator.getSubscribeInitResult.bind(null, this._aaiService.getCategoryParameters)
- })
- };
}
diff --git a/vid-webpack-master/src/app/shared/components/genericForm/formControlsServices/sharedControlles/shared.controllers.service.spec.ts b/vid-webpack-master/src/app/shared/components/genericForm/formControlsServices/sharedControlles/shared.controllers.service.spec.ts
index 58ee33b53..f456a747a 100644
--- a/vid-webpack-master/src/app/shared/components/genericForm/formControlsServices/sharedControlles/shared.controllers.service.spec.ts
+++ b/vid-webpack-master/src/app/shared/components/genericForm/formControlsServices/sharedControlles/shared.controllers.service.spec.ts
@@ -11,7 +11,6 @@ import {FormControlModel, ValidatorOptions} from "../../../../models/formControl
import {ControlGeneratorUtil} from "../control.generator.util.service";
-
describe('Shared Controllers Service', () => {
let injector;
let service: SharedControllersService;
@@ -118,6 +117,18 @@ describe('Shared Controllers Service', () => {
const legacyRegionControl: FormControlModel = service.getLegacyRegion(instance);
expect(legacyRegionControl.isVisible).toBeFalsy();
});
+
+ test('multiSelectFlag is not activated should generate platform multi select control with 1 as limitSelection', ()=>{
+ const control = service.getPlatformMultiselectControl(null, [],false);
+ expect(control.dataTestId).toEqual('multi-selectPlatform');
+ expect(control.limitSelection).toEqual(1);
+ });
+
+ test('multiSelectFlag is activated should generate platform multi select control with 1000 as limitSelection', ()=>{
+ const control = service.getPlatformMultiselectControl(null, [],true);
+ expect(control.dataTestId).toEqual('multi-selectPlatform');
+ expect(control.limitSelection).toEqual(1000);
+ });
});
class MockAppStore<T> {
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 4b567328d..c41c6c282 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
@@ -18,6 +18,8 @@ import {InputFormControl} from "../../../../models/formControlModels/inputFormCo
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";
@Injectable()
export class SharedControllersService {
@@ -284,4 +286,32 @@ export class SharedControllersService {
formControlModel.value = instance ? instance.instanceName : null;
return formControlModel;
}
+
+ getPlatformMultiselectControl = (instance: any, controls: FormControlModel[], isMultiSelected: boolean) : MultiselectFormControl => {
+ return new MultiselectFormControl({
+ type: FormControlType.MULTI_SELECT,
+ controlName: 'platformName',
+ displayName: 'Platform',
+ dataTestId: 'multi-selectPlatform',
+ selectedFieldName: 'name',
+ ngValue: 'name',
+ placeHolder: 'Select Platform',
+ isDisabled: false,
+ name: "platform",
+ value: instance ? instance.platformName : '',
+ limitSelection: isMultiSelected ? 1000 : 1,
+ validations: [new ValidatorModel(ValidatorOptions.required, 'is required')],
+ onInitSelectedField: ['platformList'],
+ onInit: this._basicControlGenerator.getSubscribeInitResult.bind(null, this._aaiService.getCategoryParameters),
+ onChange: (param: MultiSelectItem[], form: FormGroup) => {
+ form.controls['platformName'].setValue(param.map((multiSelectItem: MultiSelectItem) => {
+ return multiSelectItem.itemName
+ }).join(','));
+ },
+ convertOriginalDataToArray: (value?: string) => {
+ if (_.isNil(value)) return [];
+ return value.split(',');
+ }
+ });
+ }
}
diff --git a/vid-webpack-master/src/app/shared/components/genericForm/formControlsServices/vnfGenerator/vnf.control.generator.spec.ts b/vid-webpack-master/src/app/shared/components/genericForm/formControlsServices/vnfGenerator/vnf.control.generator.spec.ts
index c7d623671..08afb417e 100644
--- a/vid-webpack-master/src/app/shared/components/genericForm/formControlsServices/vnfGenerator/vnf.control.generator.spec.ts
+++ b/vid-webpack-master/src/app/shared/components/genericForm/formControlsServices/vnfGenerator/vnf.control.generator.spec.ts
@@ -14,7 +14,6 @@ import {
import {LogService} from "../../../../utils/log/log.service";
import {VnfControlGenerator} from "./vnf.control.generator";
import {FeatureFlagsService} from "../../../../services/featureFlag/feature-flags.service";
-import {FormControlType} from "../../../../models/formControlModels/formControlTypes.enum";
import {SharedControllersService} from "../sharedControlles/shared.controllers.service";
class MockAppStore<T> {
@@ -940,19 +939,6 @@ describe('VNF Control Generator', () => {
})().then(done).catch(done.fail));
-
- test('should generate platform multi select control', ()=>{
- const control = service.getPlatformMultiselectControl(null, [],false);
- expect(control.type).toEqual(FormControlType.MULTI_SELECT);
- expect(control.controlName).toEqual('platformName');
- expect(control.displayName).toEqual('Platform');
- expect(control.dataTestId).toEqual('multi-selectPlatform');
- expect(control.selectedFieldName).toEqual('name');
- expect(control.value).toEqual('');
- expect(control.onChange).toBeDefined();
- expect(control.convertOriginalDataToArray).toBeDefined();
- });
-
test('getMacroFormControls check for mandatory controls', () => {
const serviceId : string = "6e59c5de-f052-46fa-aa7e-2fca9d674c44";
const vnfName : string = "VF_vGeraldine 0";
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 ef58bc761..4b325b286 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
@@ -4,19 +4,11 @@ import {AaiService} from "../../../../services/aaiService/aai.service";
import {NgRedux} from "@angular-redux/store";
import {HttpClient} from "@angular/common/http";
import {ControlGeneratorUtil} from "../control.generator.util.service";
-import {
- FormControlModel,
- ValidatorModel,
- ValidatorOptions
-} from "../../../../models/formControlModels/formControl.model";
+import {FormControlModel} from "../../../../models/formControlModels/formControl.model";
import {LogService} from "../../../../utils/log/log.service";
import {VNFModel} from "../../../../models/vnfModel";
import {AppState} from "../../../../store/reducers";
-import {FormGroup} from "@angular/forms";
-import {FormControlType} from "../../../../models/formControlModels/formControlTypes.enum";
import * as _ from 'lodash';
-import {MultiselectFormControl} from "../../../../models/formControlModels/multiselectFormControl.model";
-import {MultiSelectItem} from "../../../formControls/component/multiselect/multiselect.model";
import {SharedControllersService} from "../sharedControlles/shared.controllers.service";
import {FeatureFlagsService, Features} from "../../../../services/featureFlag/feature-flags.service";
@@ -60,7 +52,7 @@ export class VnfControlGenerator {
result.push(this._sharedControllersService.getLcpRegionControl(serviceId, vnfInstance, result));
result.push(this._sharedControllersService.getLegacyRegion(vnfInstance));
result.push(this._sharedControllersService.getTenantControl(serviceId, vnfInstance));
- result.push(this.getPlatformMultiselectControl(vnfInstance, result, flags['FLAG_2002_VNF_PLATFORM_MULTI_SELECT']));
+ result.push(this._sharedControllersService.getPlatformMultiselectControl(vnfInstance, result, flags['FLAG_2002_VNF_PLATFORM_MULTI_SELECT']));
result.push(this._sharedControllersService.getLineOfBusinessControl(vnfInstance));
}
return result;
@@ -91,12 +83,12 @@ export class VnfControlGenerator {
result.push(this._sharedControllersService.getLcpRegionByLineOfBusinessControl(serviceId, vnfInstance, result));
result.push(this._sharedControllersService.getLegacyRegion(vnfInstance));
result.push(this._sharedControllersService.getTenantByLcpRegionControl(serviceId, vnfInstance));
- result.push(this.getPlatformMultiselectControl(vnfInstance, result, isMultiSelected));
+ result.push(this._sharedControllersService.getPlatformMultiselectControl(vnfInstance, result, isMultiSelected));
} else {
result.push(this._sharedControllersService.getLcpRegionControl(serviceId, vnfInstance, result));
result.push(this._sharedControllersService.getLegacyRegion(vnfInstance));
result.push(this._sharedControllersService.getTenantControl(serviceId, vnfInstance));
- result.push(this.getPlatformMultiselectControl(vnfInstance, result, isMultiSelected));
+ result.push(this._sharedControllersService.getPlatformMultiselectControl(vnfInstance, result, isMultiSelected));
result.push(this._sharedControllersService.getLineOfBusinessControl(vnfInstance));
}
@@ -109,32 +101,4 @@ export class VnfControlGenerator {
const vnfModel : VNFModel = this.store.getState().service.serviceHierarchy[serviceId].vnfs[vnfName];
return this._sharedControllersService.getInstanceNameController(instance, serviceId, isEcompGeneratedNaming, vnfModel);
}
-
- getPlatformMultiselectControl = (instance: any, controls: FormControlModel[], isMultiSelected: boolean) : MultiselectFormControl => {
- return new MultiselectFormControl({
- type: FormControlType.MULTI_SELECT ,
- controlName: 'platformName',
- displayName: 'Platform',
- dataTestId: 'multi-selectPlatform',
- selectedFieldName : 'name' ,
- ngValue : 'name',
- placeHolder: 'Select Platform',
- isDisabled: false,
- name: "platform",
- value: instance ? instance.platformName : '',
- limitSelection : isMultiSelected ? 1000 : 1,
- validations: [new ValidatorModel(ValidatorOptions.required, 'is required')],
- onInitSelectedField: ['platformList'],
- onInit: this._basicControlGenerator.getSubscribeInitResult.bind(null, this._aaiService.getCategoryParameters),
- onChange : (param: MultiSelectItem[], form: FormGroup) => {
- form.controls['platformName'].setValue(param.map((multiSelectItem: MultiSelectItem)=>{
- return multiSelectItem.itemName
- }).join(','));
- },
- convertOriginalDataToArray : (value?: string) => {
- if(_.isNil(value)) return [];
- return value.split(',');
- }
- });
- };
}