summaryrefslogtreecommitdiffstats
path: root/vid-webpack-master/src/app/shared/components/genericForm/formControlsServices/vnfGenerator/vnf.control.generator.ts
diff options
context:
space:
mode:
Diffstat (limited to 'vid-webpack-master/src/app/shared/components/genericForm/formControlsServices/vnfGenerator/vnf.control.generator.ts')
-rw-r--r--vid-webpack-master/src/app/shared/components/genericForm/formControlsServices/vnfGenerator/vnf.control.generator.ts52
1 files changed, 47 insertions, 5 deletions
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 7760ba8ad..55177aaac 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
@@ -20,6 +20,8 @@ import {Observable, of} from "rxjs";
import {SelectOption} from "../../../../models/selectOption";
import * as _ from 'lodash';
import {Constants} from "../../../../utils/constants";
+import {MultiselectFormControl} from "../../../../models/formControlModels/multiselectFormControl.model";
+import {MultiSelectItem} from "../../../formControls/component/multiselect/multiselect.model";
export enum FormControlNames {
INSTANCE_NAME = 'instanceName',
@@ -101,12 +103,13 @@ export class VnfControlGenerator {
const vnfModel = new VNFModel(this.store.getState().service.serviceHierarchy[serviceId].vnfs[vnfName]);
if (!_.isNil(vnfModel)) {
+ const flags = this.store.getState().global.flags;
result.push(this.getInstanceName(vnfInstance, serviceId, vnfName, vnfModel.isEcompGeneratedNaming));
result.push(this._basicControlGenerator.getProductFamilyControl(vnfInstance, result, false));
result.push(this.getLcpRegionControl(serviceId, vnfInstance, result));
result.push(this._basicControlGenerator.getLegacyRegion(vnfInstance));
result.push(this.getTenantControl(serviceId, vnfInstance, result));
- result.push(this.getPlatformControl(vnfInstance, result));
+ result.push(this.getPlatformControl(vnfInstance, result, flags['FLAG_2002_VNF_PLATFORM_MULTI_SELECT']));
result.push(this.getLineOfBusinessControl(vnfInstance, result));
result.push(this.getRollbackOnFailureControl(vnfInstance, result));
}
@@ -139,20 +142,59 @@ export class VnfControlGenerator {
})
};
- getPlatformControl = (instance: any, controls: FormControlModel[]): DropdownFormControl => {
+
+
+ getPlatformDropdownControl = (instance: any, controls: FormControlModel[]) : DropdownFormControl => {
return new DropdownFormControl({
- type: FormControlType.DROPDOWN,
+ type: FormControlType.DROPDOWN ,
controlName: 'platformName',
displayName: 'Platform',
dataTestId: 'platform',
+ selectedFieldName : null ,
+ ngValue : null,
placeHolder: 'Select Platform',
isDisabled: false,
name: "platform",
value: instance ? instance.platformName : null,
validations: [new ValidatorModel(ValidatorOptions.required, 'is required')],
onInitSelectedField: ['platformList'],
- onInit: this._basicControlGenerator.getSubscribeInitResult.bind(null, this._aaiService.getCategoryParameters)
- })
+ onInit: this._basicControlGenerator.getSubscribeInitResult.bind(null, this._aaiService.getCategoryParameters),
+ });
+ };
+
+ getPlatformMultiselectControl = (instance: any, controls: FormControlModel[]) : 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 : '',
+ 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(',');
+ }
+ });
+ };
+
+ getPlatformControl = (instance: any, controls: FormControlModel[], isMultiSelect?: boolean): MultiselectFormControl | DropdownFormControl => {
+ const shouldGenerateDropdown = isMultiSelect === undefined || isMultiSelect === false;
+ if(shouldGenerateDropdown){
+ return this.getPlatformDropdownControl(instance, controls);
+ }
+ return this.getPlatformMultiselectControl(instance, controls);
};
getTenantControl = (serviceId: string, instance: any, controls: FormControlModel[]): DropdownFormControl => {