SearchForm.vue 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. <script>
  2. import Vue from 'vue'
  3. import { MSAPI } from 'vuejs/api/msapi-axios'
  4. export default {
  5. data() {
  6. return {
  7. template: null,
  8. typed: ""
  9. }
  10. },
  11. props: ['form'],
  12. methods: {
  13. keyup() {
  14. console.log("search typed", this.typed);
  15. },
  16. submit() {
  17. console.log("search clicked");
  18. }
  19. },
  20. beforeMount() {
  21. console.log('SearchForm beforeMount');
  22. if(this._props.form){
  23. console.log('SearchForm beforeMount if this._props.form ok');
  24. this.template = Vue.compile(this._props.form).render
  25. }
  26. },
  27. beforeUpdate() {
  28. console.log('SearchForm beforeUpdate');
  29. if(this._props.form){
  30. console.log('SearchForm beforeUpdate if this._props.form ok');
  31. this.template = Vue.compile(this._props.form).render
  32. }
  33. },
  34. mounted(){
  35. console.log('SearchForm mounted');
  36. // Drupal.attachBehaviors(this.$el);
  37. },
  38. updated(){
  39. console.log('SearchForm updated');
  40. // Drupal.attachBehaviors(this.$el);
  41. },
  42. render(h) {
  43. console.log('searchForm render');
  44. if(!this.template){
  45. return h('span', 'Loading ...')
  46. }else{
  47. return this.template()
  48. }
  49. }
  50. }
  51. // searchform: (resolve, reject) => (
  52. // MSAPI.get(`/search_form`)
  53. // .then(({data}) => {
  54. // // console.log("materiosapisearchform", data);
  55. // resolve({
  56. // data() {
  57. // return {
  58. // typed:""
  59. // }
  60. // },
  61. // methods: {
  62. // keyup() {
  63. // console.log("search typed", this.typed);
  64. // },
  65. // submit() {
  66. // console.log("search clicked");
  67. // }
  68. // },
  69. // mounted() {
  70. // Drupal.attachBehaviors(this.$el);
  71. // },
  72. // template: data.rendered
  73. // })
  74. // })
  75. // .catch(( error ) => {
  76. // console.warn('Issue with get searchform', error)
  77. // Promise.reject(error)
  78. // })
  79. //
  80. // )
  81. </script>
  82. <style lang="scss" scoped>
  83. </style>