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