Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed: issue of tags not working when having special character in them and cleared the filters applied on logout(#2a7yged) #67

Merged
merged 5 commits into from
May 10, 2022
2 changes: 0 additions & 2 deletions src/store/modules/job/getters.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
import { GetterTree } from 'vuex'
import JobState from './JobState'
import RootState from '../../RootState'
import { JobService } from '@/services/JobService';
import { State } from '@ionic/core/dist/types/stencil-public-runtime';

const getters: GetterTree <JobState, RootState> = {
getJobStatus: (state) => (id: string): any => {
Expand Down
23 changes: 21 additions & 2 deletions src/store/modules/product/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,12 +87,18 @@ const actions: ActionTree<ProductState, RootState> = {
}

state.query.json['filter'] = Object.keys(state.appliedFilters.included).reduce((filter, value) => {
(state.appliedFilters.included as any)[value].length > 0 && filter.push(`${value}: (${(state.appliedFilters.included as any)[value].join(' OR ')})`)
const filterValues = (state.appliedFilters.included as any)[value]
if (filterValues.length > 0) {
filter.push(`${value}: ("${filterValues.join('" OR "')}")`)
}
return filter
}, state.query.json['filter'])

state.query.json['filter'] = Object.keys(state.appliedFilters.excluded).reduce((filter, value) => {
(state.appliedFilters.excluded as any)[value].length > 0 && filter.push(`-${value}: (${(state.appliedFilters.excluded as any)[value].join(' OR ')})`)
const filterValues = (state.appliedFilters.excluded as any)[value]
if (filterValues.length > 0) {
filter.push(`-${value}: ("${filterValues.join('" OR "')}")`)
}
return filter
}, state.query.json['filter'])

Expand All @@ -110,6 +116,19 @@ const actions: ActionTree<ProductState, RootState> = {
await dispatch('updateQuery')
},

async clearAllFilters({ commit, state }) {
const appliedFilters = JSON.parse(JSON.stringify(state.appliedFilters))
const value = Object.keys(appliedFilters).reduce((value: any, type: any) => {
const val = Object.keys(appliedFilters[type]).reduce((val: any, filter: any) => {
val[filter] = []
return val
}, {})
value[type] = val
return value
}, {})
commit(types.PRODUCT_ALL_FILTERS_UPDATED, value)
},

async clearFilters({ commit, dispatch }, payload) {
commit(types.PRODUCT_FILTER_UPDATED, {id: payload.id, type: payload.type, value: payload.value})
await dispatch('updateQuery')
Expand Down
1 change: 1 addition & 0 deletions src/store/modules/product/mutation-types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ export const PRODUCT_LIST_UPDATED = SN_PRODUCT + '/LIST_UPDATED'
export const PRODUCT_FILTER_UPDATED = SN_PRODUCT + '/FILTER_UPDATED'
export const PRODUCT_QUERY_UPDATED = SN_PRODUCT + '/QUERY_UPDATED'
export const PRODUCT_FILTERS_UPDATED = SN_PRODUCT + '/FILTERS_UPDATED'
export const PRODUCT_ALL_FILTERS_UPDATED = SN_PRODUCT + '/ALL_FILTERS_UPDATED'
3 changes: 3 additions & 0 deletions src/store/modules/product/mutations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ const mutations: MutationTree <ProductState> = {
},
[types.PRODUCT_FILTERS_UPDATED] (state, payload) {
(state.appliedFilters as any)[payload.type] = payload.value
},
[types.PRODUCT_ALL_FILTERS_UPDATED] (state, payload) {
state.appliedFilters = payload
}
}
export default mutations;
1 change: 1 addition & 0 deletions src/store/modules/user/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ const actions: ActionTree<UserState, RootState> = {
async logout ({ commit }) {
// TODO add any other tasks if need
commit(types.USER_END_SESSION)
this.dispatch('product/clearAllFilters')
this.dispatch('product/clearProductList');
},

Expand Down