From 49aea04b9b084e928bc416db641cce83ecae94cc Mon Sep 17 00:00:00 2001 From: Maximilian Krambach Date: Mon, 11 Feb 2019 11:13:50 +0100 Subject: [PATCH] search users in list search by full name --- .../components/user-list/user-list.component.ts | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/client/src/app/site/users/components/user-list/user-list.component.ts b/client/src/app/site/users/components/user-list/user-list.component.ts index afab6453a..632c8c357 100644 --- a/client/src/app/site/users/components/user-list/user-list.component.ts +++ b/client/src/app/site/users/components/user-list/user-list.component.ts @@ -112,6 +112,7 @@ export class UserListComponent extends ListViewBaseComponent implement this.dataSource.data = sortedData; this.checkSelection(); }); + this.setFulltextFilter(); } /** @@ -305,4 +306,18 @@ export class UserListComponent extends ListViewBaseComponent implement viewUser.user.is_present = !viewUser.user.is_present; await this.repo.update(viewUser.user, viewUser); } + + /** + * Overwrites the dataSource's string filter with a case-insensitive search + * in the full_name property + */ + private setFulltextFilter(): void { + this.dataSource.filterPredicate = (data, filter) => { + if (!data || !data.full_name) { + return false; + } + filter = filter ? filter.toLowerCase() : ''; + return data.full_name.toLowerCase().indexOf(filter) >= 0; + }; + } }