search filters ok, to be improved on results pertinance

This commit is contained in:
2021-04-05 12:45:58 +02:00
parent fd8237037a
commit 8008217444
8 changed files with 107 additions and 25 deletions

View File

@ -65,24 +65,34 @@ export default {
// at first page load or first route entering launch a search if params exists in url query
console.log('Base created() location',window.location)
let params = new URLSearchParams(window.location.search)
if (params.has('keys') || params.has('term')) {
if (params.has('keys')) {
this.$store.commit('Search/setKeys', params.get('keys'))
this.$store.commit('Search/setTerm', params.get('term'))
this.pagetitle = params.get('keys')
this.newSearch()
} else {
// load default base page
this.$store.commit('Search/setKeys', '')
this.$store.commit('Search/setTerm', '')
this.pagetitle = 'Base'
this.newSearch()
}
if (params.has('term')) {
this.$store.commit('Search/setTerm', params.get('term'))
} else {
this.$store.commit('Search/setTerm', '')
}
if (params.has('filters')) {
this.$store.commit('Search/setFilters', params.get('filters').split(','))
} else {
this.$store.commit('Search/setFilters', [])
}
this.newSearch()
},
beforeRouteUpdate (to, from, next) {
// when query change launch a new search
console.log('Base beforeRouteUpdate', to, from, next)
this.$store.commit('Search/setKeys', to.query.keys)
this.$store.commit('Search/setTerm', to.query.term)
this.$store.commit('Search/setFilters', to.query.filters)
this.pagetitle = to.query.keys
this.newSearch()
next()