Fixes #5938 -- Fix uploading of custom assets.

This commit is contained in:
Buster Neece 2022-12-13 02:24:56 -06:00
parent 5d4a3cb704
commit e6d20ba400
No known key found for this signature in database
GPG Key ID: F1D2E64A0005E80E
1 changed files with 17 additions and 16 deletions

View File

@ -8,7 +8,7 @@
<b-overlay variant="card" :show="loading">
<b-form-group :label-for="id">
<template #label>{{ caption }}</template>
<b-form-file :id="id" v-model="file" accept="image/*" @input="upload"></b-form-file>
<b-form-file :id="id" v-model="file" accept="image/*"></b-form-file>
</b-form-group>
<b-button v-if="isUploaded" variant="outline-danger" @click.prevent="clear()">
<translate key="lang_btn_reset">Clear Image</translate>
@ -37,6 +37,22 @@ export default {
mounted() {
this.relist();
},
watch: {
file(newFile) {
if (null === newFile) {
return;
}
let formData = new FormData();
formData.append('file', this.file);
this.$wrapWithLoading(
this.axios.post(this.apiUrl, formData)
).finally(() => {
this.relist();
});
}
},
methods: {
relist() {
this.file = null;
@ -48,7 +64,6 @@ export default {
this.loading = false;
});
},
clear() {
this.$wrapWithLoading(
@ -57,20 +72,6 @@ export default {
this.relist();
});
},
upload() {
if (null === this.file) {
return;
}
let formData = new FormData();
formData.append('file', this.file);
this.$wrapWithLoading(
this.axios.post(this.apiUrl, formData)
).finally((resp) => {
this.relist();
});
},
}
}
</script>