From a6b4a698afdc7c7a64688846015bd7e33b2477b9 Mon Sep 17 00:00:00 2001 From: Martin Filser Date: Tue, 26 Apr 2022 23:14:57 +0200 Subject: [PATCH] Attachment, upload all selected files - until now only the first attachment was uploaded --- client/components/cards/attachments.js | 50 ++++++++++++++------------ 1 file changed, 27 insertions(+), 23 deletions(-) diff --git a/client/components/cards/attachments.js b/client/components/cards/attachments.js index 2279ae932..ade5833b0 100644 --- a/client/components/cards/attachments.js +++ b/client/components/cards/attachments.js @@ -20,30 +20,34 @@ Template.attachmentsGalery.helpers({ Template.cardAttachmentsPopup.events({ 'change .js-attach-file'(event) { const card = this; - if (event.currentTarget.files && event.currentTarget.files[0]) { - const fileId = Random.id(); - const config = { - file: event.currentTarget.files[0], - fileId: fileId, - meta: Utils.getCommonAttachmentMetaFrom(card), - chunkSize: 'dynamic', - }; - config.meta.fileId = fileId; - const uploader = Attachments.insert( - config, - false, - ); - uploader.on('uploaded', (error, fileRef) => { - if (!error) { - if (fileRef.isImage) { - card.setCover(fileRef._id); + const files = event.currentTarget.files; + if (files) { + let finished = []; + for (const file of files) { + const fileId = Random.id(); + const config = { + file: file, + fileId: fileId, + meta: Utils.getCommonAttachmentMetaFrom(card), + chunkSize: 'dynamic', + }; + config.meta.fileId = fileId; + const uploader = Attachments.insert( + config, + false, + ); + uploader.on('uploaded', (error, fileRef) => { + if (!error) { + if (fileRef.isImage) { + card.setCover(fileRef._id); + } } - } - }); - uploader.on('end', (error, fileRef) => { - Popup.back(); - }); - uploader.start(); + }); + uploader.on('end', (error, fileRef) => { + Popup.back(); + }); + uploader.start(); + } } }, 'click .js-computer-upload'(event, templateInstance) {