search users in list search by full name

This commit is contained in:
Maximilian Krambach 2019-02-11 11:13:50 +01:00
parent 79aaa949ae
commit 49aea04b9b

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;
};
}
}