listHeader.js 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. BlazeComponent.extendComponent({
  2. template() {
  3. return 'listHeader';
  4. },
  5. editTitle(evt) {
  6. evt.preventDefault();
  7. const newTitle = this.childComponents('inlinedForm')[0].getValue().trim();
  8. const list = this.currentData();
  9. if (newTitle) {
  10. list.rename(newTitle.trim());
  11. }
  12. },
  13. events() {
  14. return [{
  15. 'click .js-open-list-menu': Popup.open('listAction'),
  16. submit: this.editTitle,
  17. }];
  18. },
  19. }).register('listHeader');
  20. Template.listActionPopup.events({
  21. 'click .js-add-card'() {
  22. const listDom = document.getElementById(`js-list-${this._id}`);
  23. const listComponent = BlazeComponent.getComponentForElement(listDom);
  24. listComponent.openForm({ position: 'top' });
  25. Popup.close();
  26. },
  27. 'click .js-list-subscribe'() {},
  28. 'click .js-select-cards'() {
  29. const cardIds = this.allCards().map((card) => card._id);
  30. MultiSelection.add(cardIds);
  31. Popup.close();
  32. },
  33. 'click .js-import-card': Popup.open('listImportCard'),
  34. 'click .js-close-list'(evt) {
  35. evt.preventDefault();
  36. this.archive();
  37. Popup.close();
  38. },
  39. });