integrated thematique in serahc results
This commit is contained in:
@ -3,7 +3,11 @@
|
||||
import { MA } from 'vuejs/api/ma-axios'
|
||||
import qs from 'querystring-es3'
|
||||
|
||||
import materiauGQL from 'vuejs/api/gql/materiausearch.fragment.gql'
|
||||
|
||||
import { MGQ } from 'vuejs/api/graphql-axios'
|
||||
import { print } from 'graphql/language/printer'
|
||||
import gql from 'graphql-tag'
|
||||
import searchresultGQL from 'vuejs/api/gql/searchresults.fragment.gql'
|
||||
|
||||
export default {
|
||||
namespaced: true,
|
||||
@ -35,7 +39,7 @@ export default {
|
||||
resetUuids (state) {
|
||||
state.uuids = []
|
||||
},
|
||||
setMaterials (state, items) {
|
||||
setResults (state, items) {
|
||||
state.items = state.items.concat(items)
|
||||
},
|
||||
resetItems (state) {
|
||||
@ -110,18 +114,27 @@ export default {
|
||||
commit('setUuids', data.uuids)
|
||||
// loadMaterials is on mixins
|
||||
// https://github.com/huybuidac/vuex-extensions
|
||||
|
||||
dispatch('loadMaterialsGQL', {
|
||||
ids: data.nids,
|
||||
gqlfragment: materiauGQL,
|
||||
callBack: 'loadMaterialsCallBack'
|
||||
})
|
||||
|
||||
// dispatch('loadMaterials', {
|
||||
// uuids: data.uuids,
|
||||
// imgStyle: ['card_medium', 'card_full'],
|
||||
// callBack: 'loadMaterialsCallBack'
|
||||
// dispatch('loadMaterialsGQL', {
|
||||
// ids: data.nids,
|
||||
// gqlfragment: materiauGQL,
|
||||
// callBack: 'loadSearchResultsCallBack'
|
||||
// })
|
||||
let ast = gql`{
|
||||
searchresults(ids: [${data.nids}]) {
|
||||
...SearchResultFields
|
||||
}
|
||||
}
|
||||
${ searchresultGQL }
|
||||
`
|
||||
MGQ.post('', { query: print(ast) })
|
||||
.then(( resp ) => {
|
||||
console.log('loadSearchResultsGQL resp', resp )
|
||||
dispatch("loadSearchResultsCallBack", { items: resp.data.data.searchresults})
|
||||
})
|
||||
.catch(error => {
|
||||
console.warn('Issue with loadSearchResults', error)
|
||||
Promise.reject(error)
|
||||
})
|
||||
} else {
|
||||
commit('setNoresults')
|
||||
}
|
||||
@ -131,9 +144,9 @@ export default {
|
||||
Promise.reject(error)
|
||||
})
|
||||
},
|
||||
loadMaterialsCallBack ({ commit, state }, { items, callBackArgs }) {
|
||||
console.log('search loadMaterialsCallBack', items)
|
||||
commit('setMaterials', items)
|
||||
loadSearchResultsCallBack ({ commit, state }, { items, callBackArgs }) {
|
||||
console.log('search loadSearchResultsCallBack', items)
|
||||
commit('setResults', items)
|
||||
if (state.infiniteLoadingState) {
|
||||
if (state.offset + state.limit > state.count) {
|
||||
console.log('Search infinite completed')
|
||||
|
Reference in New Issue
Block a user