Refactor media upload
Use Upload Media logic from Pleroma Backend changes for picture upload Move AS <-> Model conversion to separate module Front changes Downgrade apollo-client: https://github.com/Akryum/vue-apollo/issues/577 Signed-off-by: Thomas Citharel <tcit@tcit.fr>
This commit is contained in:
29
js/src/components/PictureUpload.vue
Normal file
29
js/src/components/PictureUpload.vue
Normal file
@@ -0,0 +1,29 @@
|
||||
<template>
|
||||
<b-field class="file">
|
||||
<b-upload v-model="pictureFile" @input="onFileChanged">
|
||||
<a class="button is-primary">
|
||||
<b-icon icon="upload"></b-icon>
|
||||
<span>Click to upload</span>
|
||||
</a>
|
||||
</b-upload>
|
||||
<span class="file-name" v-if="pictureFile">
|
||||
{{ pictureFile.name }}
|
||||
</span>
|
||||
</b-field>
|
||||
</template>
|
||||
|
||||
<script lang="ts">
|
||||
import { Component, Vue } from 'vue-property-decorator';
|
||||
import { IPictureUpload } from '@/types/picture.model';
|
||||
|
||||
@Component
|
||||
export default class PictureUpload extends Vue {
|
||||
picture!: IPictureUpload;
|
||||
pictureFile: File|null = null;
|
||||
|
||||
onFileChanged(file: File) {
|
||||
this.picture = { file, name: file.name, alt: '' };
|
||||
this.$emit('change', this.picture);
|
||||
}
|
||||
}
|
||||
</script>
|
||||
Reference in New Issue
Block a user