Code refactoring

This commit is contained in:
Burak Civan
2021-05-25 19:52:39 +03:00
parent 5bac50274a
commit 32894e7151
16 changed files with 190 additions and 253 deletions

View File

@ -231,6 +231,42 @@ export default {
async mounted() {
this.initDropzone();
},
watch: {
attachments: function (attachments) {
attachments.forEach((attachment) => {
var mockFile = {
id: attachment[0].id,
name: attachment[0].name,
size: attachment[0].size,
type: attachment[0].type,
download: attachment[0].downloadPath,
dropzone: 'edit',
};
this.dropzone.emit("addedfile", mockFile);
this.dropzone.options.thumbnail.call(this.dropzone, mockFile, attachment[0].path);
// Make sure that there is no progress bar, etc...
this.dropzone.emit("complete", mockFile);
}, this);
this.files.forEach(async (attachment) => {
if (attachment.download) {
attachment.previewElement.querySelector("[data-dz-download]").href = attachment.download;
attachment.previewElement.querySelector("[data-dz-download]").classList.remove("d-none");
}
});
if (this.preview == 'single' && attachments.length == 1) {
this.$nextTick(() => {
document.querySelector("#dropzone-" + this._uid).classList.add("dz-max-files-reached");
});
}
},
},
}
</script>