listHeader.js 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. BlazeComponent.extendComponent({
  2. editTitle(evt) {
  3. evt.preventDefault();
  4. const newTitle = this.childComponents('inlinedForm')[0].getValue().trim();
  5. const list = this.currentData();
  6. if (newTitle) {
  7. list.rename(newTitle.trim());
  8. }
  9. },
  10. isWatching() {
  11. const list = this.currentData();
  12. return list.findWatcher(Meteor.userId());
  13. },
  14. limitToShowCardsCount() {
  15. return Meteor.user().getLimitToShowCardsCount();
  16. },
  17. showCardsCountForList(count) {
  18. return count > this.limitToShowCardsCount();
  19. },
  20. events() {
  21. return [{
  22. 'click .js-open-list-menu': Popup.open('listAction'),
  23. submit: this.editTitle,
  24. }];
  25. },
  26. }).register('listHeader');
  27. Template.listActionPopup.helpers({
  28. isWatching() {
  29. return this.findWatcher(Meteor.userId());
  30. },
  31. });
  32. Template.listActionPopup.events({
  33. 'click .js-add-card' () {
  34. const listDom = document.getElementById(`js-list-${this._id}`);
  35. const listComponent = BlazeComponent.getComponentForElement(listDom);
  36. listComponent.openForm({
  37. position: 'top'
  38. });
  39. Popup.close();
  40. },
  41. 'click .js-list-subscribe' () {},
  42. 'click .js-select-cards' () {
  43. const cardIds = this.allCards().map((card) => card._id);
  44. MultiSelection.add(cardIds);
  45. Popup.close();
  46. },
  47. 'click .js-toggle-watch-list' () {
  48. const currentList = this;
  49. const level = currentList.findWatcher(Meteor.userId()) ? null : 'watching';
  50. Meteor.call('watch', 'list', currentList._id, level, (err, ret) => {
  51. if (!err && ret) Popup.close();
  52. });
  53. },
  54. 'click .js-close-list' (evt) {
  55. evt.preventDefault();
  56. this.archive();
  57. Popup.close();
  58. },
  59. 'click .js-more': Popup.open('listMore'),
  60. });
  61. Template.listMorePopup.events({
  62. 'click .js-delete': Popup.afterConfirm('listDelete', function () {
  63. Popup.close();
  64. Lists.remove(this._id);
  65. Utils.goBoardId(this.boardId);
  66. }),
  67. });