2019-05-31 23:05:37 +02:00
|
|
|
<script>
|
|
|
|
|
|
|
|
import Vue from 'vue'
|
|
|
|
import { mapState, mapActions } from 'vuex'
|
2021-01-19 16:38:26 +01:00
|
|
|
import router from 'vuejs/route'
|
2019-05-31 23:05:37 +02:00
|
|
|
|
|
|
|
export default {
|
2021-01-19 16:38:26 +01:00
|
|
|
name: "LoginBlock",
|
|
|
|
router,
|
2019-05-31 23:05:37 +02:00
|
|
|
props: ['title', 'block'],
|
|
|
|
data () {
|
|
|
|
return {
|
|
|
|
template: null,
|
|
|
|
mail: '',
|
|
|
|
password: ''
|
|
|
|
}
|
|
|
|
},
|
2021-01-27 22:49:52 +01:00
|
|
|
computed: {
|
|
|
|
...mapState({
|
|
|
|
loginMessage: state => state.User.loginMessage,
|
|
|
|
})
|
|
|
|
},
|
2019-05-31 23:05:37 +02:00
|
|
|
methods: {
|
|
|
|
...mapActions({
|
|
|
|
userLogin: 'User/userLogin'
|
|
|
|
}),
|
|
|
|
login () {
|
|
|
|
this.userLogin({
|
|
|
|
mail: this.mail,
|
|
|
|
pass: this.password
|
2021-01-19 16:38:26 +01:00
|
|
|
}).then(() => {
|
|
|
|
console.log("LoginBlock user logged-in")
|
|
|
|
this.$router.push({
|
|
|
|
name: 'base'
|
|
|
|
})
|
2019-05-31 23:05:37 +02:00
|
|
|
})
|
|
|
|
}
|
|
|
|
},
|
|
|
|
beforeMount() {
|
2019-06-01 16:15:08 +02:00
|
|
|
// console.log('LoginBlock beforeMount', this._props.block);
|
2019-05-31 23:05:37 +02:00
|
|
|
if(this._props.block){
|
|
|
|
// console.log('LoginBlock beforeMount if this._props.block ok');
|
|
|
|
this.template = Vue.compile(this._props.block)
|
|
|
|
this.$options.staticRenderFns = [];
|
|
|
|
this._staticTrees = [];
|
|
|
|
this.template.staticRenderFns.map(fn => (this.$options.staticRenderFns.push(fn)));
|
|
|
|
}
|
|
|
|
},
|
|
|
|
mounted(){
|
|
|
|
// console.log('LoginBlock mounted');
|
|
|
|
Drupal.attachBehaviors(this.$el);
|
|
|
|
},
|
|
|
|
render(h) {
|
|
|
|
// console.log('LoginBlock render');
|
|
|
|
if(!this.template){
|
|
|
|
// console.log('LoginBlock render NAN');
|
|
|
|
return h('span', 'Loading ...')
|
|
|
|
}else{
|
|
|
|
// console.log('LoginBlock render template');
|
|
|
|
return this.template.render.call(this)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<style lang="scss" scoped>
|
|
|
|
// section{
|
|
|
|
// max-width:300px;
|
|
|
|
// }
|
|
|
|
// input{
|
|
|
|
// display:block;
|
|
|
|
// max-width:100%;
|
|
|
|
// margin:0.5em 0 0 0;
|
|
|
|
// }
|
|
|
|
// button{
|
|
|
|
// margin:0.5em 0 0 0;
|
|
|
|
// }
|
|
|
|
// ul{
|
|
|
|
// margin:0; padding:0.5em 0 0 0;
|
|
|
|
// }
|
|
|
|
// li{
|
|
|
|
// list-style:none;
|
|
|
|
// margin:0.5em 0 0 0; padding:0;
|
|
|
|
// font-size:0.882em;
|
|
|
|
// }
|
|
|
|
// a{
|
|
|
|
// }
|
|
|
|
</style>
|