attachments.js 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. Template.attachmentsGalery.events({
  2. 'click .js-add-attachment': Popup.open('cardAttachments'),
  3. 'click .js-confirm-delete': Popup.afterConfirm('attachmentDelete',
  4. () => {
  5. Attachments.remove(this._id);
  6. Popup.close();
  7. }
  8. ),
  9. // If we let this event bubble, FlowRouter will handle it and empty the page
  10. // content, see #101.
  11. 'click .js-download'(event) {
  12. event.stopPropagation();
  13. },
  14. 'click .js-open-viewer'() {
  15. // XXX Not implemented!
  16. },
  17. 'click .js-add-cover'() {
  18. Cards.findOne(this.cardId).setCover(this._id);
  19. },
  20. 'click .js-remove-cover'() {
  21. Cards.findOne(this.cardId).unsetCover();
  22. },
  23. });
  24. Template.cardAttachmentsPopup.events({
  25. 'change .js-attach-file'(evt) {
  26. const card = this;
  27. FS.Utility.eachFile(evt, (f) => {
  28. const file = new FS.File(f);
  29. file.boardId = card.boardId;
  30. file.cardId = card._id;
  31. Attachments.insert(file);
  32. Popup.close();
  33. });
  34. },
  35. 'click .js-computer-upload'(evt, tpl) {
  36. tpl.find('.js-attach-file').click();
  37. evt.preventDefault();
  38. },
  39. });