diff options
author | Dan Timoney <dtimoney@att.com> | 2019-03-21 13:22:22 +0000 |
---|---|---|
committer | Gerrit Code Review <gerrit@onap.org> | 2019-03-21 13:22:22 +0000 |
commit | aa3e4974775f1c93d98ac1a569dfa53131731d0b (patch) | |
tree | 5dbfa84c9d903ece3bef090fd0e67aaeae2112f4 /cds-ui/client/src | |
parent | 232706f023aa052eff928f23e6fabf32d7895c1b (diff) | |
parent | 02168b46d5614325afc1c5c6165b0bda3279e251 (diff) |
Merge "Search pipe"
Diffstat (limited to 'cds-ui/client/src')
-rw-r--r-- | cds-ui/client/src/app/common/shared/pipes/search.pipe.ts | 15 |
1 files changed, 8 insertions, 7 deletions
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 |