SHARE
TWEET

Untitled

a guest Nov 16th, 2017 31 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <template>
  2.     <div>
  3.         <h3 class="fw-3" v-text="user.username"></h3>
  4.  
  5.         <form v-if="canUpdate" method="POST" enctype="multipart/form-data">
  6.  
  7.             <image-upload @loaded="onLoad"></image-upload>
  8.  
  9.  
  10.             <!--<input id="upload" name="avatar" accept="image/*" @change="onChange" type="file">-->
  11.             <!--<a href="" id="upload_link">-->
  12.                 <!--<i class="fa fa-pencil" style="font-size: 24px; color: black"></i>-->
  13.             <!--</a>-->
  14.         </form>
  15.  
  16.  
  17.  
  18.         <!--Bind de avatar naar wat de avatar is-->
  19.         <img :src="avatar" class="rounded-circle" width="100" height="100">
  20.     </div>
  21. </template>
  22.  
  23. <script>
  24.  
  25.     import ImageUpload from './ImageUpload.vue';
  26.  
  27.     export default {
  28.  
  29.         props:  ['user'],
  30.  
  31.         components: { ImageUpload },
  32.  
  33.         data() {
  34.             return {
  35.                 avatar: this.user.avatar_path
  36.             };
  37.         },
  38.  
  39.         computed: {
  40.             canUpdate() {
  41.                 return this.authorize(user => user.id === this.user.id)
  42.             }
  43.         },
  44.  
  45.         methods: {
  46.             onLoad(avatar) {
  47.                 this.avatar = avatar.src;
  48.  
  49.                 this.persist(avatar.file);
  50.             },
  51.  
  52.             persist(bestand) {
  53.                 let data = new FormData();
  54.  
  55.                 data.append('avatar', bestand);
  56.  
  57.                 axios.post(`/gebruikers/${this.user.username}/avatar`, data).then(() => flash('Foto bewerkt!'));
  58.             }
  59.         }
  60.     }
  61. </script>
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top