menu.js 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. Template.listActionPopup.events({
  2. 'click .js-add-card': function() {
  3. // XXX We need a better API and architecture here. See
  4. // https://github.com/peerlibrary/meteor-blaze-components/issues/19
  5. var listDom = document.getElementById('js-list-' + this._id);
  6. var listComponent = Blaze.getView(listDom).templateInstance().get('component');
  7. listComponent.openForm();
  8. Popup.close();
  9. },
  10. 'click .js-list-subscribe': function() {},
  11. 'click .js-move-cards': Popup.open('listMoveCards'),
  12. 'click .js-archive-cards': Popup.afterConfirm('listArchiveCards', function() {
  13. Cards.find({listId: this._id}).forEach(function(card) {
  14. Cards.update(card._id, {
  15. $set: {
  16. archived: true
  17. }
  18. });
  19. });
  20. Popup.close();
  21. }),
  22. 'click .js-close-list': function(evt) {
  23. evt.preventDefault();
  24. Lists.update(this._id, {
  25. $set: {
  26. archived: true
  27. }
  28. });
  29. Popup.close();
  30. }
  31. });
  32. Template.listMoveCardsPopup.events({
  33. 'click .js-select-list': function() {
  34. var fromList = Template.parentData(2).data._id;
  35. var toList = this._id;
  36. Cards.find({listId: fromList}).forEach(function(card) {
  37. Cards.update(card._id, {
  38. $set: {
  39. listId: toList
  40. }
  41. });
  42. });
  43. Popup.close();
  44. }
  45. });