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,
|
2021-04-01 21:17:25 +02:00
|
|
|
// roles: state => state.User.roles,
|
2021-01-27 22:49:52 +01:00
|
|
|
})
|
|
|
|
},
|
2019-05-31 23:05:37 +02:00
|
|
|
methods: {
|
|
|
|
...mapActions({
|
2021-03-29 22:28:24 +02:00
|
|
|
userLogin: 'User/userLogin',
|
|
|
|
openCloseHamMenu: 'Common/openCloseHamMenu'
|
2019-05-31 23:05:37 +02:00
|
|
|
}),
|
|
|
|
login () {
|
|
|
|
this.userLogin({
|
|
|
|
mail: this.mail,
|
|
|
|
pass: this.password
|
|
|
|
})
|
2021-04-01 21:17:25 +02:00
|
|
|
// moved to user.js store
|
|
|
|
// .then(() => {
|
|
|
|
// console.log('LoginBlock user logged-in')
|
|
|
|
// this.openCloseHamMenu(false)
|
|
|
|
// this.$router.push({
|
|
|
|
// name: 'base'
|
|
|
|
// })
|
|
|
|
// })
|
2019-05-31 23:05:37 +02:00
|
|
|
}
|
|
|
|
},
|
|
|
|
beforeMount() {
|
2021-03-31 18:42:05 +02:00
|
|
|
// console.log('LoginBlock beforeMount', this._props.block)
|
|
|
|
if (this._props.block) {
|
|
|
|
// console.log('LoginBlock beforeMount if this._props.block ok')
|
2019-05-31 23:05:37 +02:00
|
|
|
this.template = Vue.compile(this._props.block)
|
|
|
|
this.$options.staticRenderFns = [];
|
|
|
|
this._staticTrees = [];
|
|
|
|
this.template.staticRenderFns.map(fn => (this.$options.staticRenderFns.push(fn)));
|
|
|
|
}
|
|
|
|
},
|
|
|
|
mounted(){
|
2021-03-31 18:42:05 +02:00
|
|
|
// console.log('LoginBlock mounted')
|
2019-05-31 23:05:37 +02:00
|
|
|
Drupal.attachBehaviors(this.$el);
|
|
|
|
},
|
|
|
|
render(h) {
|
2021-03-31 18:42:05 +02:00
|
|
|
// console.log('LoginBlock render')
|
|
|
|
if (!this.template) {
|
|
|
|
// console.log('LoginBlock render NAN')
|
2021-06-01 22:46:15 +02:00
|
|
|
return h('span', this.$t('default.Loading…'))
|
2021-03-31 18:42:05 +02:00
|
|
|
} else {
|
|
|
|
// console.log('LoginBlock render template')
|
2019-05-31 23:05:37 +02:00
|
|
|
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>
|