handled home loading if not available in dom (if drupalSettings.path.isFront == false)
This commit is contained in:
@@ -1,45 +1,25 @@
|
||||
|
||||
<script>
|
||||
|
||||
import Vue from 'vue'
|
||||
import { MA } from 'vuejs/api/ma-axios'
|
||||
|
||||
export default {
|
||||
props: ['html'], // get the html from parent with props
|
||||
data() {
|
||||
return {
|
||||
template_src: null, // record the prop into data as it will be available in every hooks
|
||||
template: null // compiled template from html used in render
|
||||
}
|
||||
},
|
||||
beforeMount() {
|
||||
// console.log('Home beforeMount this.html', this.html);
|
||||
if(!this.template_src){
|
||||
if(this.html){ // if html prop is available record it has data
|
||||
this.template_src = this.html
|
||||
}else{ // else get it from ajax (e.g. if we didn't load the page from home)
|
||||
this.getHomeHtml()
|
||||
}
|
||||
}
|
||||
// console.log('Home beforeMount');
|
||||
// compile the html src (coming from parent with props or from ajax call)
|
||||
if(this.template_src){
|
||||
this.template = Vue.compile(this.template_src)
|
||||
if(this.html){
|
||||
// console.log('html', this.html);
|
||||
this.template = Vue.compile(this.html)
|
||||
this.$options.staticRenderFns = []
|
||||
this._staticTrees = []
|
||||
this.template.staticRenderFns.map(fn => (this.$options.staticRenderFns.push(fn)))
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
getHomeHtml(){
|
||||
MA.get(`/materio_user/login_block`)
|
||||
.then(({data}) => {
|
||||
this.template_src = data.rendered // record the html src into data
|
||||
})
|
||||
.catch(( error ) => {
|
||||
console.warn('Issue with getHomeHtml', error)
|
||||
})
|
||||
}
|
||||
},
|
||||
render(h) {
|
||||
if(!this.template){
|
||||
return h('span', 'Loading ...')
|
||||
|
||||
Reference in New Issue
Block a user