Merge pull request #4295 from MaximilianKrambach/userSearchFix

search users in list search by full name
This commit is contained in:
Sean 2019-02-11 16:18:15 +01:00 committed by GitHub
commit 4d9adc291c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -112,6 +112,7 @@ export class UserListComponent extends ListViewBaseComponent<ViewUser> implement
this.dataSource.data = sortedData;
this.checkSelection();
});
this.setFulltextFilter();
}
/**
@ -305,4 +306,18 @@ export class UserListComponent extends ListViewBaseComponent<ViewUser> 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;
};
}
}