dropdown search types ok, added type param to search query
This commit is contained in:
@@ -16,7 +16,7 @@
|
||||
type="select"
|
||||
placeholder="dans ..."
|
||||
append-to-body
|
||||
:calculate-position="withPopper"
|
||||
:calculate-position="dropDownMenuPos"
|
||||
:options="searchTypeOptions"
|
||||
:clearable="false"
|
||||
:value="searchTypeValue"
|
||||
@@ -68,13 +68,6 @@ import { mapActions, mapState } from 'vuex'
|
||||
export default {
|
||||
name: 'Search',
|
||||
data: () => ({
|
||||
searchTypeOptions: [
|
||||
{ 'code': 'text', 'label': 'Dans les textes' },
|
||||
{ 'code': 'nominum', 'label': 'Dans les personnes' },
|
||||
{ 'code': 'locorum', 'label': 'Dans les lieux' },
|
||||
{ 'code': 'operum', 'label': 'Dans les objets' }
|
||||
],
|
||||
searchTypeValue: { 'code': 'text', 'label': 'Dans les textes' }
|
||||
}),
|
||||
computed: {
|
||||
keys: {
|
||||
@@ -82,18 +75,21 @@ export default {
|
||||
set (value) { this.$store.commit('Search/setKeys', value) }
|
||||
},
|
||||
...mapState({
|
||||
isloading: state => state.Search.isloading
|
||||
isloading: state => state.Search.isloading,
|
||||
searchTypeOptions: state => state.Search.searchTypeOptions,
|
||||
searchTypeValue: state => state.Search.searchTypeValue
|
||||
})
|
||||
},
|
||||
methods: {
|
||||
...mapActions({
|
||||
getResults: 'Search/getResults'
|
||||
getResults: 'Search/getResults',
|
||||
setSearchTypeValue: 'Search/setSearchTypeValue'
|
||||
}),
|
||||
submit () {
|
||||
console.log('submited', this.keys)
|
||||
this.getResults()
|
||||
},
|
||||
withPopper (dropdownList, component, { width }) {
|
||||
dropDownMenuPos (dropdownList, component, { width }) {
|
||||
/**
|
||||
* We need to explicitly define the dropdown width since
|
||||
* it is usually inherited from the parent with CSS.
|
||||
@@ -137,7 +133,7 @@ export default {
|
||||
},
|
||||
onSearchTypeSelected (e) {
|
||||
console.log('onSearchTypeSelected', e)
|
||||
this.searchTypeValue = e
|
||||
this.setSearchTypeValue(e)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,6 +7,13 @@ export default {
|
||||
// initial state
|
||||
state: {
|
||||
keys: '',
|
||||
searchTypeOptions: [
|
||||
{ 'code': 'text', 'label': 'Dans les textes' },
|
||||
{ 'code': 'persons', 'label': 'Dans les personnes' },
|
||||
{ 'code': 'places', 'label': 'Dans les lieux' },
|
||||
{ 'code': 'objects', 'label': 'Dans les objets' }
|
||||
],
|
||||
searchTypeValue: { 'code': 'text', 'label': 'Dans les textes' },
|
||||
results: [],
|
||||
isloading: false,
|
||||
opened: false
|
||||
@@ -28,6 +35,9 @@ export default {
|
||||
},
|
||||
setOpened (state, opened) {
|
||||
state.opened = opened
|
||||
},
|
||||
setSearchTypeValue (state, value) {
|
||||
state.searchTypeValue = value
|
||||
}
|
||||
},
|
||||
|
||||
@@ -39,6 +49,10 @@ export default {
|
||||
let params = {
|
||||
search: state.keys
|
||||
}
|
||||
if (state.searchTypeValue.code !== 'text') {
|
||||
params.type = state.searchTypeValue.code
|
||||
}
|
||||
|
||||
// console.log('Search getResults params', params);
|
||||
let q = qs.stringify(params)
|
||||
return REST.get(`${window.apipath}/search?` + q)
|
||||
@@ -53,6 +67,9 @@ export default {
|
||||
commit('setIsloading', false)
|
||||
Promise.reject(error)
|
||||
})
|
||||
},
|
||||
setSearchTypeValue ({ dispatch, commit, state }, value) {
|
||||
commit('setSearchTypeValue', value)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user