diff --git a/src/store/modules/users.js b/src/store/modules/users.js index 6b93fb2a..7bacb907 100644 --- a/src/store/modules/users.js +++ b/src/store/modules/users.js @@ -32,14 +32,7 @@ const users = { currentPage: 1, pageSize: 50, actorTypeFilters: [], - filters: { - local: false, - external: false, - active: false, - need_approval: false, - deactivated: false, - unconfirmed: false - }, + filters: [], passwordResetToken: { token: '', link: '' @@ -153,14 +146,7 @@ const users = { }, ClearUsersState({ commit }) { commit('SET_SEARCH_QUERY', '') - commit('SET_USERS_FILTERS', - { local: false, - external: false, - active: false, - need_approval: false, - deactivated: false, - unconfirmed: false - }) + commit('SET_USERS_FILTERS', []) }, async ClearFilters({ commit, dispatch, state }) { commit('CLEAR_USERS_FILTERS') @@ -251,7 +237,7 @@ const users = { }, async FetchUsers({ commit, dispatch, getters, state }, { page }) { commit('SET_LOADING', true) - const filters = Object.keys(state.filters).filter(filter => state.filters[filter]).join() + const filters = state.filters.join() const response = await fetchUsers(filters, state.actorTypeFilters, getters.authHost, getters.token, page) await dispatch('GetNodeInfo') loadUsers(commit, page, response.data) @@ -302,7 +288,7 @@ const users = { commit('SET_LOADING', true) commit('SET_SEARCH_QUERY', query) - const filters = Object.keys(state.filters).filter(filter => state.filters[filter]).join() + const filters = state.filters.join() const response = await searchUsers(query, filters, state.actorTypeFilters, getters.authHost, getters.token, page) loadUsers(commit, page, response.data) @@ -319,16 +305,7 @@ const users = { dispatch('SearchUsers', { query: state.searchQuery, page: 1 }) }, async ToggleUsersFilter({ commit, dispatch, state }, filters) { - const defaultFilters = { - local: false, - external: false, - active: false, - need_approval: false, - deactivated: false, - unconfirmed: false - } - const currentFilters = { ...defaultFilters, ...filters } - commit('SET_USERS_FILTERS', currentFilters) + commit('SET_USERS_FILTERS', filters) dispatch('SearchUsers', { query: state.searchQuery, page: 1 }) }, async UpdateActorType({ dispatch, getters }, { user, type, _userId, _statusId }) { diff --git a/src/views/users/components/UsersFilter.vue b/src/views/users/components/UsersFilter.vue index f624a508..f4a59462 100644 --- a/src/views/users/components/UsersFilter.vue +++ b/src/views/users/components/UsersFilter.vue @@ -37,12 +37,10 @@ export default { } }, created() { - const currentFilters = this.$data.value.reduce((acc, filter) => ({ ...acc, [filter]: true }), {}) - this.$store.dispatch('ToggleUsersFilter', currentFilters) + this.$store.dispatch('ToggleUsersFilter', this.$data.value) }, methods: { removeOppositeFilters() { - const filtersQuantity = Object.keys(this.$store.state.users.filters).length const currentFilters = [] const indexOfLocal = this.$data.value.indexOf('local') const indexOfExternal = this.$data.value.indexOf('external') @@ -54,10 +52,6 @@ export default { const indexOfService = this.$data.value.indexOf('Service') const indexOfApplication = this.$data.value.indexOf('Application') - if (this.$data.value.length === filtersQuantity) { - return [] - } - Math.max(indexOfLocal, indexOfExternal) > -1 ? currentFilters.push(this.$data.value[Math.max(indexOfLocal, indexOfExternal)]) : currentFilters @@ -84,8 +78,7 @@ export default { 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('ToggleUsersFilter', filters) this.$store.dispatch('ToggleActorTypeFilter', actorTypeFilters) } } diff --git a/src/views/users/index.vue b/src/views/users/index.vue index 5345034a..2ea7fa7f 100644 --- a/src/views/users/index.vue +++ b/src/views/users/index.vue @@ -249,6 +249,9 @@ export default { usersCount() { return this.$store.state.users.totalUsersCount }, + pendingView() { + return this.$store.state.users.filters.includes('need_approval') + }, width() { return this.isMobile ? 55 : false }