replaced path+route_load navigation by id nav for articles and thematiques

This commit is contained in:
2021-03-06 16:46:19 +01:00
parent 651315c319
commit 8dadb8d3a5
7 changed files with 62 additions and 68 deletions

View File

@@ -169,33 +169,23 @@ export default {
getPrevNextItems: 'Blabla/getPrevNextItems'
}),
getArticle(){
console.log(this.$route);
// get the article uuid
// if(this.$route.query.nid){
// // we come from internal link with vuejs
// // directly record uuid
// this.nid = this.$route.query.nid
//
// }else if(drupalDecoupled.entity_type == 'node' && drupalDecoupled.entity_bundle == 'article'){
// // we landed in an internal page
// // get the uuid from drupalDeclouped, provided by materio_decoupled.module
// this.nid = drupalDecoupled.entity_id
// }
if (this.$route.path) {
console.log('getArticle', this.$route);
if (this.$route.params.id) {
// we come from internal link with vuejs
this.path = this.$route.path
} else {
// using path to load from route is hasardous
// this.path = this.$route.path
this.id = this.$route.params.id
}else if(drupalDecoupled.entity_type == 'node' && drupalDecoupled.entity_bundle == 'article'){
// we landed in an internal page
this.path = window.location.pathname
// get the id from drupalDeclouped, provided by materio_decoupled.module
this.id = drupalDecoupled.entity_id
}
if(this.path){
if(this.id){
this.loadArticle()
}else{
// if for any reason we dont have the uuid
// redirect to home
this.$route.replace('home')
// if for any reason we dont have the id redirect to home
this.$router.replace({name:'home'})
}
},
getIndex(){
@@ -213,7 +203,7 @@ export default {
this.loading = true
let ast = gql`{
route(path: "${this.path}", lang: "${drupalDecoupled.lang_code}") {
article(id: ${this.id}, lang: "${drupalDecoupled.lang_code}") {
...ArticleFields
}
}
@@ -221,9 +211,9 @@ export default {
`
MGQ.post('', { query: print(ast)
})
.then(({ data:{data:{route}}}) => {
console.log('loadArticle', route )
this.parseDataGQL(route)
.then(({ data:{data:{article}}}) => {
console.log('loadArticle', article )
this.parseDataGQL(article)
})
.catch(error => {
console.warn('Issue with loadArticle', error)