From 13467852cd203064e779bda9d9ab4612ee1f0381 Mon Sep 17 00:00:00 2001 From: Sevan Nerse Date: Mon, 18 Jan 2021 13:46:04 +0300 Subject: [PATCH] event listener part of akaunting dropzone is arranged --- .../AkauntingDropzoneFileUpload.vue | 77 +++---------------- 1 file changed, 12 insertions(+), 65 deletions(-) diff --git a/resources/assets/js/components/AkauntingDropzoneFileUpload.vue b/resources/assets/js/components/AkauntingDropzoneFileUpload.vue index 70b058818..a5e43d231 100644 --- a/resources/assets/js/components/AkauntingDropzoneFileUpload.vue +++ b/resources/assets/js/components/AkauntingDropzoneFileUpload.vue @@ -107,81 +107,28 @@ export default { if (self.options.maxFiles == 1) { self.$emit('change', file); } else { - self.$emit('change', this.files); + self.$emit('change', self.files); } }), + this.on("removedfile", function (file) { + let index = self.files.findIndex(f => f.upload.uuid === file.upload.uuid); + + if (index !== -1) { + self.files.splice(index, 1); + } + + self.$emit('change', self.files); + }), this.on("maxfilesexceeded", function(file) { this.removeAllFiles('notCancel'); this.addFile(file); - }); + }) } }; this.dropzone = new Dropzone(this.$el, finalOptions); - preview.innerHTML = ''; - - let evtList = [ - 'drop', - 'dragstart', - 'dragend', - 'dragenter', - 'dragover', - 'addedfile', - 'removedfile', - 'thumbnail', - 'error', - 'processing', - 'uploadprogress', - 'sending', - 'success', - 'complete', - 'canceled', - 'maxfilesreached', - 'maxfilesexceeded', - 'processingmultiple', - 'sendingmultiple', - 'successmultiple', - 'completemultiple', - 'canceledmultiple', - 'totaluploadprogress', - 'reset', - 'queuecomplete', - ]; - - evtList.forEach(evt => { - this.dropzone.on(evt, (file) => { - this.$emit(evt, file); - /* - if (evt === 'addedfile') { - if (self.multiple) { - this.files.push(file); - - this.$emit('change', this.files); - } else { - this.file = file; - this.$emit('change', file); - } - } - */ - - if (evt === 'removedfile') { - //if (self.multiple) { - let index = this.files.findIndex(f => f.upload.uuid === file.upload.uuid); - - if (index !== -1) { - this.files.splice(index, 1); - } - - this.$emit('change', this.files); - //} else { - // this.file = ''; - - // this.$emit('change', ''); - //} - } - }) - }, this); + preview.innerHTML = '' } },