materio-d9/web/themes/custom/materiotheme/vuejs/components/Block/UserBlock.vue

58 lines
1.1 KiB
Vue
Raw Permalink Normal View History

2019-04-10 10:47:45 +02:00
<template lang="html">
<UserTools v-if="isloggedin" />
<LoginBlock v-bind:title="title" v-bind:block="block" v-else/>
2019-04-10 10:47:45 +02:00
</template>
<script>
import { mapState, mapActions } from 'vuex'
import LoginBlock from 'vuejs/components/Block/LoginBlock'
2019-04-10 10:47:45 +02:00
import UserTools from 'vuejs/components/User/UserTools'
import MA from 'vuejs/api/ma-axios'
2019-04-10 10:47:45 +02:00
export default {
props: ['title', 'loginblock'],
data(){
return {
block: null
}
},
2019-04-10 10:47:45 +02:00
computed: {
...mapState({
isloggedin: state => state.User.isloggedin
2019-04-10 10:47:45 +02:00
})
},
beforeMount() {
console.log('UserBlock beforeMount')
if (this.loginblock) {
this.block = this.loginblock
} else {
this.getLoginBlock()
}
},
methods: {
getLoginBlock(){
MA.get(`/materio_user/login_block`)
.then(({data}) => {
// console.log("getLoginBlock data", data)
this.block = data.rendered
})
.catch((error) => {
console.warn('Issue with getLoginBlock', error)
})
}
},
2019-04-10 10:47:45 +02:00
components: {
LoginBlock,
2019-04-10 10:47:45 +02:00
UserTools
}
}
</script>
<style lang="css" scoped>
</style>