Edit submissions file issue (#373)

* Edit submissions file issue fixed

* handleCompValChange with loader

---------

Co-authored-by: Julien Nahum <julien@nahum.net>
This commit is contained in:
Chirag Chhatrala
2024-04-15 18:42:36 +05:30
committed by GitHub
parent 4f4f7128fa
commit e1faba8239
4 changed files with 82 additions and 54 deletions

View File

@@ -129,34 +129,47 @@ export default {
handler(files) {
this.compVal = files.map((file) => file.url)
}
},
'compVal': {
deep: true,
handler(newVal, oldVal) {
if (!oldVal) {
this.handleCompValChange();
}
}
}
},
async created() {
if (typeof this.compVal === 'string' || this.compVal instanceof String) {
await this.getFileFromUrl(this.compVal).then((fileObj) => {
this.files = [{
file: fileObj,
url: this.compVal,
src: this.getFileSrc(fileObj)
}]
})
} else if (this.compVal && this.compVal.length > 0) {
const tmpFiles = []
for (let i = 0; i < this.compVal.length; i++) {
await this.getFileFromUrl(this.compVal[i]).then((fileObj) => {
tmpFiles.push({
file: fileObj,
url: this.compVal[i],
src: this.getFileSrc(fileObj)
})
})
}
this.files = tmpFiles
}
mounted() {
this.handleCompValChange();
},
methods: {
async handleCompValChange() {
this.loading = true
if (typeof this.compVal === 'string' || this.compVal instanceof String) {
await this.getFileFromUrl(this.compVal).then((fileObj) => {
this.files = [{
file: fileObj,
url: this.compVal,
src: this.getFileSrc(fileObj)
}]
})
} else if (this.compVal && this.compVal.length > 0) {
const tmpFiles = []
for (let i = 0; i < this.compVal.length; i++) {
await this.getFileFromUrl(this.compVal[i]).then((fileObj) => {
tmpFiles.push({
file: fileObj,
url: (typeof this.compVal[i] === 'object') ? this.compVal[i]?.file_url : this.compVal[i],
src: this.getFileSrc(fileObj)
})
})
}
this.files = tmpFiles
}
this.loading = false
},
clearAll() {
this.files = []
},