Update function that removes opposite filters to work with need_approval filter

This commit is contained in:
Angelina Filippova 2020-08-10 01:59:00 +03:00
parent 6bf096b4c8
commit c9ce3cf231

View file

@ -37,20 +37,25 @@ export default {
methods: { methods: {
removeOppositeFilters() { removeOppositeFilters() {
const filtersQuantity = Object.keys(this.$store.state.users.filters).length const filtersQuantity = Object.keys(this.$store.state.users.filters).length
const currentFilters = this.$data.value.slice() const currentFilters = []
const indexOfLocal = currentFilters.indexOf('local') const indexOfLocal = this.$data.value.indexOf('local')
const indexOfExternal = currentFilters.indexOf('external') const indexOfExternal = this.$data.value.indexOf('external')
const indexOfActive = currentFilters.indexOf('active') const indexOfActive = this.$data.value.indexOf('active')
const indexOfDeactivated = currentFilters.indexOf('deactivated') const indexOfDeactivated = this.$data.value.indexOf('deactivated')
if (currentFilters.length === filtersQuantity) { const indexOfPending = this.$data.value.indexOf('need_approval')
if (this.$data.value.length === filtersQuantity) {
return [] return []
} else if (indexOfLocal > -1 && indexOfExternal > -1) {
const filterToRemove = indexOfLocal > indexOfExternal ? indexOfExternal : indexOfLocal
currentFilters.splice(filterToRemove, 1)
} else if (indexOfActive > -1 && indexOfDeactivated > -1) {
const filterToRemove = indexOfActive > indexOfDeactivated ? indexOfDeactivated : indexOfActive
currentFilters.splice(filterToRemove, 1)
} }
Math.max(indexOfLocal, indexOfExternal) > -1
? currentFilters.push(this.$data.value[Math.max(indexOfLocal, indexOfExternal)])
: currentFilters
Math.max(indexOfActive, indexOfDeactivated, indexOfPending) > -1
? currentFilters.push(this.$data.value[Math.max(indexOfActive, indexOfDeactivated, indexOfPending)])
: currentFilters
return currentFilters return currentFilters
}, },
toggleFilters() { toggleFilters() {