search filters ok, to be improved on results pertinance
This commit is contained in:
@ -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()
|
||||
|
Reference in New Issue
Block a user