diff options
Diffstat (limited to 'client')
-rw-r--r-- | client/components/cards/attachments.js | 23 | ||||
-rwxr-xr-x | client/components/main/editor.js | 8 | ||||
-rw-r--r-- | client/lib/utils.js | 14 |
3 files changed, 31 insertions, 14 deletions
diff --git a/client/components/cards/attachments.js b/client/components/cards/attachments.js index 604dc078..f24a7f82 100644 --- a/client/components/cards/attachments.js +++ b/client/components/cards/attachments.js @@ -45,18 +45,31 @@ Template.attachmentsGalery.events({ }, }); +Template.attachmentsGalery.helpers({ + url() { + return Attachments.link(this); + } +}); + Template.previewAttachedImagePopup.events({ 'click .js-large-image-clicked'() { Popup.close(); }, }); +Template.previewAttachedImagePopup.helpers({ + url() { + return Attachments.link(this); + } +}); + Template.cardAttachmentsPopup.events({ 'change .js-attach-file'(event) { const card = this; const processFile = f => { Utils.processUploadedAttachment(card, f, attachment => { - if (attachment && attachment._id && attachment.isImage()) { + console.log('attachment', attachment); + if (attachment && attachment._id && attachment.isImage) { card.setCover(attachment._id); } Popup.close(); @@ -152,13 +165,14 @@ Template.previewClipboardImagePopup.events({ const settings = { file: results.file, streams: 'dynamic', - chunkSize: 'dynamic' + chunkSize: 'dynamic', }; if (!results.name) { // if no filename, it's from clipboard. then we give it a name, with ext name from MIME type // FIXME: Check this behavior if (typeof results.file.type === 'string') { - settings.fileName = new Date().getTime() + results.file.type.replace('.+/', ''); + settings.fileName = + new Date().getTime() + results.file.type.replace('.+/', ''); } } settings.meta = {}; @@ -166,8 +180,7 @@ Template.previewClipboardImagePopup.events({ settings.meta.boardId = card.boardId; settings.meta.cardId = card._id; settings.meta.userId = Meteor.userId(); - console.log('settings', settings); - const attachment = Attachments.insert(settings, false); + const attachment = Attachments.insert(settings); // TODO: Check image cover behavior if (attachment && attachment._id && attachment.isImage) { diff --git a/client/components/main/editor.js b/client/components/main/editor.js index 39c03aa9..bd110868 100755 --- a/client/components/main/editor.js +++ b/client/components/main/editor.js @@ -229,18 +229,14 @@ Template.editor.onRendered(() => { currentCard, fileObj, attachment => { - if ( - attachment && - attachment._id && - attachment.isImage() - ) { + if (attachment && attachment._id && attachment.isImage) { attachment.one('uploaded', function() { const maxTry = 3; const checkItvl = 500; let retry = 0; const checkUrl = function() { // even though uploaded event fired, attachment.url() is still null somehow //TODO - const url = attachment.url(); + const url = attachment.link(); if (url) { insertImage( `${location.protocol}//${location.host}${url}`, diff --git a/client/lib/utils.js b/client/lib/utils.js index 2694396f..d667382d 100644 --- a/client/lib/utils.js +++ b/client/lib/utils.js @@ -37,7 +37,15 @@ Utils = { let settings = { file: fileObj, streams: 'dynamic', - chunkSize: 'dynamic' + chunkSize: 'dynamic', + onUploaded: function(error, fileObj) { + console.log('after insert', Attachments.find({}).fetch()); + if (error) { + console.log('Error while upload', error); + } else { + next(fileObj); + } + }, }; settings.meta = {}; if (card.isLinkedCard()) { @@ -51,10 +59,10 @@ Utils = { } settings.meta.userId = Meteor.userId(); // FIXME: What is this? -/* if (file.original) { + /* if (file.original) { file.original.name = fileObj.name; }*/ - return next(Attachments.insert(settings, false)); + Attachments.insert(settings); }, shrinkImage(options) { // shrink image to certain size |