menu.js 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. Template.listActionPopup.events({
  2. 'click .js-add-card': function() {
  3. var listDom = document.getElementById('js-list-' + this._id);
  4. var listComponent = BlazeComponent.getComponentForElement(listDom);
  5. listComponent.openForm({ position: 'top' });
  6. Popup.close();
  7. },
  8. 'click .js-list-subscribe': function() {},
  9. 'click .js-select-cards': function() {
  10. var cardIds = Cards.find(
  11. {listId: this._id},
  12. {fields: { _id: 1 }}
  13. ).map(function(card) { return card._id; });
  14. MultiSelection.add(cardIds);
  15. Popup.close();
  16. },
  17. 'click .js-move-cards': Popup.open('listMoveCards'),
  18. 'click .js-archive-cards': Popup.afterConfirm('listArchiveCards', function() {
  19. Cards.find({listId: this._id}).forEach(function(card) {
  20. Cards.update(card._id, {
  21. $set: {
  22. archived: true
  23. }
  24. });
  25. });
  26. Popup.close();
  27. }),
  28. 'click .js-close-list': function(evt) {
  29. evt.preventDefault();
  30. Lists.update(this._id, {
  31. $set: {
  32. archived: true
  33. }
  34. });
  35. Popup.close();
  36. }
  37. });
  38. Template.listMoveCardsPopup.events({
  39. 'click .js-select-list': function() {
  40. var fromList = Template.parentData(2).data._id;
  41. var toList = this._id;
  42. Cards.find({listId: fromList}).forEach(function(card) {
  43. Cards.update(card._id, {
  44. $set: {
  45. listId: toList
  46. }
  47. });
  48. });
  49. Popup.close();
  50. }
  51. });