Toggle Actor Type Filters

This commit is contained in:
Angelina Filippova 2020-10-16 00:58:34 +03:00
parent 4316028e41
commit 6b58b4f545

View file

@ -66,16 +66,27 @@ export default {
? currentFilters.push(this.$data.value[Math.max(indexOfActive, indexOfDeactivated, indexOfPending, indexOfUnconfirmed)])
: currentFilters
Math.max(indexOfPerson, indexOfService, indexOfApplication) > -1
? currentFilters.push(this.$data.value[Math.max(indexOfPerson, indexOfService, indexOfApplication)])
: currentFilters
const actorTypeFilters = [indexOfPerson, indexOfService, indexOfApplication].reduce((acc, index) => {
if (index > -1) {
currentFilters.push(this.$data.value[index])
acc.push(this.$data.value[index])
}
return acc
}, [])
return currentFilters
return [
currentFilters,
currentFilters.filter(filter => !actorTypeFilters.includes(filter)),
actorTypeFilters
]
},
toggleFilters() {
this.$data.value = this.removeOppositeFilters()
const currentFilters = this.$data.value.reduce((acc, filter) => ({ ...acc, [filter]: true }), {})
const [allFilters, filters, actorTypeFilters] = this.removeOppositeFilters()
this.$data.value = allFilters
const currentFilters = filters.reduce((acc, filter) => ({ ...acc, [filter]: true }), {})
this.$store.dispatch('ToggleUsersFilter', currentFilters)
this.$store.dispatch('ToggleActorTypeFilter', actorTypeFilters)
}
}
}