dropzone fixed href issue..

This commit is contained in:
Cüneyt Şentürk 2021-02-08 18:26:30 +03:00
parent 4f6d2a0435
commit 6852d83cb9

View File

@ -107,11 +107,11 @@ export default {
let preview = this.preview == 'single' ? this.$refs.previewSingle : this.$refs.previewMultiple; let preview = this.preview == 'single' ? this.$refs.previewSingle : this.$refs.previewMultiple;
if (this.configurations.maxFiles === undefined && this.multiple == false) { if (this.configurations.maxFiles === undefined && this.multiple == false) {
this.configurations.maxFiles = 1 this.configurations.maxFiles = 1;
} }
if (this.configurations.acceptedFiles === undefined) { if (this.configurations.acceptedFiles === undefined) {
this.configurations.acceptedFiles = 'image/*' this.configurations.acceptedFiles = 'image/*';
} }
let finalOptions = { let finalOptions = {
@ -123,7 +123,7 @@ export default {
autoProcessQueue: false, autoProcessQueue: false,
init: function () { init: function () {
let dropzone = this let dropzone = this;
dropzone.on('addedfile', function (file) { dropzone.on('addedfile', function (file) {
self.files.push(file); self.files.push(file);
@ -160,20 +160,25 @@ export default {
} }
}) })
if (self.attachments.length) {
setTimeout(() => { setTimeout(() => {
self.attachments.forEach(async (attachment) => { self.attachments.forEach(async (attachment) => {
let blob = await self.getAttachmentContent(attachment.path) let blob = await self.getAttachmentContent(attachment.path);
let file = new File([blob], attachment.name, { type: blob.type }) let file = new File([blob], attachment.name, { type: blob.type });
dropzone.displayExistingFile(file, attachment.path, () => { dropzone.displayExistingFile(file, attachment.path, () => {
file.previewElement.querySelector("[data-dz-download]").href = attachment.downloadPath if (attachment.downloadPath) {
file.previewElement.querySelector("[data-dz-download]").classList.remove("d-none") file.previewElement.querySelector("[data-dz-download]").href = attachment.downloadPath;
}) file.previewElement.querySelector("[data-dz-download]").classList.remove("d-none");
}) }
});
});
if (self.preview == 'single' && self.attachments.length == 1) if (self.preview == 'single' && self.attachments.length == 1) {
document.querySelector("#dropzone").classList.add("dz-max-files-reached"); document.querySelector("#dropzone").classList.add("dz-max-files-reached");
}, 750) }
}, 100);
}
} }
}; };
@ -181,9 +186,10 @@ export default {
preview.innerHTML = ''; preview.innerHTML = '';
}, },
async getAttachmentContent(imageUrl) { async getAttachmentContent(imageUrl) {
return await axios.get(imageUrl, { responseType: 'blob' }).then(function (response) { return await axios.get(imageUrl, { responseType: 'blob' }).then(function (response) {
return response.data return response.data;
}); });
} }
}, },