Fixes #5938 -- Fix uploading of custom assets.
This commit is contained in:
parent
5d4a3cb704
commit
e6d20ba400
|
@ -8,7 +8,7 @@
|
||||||
<b-overlay variant="card" :show="loading">
|
<b-overlay variant="card" :show="loading">
|
||||||
<b-form-group :label-for="id">
|
<b-form-group :label-for="id">
|
||||||
<template #label>{{ caption }}</template>
|
<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-form-group>
|
||||||
<b-button v-if="isUploaded" variant="outline-danger" @click.prevent="clear()">
|
<b-button v-if="isUploaded" variant="outline-danger" @click.prevent="clear()">
|
||||||
<translate key="lang_btn_reset">Clear Image</translate>
|
<translate key="lang_btn_reset">Clear Image</translate>
|
||||||
|
@ -37,6 +37,22 @@ export default {
|
||||||
mounted() {
|
mounted() {
|
||||||
this.relist();
|
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: {
|
methods: {
|
||||||
relist() {
|
relist() {
|
||||||
this.file = null;
|
this.file = null;
|
||||||
|
@ -48,7 +64,6 @@ export default {
|
||||||
|
|
||||||
this.loading = false;
|
this.loading = false;
|
||||||
});
|
});
|
||||||
|
|
||||||
},
|
},
|
||||||
clear() {
|
clear() {
|
||||||
this.$wrapWithLoading(
|
this.$wrapWithLoading(
|
||||||
|
@ -57,20 +72,6 @@ export default {
|
||||||
this.relist();
|
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>
|
</script>
|
||||||
|
|
Loading…
Reference in New Issue