Skip to content

Commit

Permalink
Merge pull request #100 from hotwax/#2dmrnhx
Browse files Browse the repository at this point in the history
Fixed: product filters not updating on reset, logout and store change (#2dmrnhx)
  • Loading branch information
adityasharma7 authored May 27, 2022
2 parents e3fe574 + b7415ef commit 5e3de37
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 7 deletions.
5 changes: 4 additions & 1 deletion src/components/ProductFilterModal.vue
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,10 @@ export default defineComponent({
await this.store.dispatch('product/clearFilters', {
type: this.type,
id: this.searchfield,
value: []
value: {
list: [],
operator: 'OR'
}
})
this.isFilterChanged = true;
},
Expand Down
10 changes: 8 additions & 2 deletions src/store/modules/product/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,10 @@ const actions: ActionTree<ProductState, RootState> = {
async resetFilters({ commit, state, dispatch }, payload) {
const appliedFilters = JSON.parse(JSON.stringify((state.appliedFilters as any)[payload.type]))
const value = Object.keys(appliedFilters).reduce((value: any, filter: any) => {
value[filter] = []
value[filter] = {
list: [],
operator: "OR"
}
return value
}, {})
commit(types.PRODUCT_FILTERS_UPDATED, {type: payload.type, value})
Expand All @@ -128,7 +131,10 @@ const actions: ActionTree<ProductState, RootState> = {
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] = []
val[filter] = {
list: [],
operator: 'OR'
}
return val
}, {})
value[type] = val
Expand Down
8 changes: 4 additions & 4 deletions src/views/SelectProduct.vue
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@
<ion-item lines="none">
<ion-label>{{ $t("Operator") }}</ion-label>
<ion-select interface="popover" @ionChange="applyOperator('included', 'tags', $event.detail.value)" :value="appliedFilters['included']['tags'].operator">
<ion-select-option :value="AND">AND</ion-select-option>
<ion-select-option :value="OR">OR</ion-select-option>
<ion-select-option value="AND">AND</ion-select-option>
<ion-select-option value="OR">OR</ion-select-option>
</ion-select>
</ion-item>
<ion-card-content>
Expand Down Expand Up @@ -72,8 +72,8 @@
<ion-item lines="none">
<ion-label>{{ $t("Operator") }}</ion-label>
<ion-select @ionChange="applyOperator('excluded', 'tags', $event.detail.value)" interface="popover" :value="appliedFilters['excluded']['tags'].operator">
<ion-select-option :value="AND">AND</ion-select-option>
<ion-select-option :value="OR">OR</ion-select-option>
<ion-select-option value="AND">AND</ion-select-option>
<ion-select-option value="OR">OR</ion-select-option>
</ion-select>
</ion-item>
<ion-card-content>
Expand Down

0 comments on commit 5e3de37

Please sign in to comment.