Skip to content

Commit

Permalink
fix: don't add default filter inGET params
Browse files Browse the repository at this point in the history
  • Loading branch information
popstas committed Dec 24, 2020
1 parent 50c378b commit 5f6a15d
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions pages/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,10 @@ export default {
return this.$store.state.filterPresets;
},
defaultFilter() {
return this.filterPresets.find(filter => filter.default) || {};
},
columnPresets() {
return this.$store.state.columnPresets;
},
Expand Down Expand Up @@ -531,8 +535,12 @@ export default {
// disable on `scan` route
if ($nuxt.$route.name !== 'index') return;
// don't add default filter
let query = {};
if (this.q) query.q = this.q;
if (this.q && this.q !== this.defaultFilter.q){
query.q = this.q;
}
if (updateFields) query.fields = this.columns.join(",");
// don't add default json url
Expand Down Expand Up @@ -734,9 +742,8 @@ export default {
this.$store.dispatch("items", itemsJson.items);
// filter
const defaultFilter = itemsJson.filters.find(filter => filter.default);
if (defaultFilter && !this.$route.query["q"]) {
this.$route.query["q"] = defaultFilter.q;
if (this.defaultFilter && !this.$route.query["q"]) {
this.$route.query["q"] = this.defaultFilter.q;
}
// q
Expand Down

0 comments on commit 5f6a15d

Please sign in to comment.