adjust image field validation
This commit is contained in:
@@ -112,11 +112,23 @@ export default {
|
|||||||
onSelectFiles (e) {
|
onSelectFiles (e) {
|
||||||
e.preventDefault()
|
e.preventDefault()
|
||||||
|
|
||||||
this.uploadFiles(this.$refs.input.files).then(() => {
|
const files = Array.from(this.$refs.input.files).filter((f) => {
|
||||||
if (this.$refs.input) {
|
if (this.accept === 'image/*') {
|
||||||
this.$refs.input.value = ''
|
return f.type.startsWith('image')
|
||||||
|
} else {
|
||||||
|
return true
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
if (this.accept === 'image/*' && !files.length) {
|
||||||
|
alert(this.t('please_upload_an_image_file'))
|
||||||
|
} else {
|
||||||
|
this.uploadFiles(files).then(() => {
|
||||||
|
if (this.$refs.input) {
|
||||||
|
this.$refs.input.value = ''
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
},
|
},
|
||||||
async uploadFiles (files) {
|
async uploadFiles (files) {
|
||||||
this.isLoading = true
|
this.isLoading = true
|
||||||
|
|||||||
Reference in New Issue
Block a user