From e001c3409a3911089adddad7bbd0e350aa152cb8 Mon Sep 17 00:00:00 2001 From: Maxime Quandalle Date: Sat, 13 Jun 2015 15:04:55 +0200 Subject: Fix card attachments Closes #192. --- client/components/cards/attachments.jade | 40 +++++++ client/components/cards/attachments.js | 38 ++++++ client/components/cards/attachments.styl | 47 ++++++++ client/components/cards/details.jade | 6 +- client/components/cards/events.js | 42 ------- client/components/cards/templates.html | 197 ------------------------------- 6 files changed, 130 insertions(+), 240 deletions(-) create mode 100644 client/components/cards/attachments.jade create mode 100644 client/components/cards/attachments.js create mode 100644 client/components/cards/attachments.styl delete mode 100644 client/components/cards/events.js delete mode 100644 client/components/cards/templates.html (limited to 'client/components/cards') diff --git a/client/components/cards/attachments.jade b/client/components/cards/attachments.jade new file mode 100644 index 00000000..4170d195 --- /dev/null +++ b/client/components/cards/attachments.jade @@ -0,0 +1,40 @@ +template(name="cardAttachmentsPopup") + ul.pop-over-list + li + input.js-attach-file.hide(type="file" name="file" multiple) + a.js-computer-upload {{_ 'computer'}} + +template(name="attachmentDeletePopup") + p {{_ "attachment-delete-pop"}} + button.js-confirm.negate.full(type="submit") {{_ 'delete'}} + +template(name="attachmentsGalery") + .attachments-galery + each attachments + a.attachment-item.js-open-viewer(title="{{_ 'added'}} {{ moment uploadedAt }}") + .attachment-thumbnail + if isUploaded + if isImage + img.attachment-thumbnail-img(src=url) + else + span.attachment-thumbnail-ext= extension + else + +spinner + p.attachment-details + = name + span.attachment-details-actions + a.js-download + i.fa.fa-download + | {{_ 'download'}} + if isImage + a(class="{{#if $eq ../coverId _id}}js-remove-cover{{else}}js-add-cover{{/if}}") + i.fa.fa-thumb-tack + if($eq ../coverId _id) + | {{_ 'remove-cover'}} + else + | {{_ 'add-cover'}} + a.js-confirm-delete + i.fa.fa-close + | {{_ 'delete'}} + + a.attachment-item.add-attachment.js-add-attachment {{_ 'add-attachment' }} diff --git a/client/components/cards/attachments.js b/client/components/cards/attachments.js new file mode 100644 index 00000000..db0ecb8e --- /dev/null +++ b/client/components/cards/attachments.js @@ -0,0 +1,38 @@ +Template.attachmentsGalery.events({ + 'click .js-add-attachment': Popup.open('cardAttachments'), + 'click .js-confirm-delete': Popup.afterConfirm('attachmentDelete', + function() { + Attachments.remove(this._id); + Popup.close(); + } + ), + // If we let this event bubble, Iron-Router will handle it and empty the + // page content, see #101. + 'click .js-open-viewer, click .js-download': function(event) { + event.stopPropagation(); + }, + 'click .js-add-cover': function() { + Cards.update(this.cardId, { $set: { coverId: this._id } }); + }, + 'click .js-remove-cover': function() { + Cards.update(this.cardId, { $unset: { coverId: '' } }); + } +}); + +Template.cardAttachmentsPopup.events({ + 'change .js-attach-file': function(evt) { + var card = this; + FS.Utility.eachFile(evt, function(f) { + var file = new FS.File(f); + file.boardId = card.boardId; + file.cardId = card._id; + + Attachments.insert(file); + Popup.close(); + }); + }, + 'click .js-computer-upload': function(evt, tpl) { + tpl.find('.js-attach-file').click(); + evt.preventDefault(); + } +}); diff --git a/client/components/cards/attachments.styl b/client/components/cards/attachments.styl new file mode 100644 index 00000000..5cdf7386 --- /dev/null +++ b/client/components/cards/attachments.styl @@ -0,0 +1,47 @@ +.attachments-galery + display: flex + flex-wrap: wrap + + .attachment-item + width: 33.33% - 2% + margin: 10px 1% 0 + text-align: center + border-radius: 3px + overflow: hidden + background: darken(white, 7%) + min-height: 120px + + &:hover + background: darken(white, 12%) + + &.add-attachment + display: flex + align-items: center + + .attachment-thumbnail + height: 80px + display: flex + align-items: center + justify-content: center + position: relative + + .attachment-thumbnail-img + height: 100% + width: 100% + + .attachment-thumbnail-ext + text-transform: uppercase + font-size: 1.6em + + .attachment-details + font-size: 0.75em + margin: 3px + + .attachment-details-actions + display: block + +.attachment-image-preview + max-width: 100px + display: block + box-shadow: 0 1px 2px rgba(0,0,0,.2) + diff --git a/client/components/cards/details.jade b/client/components/cards/details.jade index 1eeda71d..f8e99d77 100644 --- a/client/components/cards/details.jade +++ b/client/components/cards/details.jade @@ -61,7 +61,11 @@ template(name="cardDetails") = description if attachments.count hr - +WindowAttachmentsModule(card=this) + h2 + i.fa.fa-paperclip + | {{_ 'attachments'}} + + +attachmentsGalery hr h2 {{ _ 'activity'}} diff --git a/client/components/cards/events.js b/client/components/cards/events.js deleted file mode 100644 index ca2ddb50..00000000 --- a/client/components/cards/events.js +++ /dev/null @@ -1,42 +0,0 @@ -Template.WindowAttachmentsModule.events({ - 'click .js-attach': Popup.open('cardAttachments'), - 'click .js-confirm-delete': Popup.afterConfirm('attachmentDelete', - function() { - Attachments.remove(this._id); - Popup.close(); - } - ), - // If we let this event bubble, Iron-Router will handle it and empty the - // page content, see #101. - 'click .js-open-viewer, click .js-download': function(event) { - event.stopPropagation(); - }, - 'click .js-add-cover': function() { - Cards.update(this.cardId, { $set: { coverId: this._id } }); - }, - 'click .js-remove-cover': function() { - Cards.update(this.cardId, { $unset: { coverId: '' } }); - } -}); - -Template.cardAttachmentsPopup.events({ - 'change .js-attach-file': function(evt) { - var card = this.card; - FS.Utility.eachFile(evt, function(f) { - var file = new FS.File(f); - - // set Ids - file.boardId = card.boardId; - file.cardId = card._id; - - // upload file - Attachments.insert(file); - - Popup.close(); - }); - }, - 'click .js-computer-upload': function(evt, t) { - t.find('.js-attach-file').click(); - evt.preventDefault(); - } -}); diff --git a/client/components/cards/templates.html b/client/components/cards/templates.html deleted file mode 100644 index f61c3df5..00000000 --- a/client/components/cards/templates.html +++ /dev/null @@ -1,197 +0,0 @@ - - - - - - - - - -- cgit v1.2.3-1-g7c22