Guest User

Untitled

a guest
Nov 19th, 2017
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.02 KB | None | 0 0
  1. <template>
  2. <div class="row">
  3. <div class="col-12">
  4. <basic-input-field :resource="user" :set-resource="setUserProperty" property="name" label="Name"></basic-input-field>
  5. <basic-input-field :resource="user" :set-resource="setUserProperty" property="email" label="Email"></basic-input-field>
  6. <basic-input-field :resource="user" :set-resource="setUserProperty" property="password" label="Password"></basic-input-field>
  7.  
  8. <vue-button :on-click="updateUser" label="Save"></vue-button>
  9. </div>
  10. </div>
  11. </template>
  12.  
  13. <script>
  14. import axios from 'axios';
  15. import basicInputField from '../general/forms/basic-input-field.vue';
  16. import vueButton from '../general/buttons/vue-button.vue';
  17.  
  18. export default {
  19. name: 'user',
  20. data() {
  21. return {
  22. };
  23. },
  24. mixins: [],
  25. components: {
  26. basicInputField,
  27. vueButton
  28. },
  29. computed: {
  30. user() {
  31. return this.$store.state.user;
  32. },
  33. },
  34. mounted() {
  35. this.$httpGet('user', {id: 5});
  36. },
  37. watch: {
  38. 'user': function (newUser) {
  39. // I want to trigger an event inside the component vue-button
  40. // I do not want to trigger then event in every vue-button component on the page just this vue-button
  41. // I need to call a resetStatus method within the vue-button component when the user changes
  42. // This would have worked in vue 1 with an event 'resetStatus' that would call the method in the vue-button component
  43. this.$broadcast('resetStatus');
  44. }
  45. },
  46. methods: {
  47. setUserProperty(property, value) {
  48. this.$store.commit('UPDATE_MODULE_RESOURCE', {module: 'user', resource: property, value: value});
  49. },
  50. updateUser() {
  51. return this.$httpPut('user', {id: this.user.id}, this.user);
  52. }
  53. },
  54. };
  55. </script>
Add Comment
Please, Sign In to add comment