From 02168b46d5614325afc1c5c6165b0bda3279e251 Mon Sep 17 00:00:00 2001 From: Swapnali Shadanan Pode Date: Wed, 20 Mar 2019 13:33:40 +0530 Subject: Search pipe Change-Id: I12067ff7e9e7a8aac1ea11328e8d0da08cb791f2 Issue-ID: CCSDK-804 Signed-off-by: sp00501638 --- cds-ui/client/src/app/common/shared/pipes/search.pipe.ts | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) (limited to 'cds-ui/client/src/app/common/shared') diff --git a/cds-ui/client/src/app/common/shared/pipes/search.pipe.ts b/cds-ui/client/src/app/common/shared/pipes/search.pipe.ts index 092531ee3..b0d37c3d1 100644 --- a/cds-ui/client/src/app/common/shared/pipes/search.pipe.ts +++ b/cds-ui/client/src/app/common/shared/pipes/search.pipe.ts @@ -26,11 +26,12 @@ import { Pipe, PipeTransform } from '@angular/core'; export class SearchPipe implements PipeTransform{ - transform(item: any, searchText: any): any { - if(searchText == null) return item; - - return item.filter(function(search){ - return search.type.toLowerCase().indexOf(searchText.toLowerCase()) > -1; - }) - } + transform(items: any[], searchText: string): any[] { + if(!items) return []; + if(!searchText) return items; + searchText = searchText.toLowerCase(); + return items.filter( it => { + return it.toLowerCase().includes(searchText); + }); + } } \ No newline at end of file -- cgit 1.2.3-korg