From d00cf8079f6ec7d791aa92d9991d95ea0bb4a0e6 Mon Sep 17 00:00:00 2001 From: Eylon Malin Date: Tue, 3 Dec 2019 12:12:38 +0200 Subject: free text filter in instantiationStatus Page Issue-ID: VID-724 Change-Id: I5f363ecc66ff1f1fef9c9d75a12a9c43403aa905 Signed-off-by: Eylon Malin --- .../genericFormServices/basic.popup.service.spec.ts | 1 - .../network/network.popup.service.spec.ts | 1 - .../genericFormServices/vnf/vnf.popup.service.spec.ts | 1 - .../pipes/searchFilter/search-filter.pipe.spec.ts | 17 +++++++++++++++++ .../app/shared/pipes/searchFilter/search-filter.pipe.ts | 14 ++++++++++++++ .../services/featureFlag/feature-flags.service.ts | 1 + vid-webpack-master/src/app/shared/shared.module.ts | 4 ++++ 7 files changed, 36 insertions(+), 3 deletions(-) create mode 100644 vid-webpack-master/src/app/shared/pipes/searchFilter/search-filter.pipe.spec.ts create mode 100644 vid-webpack-master/src/app/shared/pipes/searchFilter/search-filter.pipe.ts (limited to 'vid-webpack-master/src/app/shared') diff --git a/vid-webpack-master/src/app/shared/components/genericFormPopup/genericFormServices/basic.popup.service.spec.ts b/vid-webpack-master/src/app/shared/components/genericFormPopup/genericFormServices/basic.popup.service.spec.ts index f5e07e7e5..a3c83263c 100644 --- a/vid-webpack-master/src/app/shared/components/genericFormPopup/genericFormServices/basic.popup.service.spec.ts +++ b/vid-webpack-master/src/app/shared/components/genericFormPopup/genericFormServices/basic.popup.service.spec.ts @@ -33,7 +33,6 @@ class MockReduxStore { "FLAG_SHOW_VERIFY_SERVICE": false, "FLAG_SERVICE_MODEL_CACHE": true, "FLAG_ADVANCED_PORTS_FILTER": true, - MERGE_OBJECT_BY_PATH "FLAG_REGION_ID_FROM_REMOTE": true, "FLAG_ADD_MSO_TESTAPI_FIELD": true }, diff --git a/vid-webpack-master/src/app/shared/components/genericFormPopup/genericFormServices/network/network.popup.service.spec.ts b/vid-webpack-master/src/app/shared/components/genericFormPopup/genericFormServices/network/network.popup.service.spec.ts index 2a0a4c47e..67c371212 100644 --- a/vid-webpack-master/src/app/shared/components/genericFormPopup/genericFormServices/network/network.popup.service.spec.ts +++ b/vid-webpack-master/src/app/shared/components/genericFormPopup/genericFormServices/network/network.popup.service.spec.ts @@ -30,7 +30,6 @@ class MockReduxStore { "FLAG_SHOW_VERIFY_SERVICE": false, "FLAG_SERVICE_MODEL_CACHE": true, "FLAG_ADVANCED_PORTS_FILTER": true, - MERGE_OBJECT_BY_PATH "FLAG_REGION_ID_FROM_REMOTE": true, "FLAG_ADD_MSO_TESTAPI_FIELD": true }, diff --git a/vid-webpack-master/src/app/shared/components/genericFormPopup/genericFormServices/vnf/vnf.popup.service.spec.ts b/vid-webpack-master/src/app/shared/components/genericFormPopup/genericFormServices/vnf/vnf.popup.service.spec.ts index 8c90655d7..2f1904468 100644 --- a/vid-webpack-master/src/app/shared/components/genericFormPopup/genericFormServices/vnf/vnf.popup.service.spec.ts +++ b/vid-webpack-master/src/app/shared/components/genericFormPopup/genericFormServices/vnf/vnf.popup.service.spec.ts @@ -30,7 +30,6 @@ class MockReduxStore { "FLAG_SHOW_VERIFY_SERVICE": false, "FLAG_SERVICE_MODEL_CACHE": true, "FLAG_ADVANCED_PORTS_FILTER": true, - MERGE_OBJECT_BY_PATH "FLAG_REGION_ID_FROM_REMOTE": true, "FLAG_ADD_MSO_TESTAPI_FIELD": true }, diff --git a/vid-webpack-master/src/app/shared/pipes/searchFilter/search-filter.pipe.spec.ts b/vid-webpack-master/src/app/shared/pipes/searchFilter/search-filter.pipe.spec.ts new file mode 100644 index 000000000..cbf7324ac --- /dev/null +++ b/vid-webpack-master/src/app/shared/pipes/searchFilter/search-filter.pipe.spec.ts @@ -0,0 +1,17 @@ +import {SearchFilterPipe} from "./search-filter.pipe"; +import * as _ from 'lodash'; + +describe('Search filter pipe', () => { + + const items= [{'id':1, 'name': 'aaa'}, + {'id':12, 'name': 'bbb', 'children':{'first': 155, 'second': 2, 'third': 3}}, + {'id':3, 'name': 'ccc', 'children':{'first': 1, 'BbB': '3', 'third': 3}}, + {'id':4, 'name': 'aad', 'children':{'first': 1, 'second': 2, 'third': 3}}]; + + test('should return items contains substring bb', () => { + let filter = new SearchFilterPipe(); + let res:any[] = filter.transform(items,'bb'); + expect(_.map(res, 'name' )).toEqual(['bbb','ccc']); + }); + +}); diff --git a/vid-webpack-master/src/app/shared/pipes/searchFilter/search-filter.pipe.ts b/vid-webpack-master/src/app/shared/pipes/searchFilter/search-filter.pipe.ts new file mode 100644 index 000000000..725eacb53 --- /dev/null +++ b/vid-webpack-master/src/app/shared/pipes/searchFilter/search-filter.pipe.ts @@ -0,0 +1,14 @@ +import {Pipe, PipeTransform} from '@angular/core'; + +@Pipe({ + name: 'searchFilter' +}) +export class SearchFilterPipe implements PipeTransform { + transform(items: Object[], searchText: string): any[] { + if(!items) return []; + if(!searchText) return items; + return items.filter( item => { + return JSON.stringify(item).toLowerCase().includes(searchText.toLowerCase()); + }); + } +} diff --git a/vid-webpack-master/src/app/shared/services/featureFlag/feature-flags.service.ts b/vid-webpack-master/src/app/shared/services/featureFlag/feature-flags.service.ts index 518830dab..2fb39e8b9 100644 --- a/vid-webpack-master/src/app/shared/services/featureFlag/feature-flags.service.ts +++ b/vid-webpack-master/src/app/shared/services/featureFlag/feature-flags.service.ts @@ -13,6 +13,7 @@ export enum Features { FLAG_FLASH_REPLACE_VF_MODULE ='FLAG_FLASH_REPLACE_VF_MODULE', FLAG_FLASH_MORE_ACTIONS_BUTTON_IN_OLD_VIEW_EDIT ='FLAG_FLASH_MORE_ACTIONS_BUTTON_IN_OLD_VIEW_EDIT', FLAG_2002_VFM_UPGRADE_ADDITIONAL_OPTIONS ='FLAG_2002_VFM_UPGRADE_ADDITIONAL_OPTIONS', + FLAG_2004_INSTANTIATION_STATUS_FILTER ='FLAG_2004_INSTANTIATION_STATUS_FILTER', } @Injectable() diff --git a/vid-webpack-master/src/app/shared/shared.module.ts b/vid-webpack-master/src/app/shared/shared.module.ts index d246771af..b12ac435d 100644 --- a/vid-webpack-master/src/app/shared/shared.module.ts +++ b/vid-webpack-master/src/app/shared/shared.module.ts @@ -74,6 +74,7 @@ import {DynamicInputsComponent} from "./components/dynamic-inputs/dynamic-inputs import {DynamicInputLabelPipe} from "./pipes/dynamicInputLabel/dynamic-input-label.pipe"; import {ModelInformationService} from "./components/model-information/model-information.service"; import {MultiselectFormControlService} from "./components/formControls/component/multiselect/multiselect.formControl.service"; +import {SearchFilterPipe} from "./pipes/searchFilter/search-filter.pipe"; @NgModule({ @@ -114,6 +115,7 @@ import {MultiselectFormControlService} from "./components/formControls/component SafePipe, ObjectToArrayPipe, DataFilterPipe, + SearchFilterPipe, InputFormControlComponent, FormControlMessageErrorComponent, GenericFormPopupComponent, @@ -145,6 +147,7 @@ import {MultiselectFormControlService} from "./components/formControls/component SafePipe, ObjectToArrayPipe, DataFilterPipe, + SearchFilterPipe, InputFormControlComponent, FormControlMessageErrorComponent, GenericFormPopupComponent, @@ -196,6 +199,7 @@ import {MultiselectFormControlService} from "./components/formControls/component ElementsTableService, ErrorMsgService, DataFilterPipe, + SearchFilterPipe, ModelInformationService, MultiselectFormControlService ] -- cgit 1.2.3-korg