aboutsummaryrefslogtreecommitdiffstats
path: root/vid-webpack-master/src/app/shared/components/genericForm
diff options
context:
space:
mode:
authorYoav Schneiderman <yoav.schneiderman@intl.att.com>2019-11-20 16:50:45 +0200
committerEinat Vinouze <einat.vinouze@intl.att.com>2019-11-26 12:41:29 +0200
commit091343aa4bbf1bd6b882e08113d90685c1c84ffe (patch)
treefbef4bda9987a59dff5109cf5cc401f95eb05068 /vid-webpack-master/src/app/shared/components/genericForm
parentee6c513301200be38c3602a4c3084c2ff3bde10c (diff)
Allow platform multi-selection for VNF in modern UI
Issue-ID: VID-722 Change-Id: Id87f59fff128e277d9158b83f3908754375c8b01 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')
-rw-r--r--vid-webpack-master/src/app/shared/components/genericForm/formControlsServices/vnfGenerator/vnf.control.generator.spec.ts30
-rw-r--r--vid-webpack-master/src/app/shared/components/genericForm/formControlsServices/vnfGenerator/vnf.control.generator.ts52
-rw-r--r--vid-webpack-master/src/app/shared/components/genericForm/generic-form.component.html5
3 files changed, 82 insertions, 5 deletions
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 5c6e25c6b..9230ccfa7 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
@@ -16,6 +16,7 @@ import {VnfControlGenerator} from "./vnf.control.generator";
import {Observable} from "rxjs";
import {SelectOption} from "../../../../models/selectOption";
import {FeatureFlagsService} from "../../../../services/featureFlag/feature-flags.service";
+import {FormControlType} from "../../../../models/formControlModels/formControlTypes.enum";
class MockAppStore<T> {
getState(){
@@ -939,6 +940,35 @@ describe('VNF Control Generator', () => {
})().then(done).catch(done.fail));
+
+ test('should call platform dropdown control', ()=>{
+ spyOn(service, 'getPlatformDropdownControl');
+
+ service.getPlatformControl(null, [], false);
+
+ expect(service.getPlatformDropdownControl).toBeCalledWith(null, []);
+ });
+
+ test('should call platform multi select control', ()=>{
+ spyOn(service, 'getPlatformMultiselectControl');
+
+ service.getPlatformControl(null, [], true);
+
+ expect(service.getPlatformMultiselectControl).toBeCalledWith(null, []);
+ });
+
+ test('should generate platform multi select control', ()=>{
+ const control = service.getPlatformMultiselectControl(null, []);
+ 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 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 => {
diff --git a/vid-webpack-master/src/app/shared/components/genericForm/generic-form.component.html b/vid-webpack-master/src/app/shared/components/genericForm/generic-form.component.html
index d4c5118b3..edf86823c 100644
--- a/vid-webpack-master/src/app/shared/components/genericForm/generic-form.component.html
+++ b/vid-webpack-master/src/app/shared/components/genericForm/generic-form.component.html
@@ -6,6 +6,11 @@
<checkbox-form-control *ngSwitchCase="'CHECKBOX'" [data]="formControl" [form]="dynamicFormGroup" ></checkbox-form-control>
<dropdown-form-control *ngSwitchCase="'DROPDOWN'" [data]="formControl" [form]="dynamicFormGroup" ></dropdown-form-control>
<file-form-control *ngSwitchCase="'FILE'" [data]="formControl" [form]="dynamicFormGroup"></file-form-control>
+ <multiselect-form-control *ngSwitchCase="'MULTI_SELECT'"
+ [data]="formControl"
+ [form]="dynamicFormGroup"
+ [multiselectOptions]="formControl?.options$"
+ [selectedItems]="formControl.value"></multiselect-form-control>
</div>
<div *ngIf="dynamicFormGroup != null && formControl != null && dynamicFormGroup.controls[formControl.controlName]?.errors">
<div *ngFor="let validatorModel of formControl?.validations">