Allow filtering by all member statuses in member list view

This commit is contained in:
Patrick Smith
2018-11-12 17:11:45 -05:00
parent 947106a5b1
commit 990c24b802
5 changed files with 32 additions and 11 deletions

View File

@@ -11,12 +11,14 @@ const search = (query, members) => {
}
}
const filterByStatus = (status, members) => {
const filterByStatus = (status, statusesByDisplayName, members) => {
const getStatusFromDisplayName = (_status) => statusesByDisplayName[_status].name
if (status === '' || status === 'all') {
return members
} else {
return members.filter(
(member) => member.status.toLowerCase() === status
(member) => getStatusFromDisplayName(member.status) === status
)
}
}
@@ -52,6 +54,7 @@ export default {
props: {
members: Array,
role_choices: Array,
status_choices: Array,
},
data: function () {
@@ -90,6 +93,7 @@ export default {
return {
searchValue: '',
status: '',
statusesByDisplayName: indexBy(prop('display_name'), this.status_choices),
role: '',
rolesByDisplayName: indexBy(prop('display_name'), this.role_choices),
sortInfo: {
@@ -104,7 +108,7 @@ export default {
searchedList: function () {
return pipe(
partial(search, [this.searchValue]),
partial(filterByStatus, [this.status]),
partial(filterByStatus, [this.status, this.statusesByDisplayName]),
partial(filterByRole, [this.role, this.rolesByDisplayName]),
partial(sort, [this.sortInfo])
)(this.members)