LoginBlock.vue 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. <script>
  2. import Vue from 'vue'
  3. import { mapState, mapActions } from 'vuex'
  4. import router from 'vuejs/route'
  5. export default {
  6. name: "LoginBlock",
  7. router,
  8. props: ['title', 'block'],
  9. data () {
  10. return {
  11. template: null,
  12. mail: '',
  13. password: ''
  14. }
  15. },
  16. computed: {
  17. ...mapState({
  18. loginMessage: state => state.User.loginMessage,
  19. // roles: state => state.User.roles,
  20. })
  21. },
  22. methods: {
  23. ...mapActions({
  24. userLogin: 'User/userLogin',
  25. openCloseHamMenu: 'Common/openCloseHamMenu'
  26. }),
  27. login () {
  28. this.userLogin({
  29. mail: this.mail,
  30. pass: this.password
  31. })
  32. // moved to user.js store
  33. // .then(() => {
  34. // console.log('LoginBlock user logged-in')
  35. // this.openCloseHamMenu(false)
  36. // this.$router.push({
  37. // name: 'base'
  38. // })
  39. // })
  40. }
  41. },
  42. beforeMount() {
  43. // console.log('LoginBlock beforeMount', this._props.block)
  44. if (this._props.block) {
  45. // console.log('LoginBlock beforeMount if this._props.block ok')
  46. this.template = Vue.compile(this._props.block)
  47. this.$options.staticRenderFns = [];
  48. this._staticTrees = [];
  49. this.template.staticRenderFns.map(fn => (this.$options.staticRenderFns.push(fn)));
  50. }
  51. },
  52. mounted(){
  53. // console.log('LoginBlock mounted')
  54. Drupal.attachBehaviors(this.$el);
  55. },
  56. render(h) {
  57. // console.log('LoginBlock render')
  58. if (!this.template) {
  59. // console.log('LoginBlock render NAN')
  60. return h('span', this.$t('default.Loading…'))
  61. } else {
  62. // console.log('LoginBlock render template')
  63. return this.template.render.call(this)
  64. }
  65. }
  66. }
  67. </script>
  68. <style lang="scss" scoped>
  69. // section{
  70. // max-width:300px;
  71. // }
  72. // input{
  73. // display:block;
  74. // max-width:100%;
  75. // margin:0.5em 0 0 0;
  76. // }
  77. // button{
  78. // margin:0.5em 0 0 0;
  79. // }
  80. // ul{
  81. // margin:0; padding:0.5em 0 0 0;
  82. // }
  83. // li{
  84. // list-style:none;
  85. // margin:0.5em 0 0 0; padding:0;
  86. // font-size:0.882em;
  87. // }
  88. // a{
  89. // }
  90. </style>