sidebarArchives.js 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. BlazeComponent.extendComponent({
  2. tabs() {
  3. return [
  4. { name: TAPi18n.__('cards'), slug: 'cards' },
  5. { name: TAPi18n.__('lists'), slug: 'lists' },
  6. { name: TAPi18n.__('swimlanes'), slug: 'swimlanes' },
  7. ];
  8. },
  9. archivedCards() {
  10. return Cards.find({
  11. archived: true,
  12. boardId: Session.get('currentBoard'),
  13. });
  14. },
  15. archivedLists() {
  16. return Lists.find({
  17. archived: true,
  18. boardId: Session.get('currentBoard'),
  19. });
  20. },
  21. archivedSwimlanes() {
  22. return Swimlanes.find({
  23. archived: true,
  24. boardId: Session.get('currentBoard'),
  25. });
  26. },
  27. cardIsInArchivedList() {
  28. return this.currentData().list().archived;
  29. },
  30. onRendered() {
  31. // XXX We should support dragging a card from the sidebar to the board
  32. },
  33. events() {
  34. return [{
  35. 'click .js-restore-card'() {
  36. const card = this.currentData();
  37. if(card.canBeRestored()){
  38. card.restore();
  39. }
  40. },
  41. 'click .js-restore-all-cards'() {
  42. this.archivedCards().forEach((card) => {
  43. if(card.canBeRestored()){
  44. card.restore();
  45. }
  46. });
  47. },
  48. 'click .js-delete-card': Popup.afterConfirm('cardDelete', function() {
  49. const cardId = this._id;
  50. Cards.remove(cardId);
  51. Popup.close();
  52. }),
  53. 'click .js-delete-all-cards': Popup.afterConfirm('cardDelete', () => {
  54. this.archivedCards().forEach((card) => {
  55. Cards.remove(card._id);
  56. });
  57. Popup.close();
  58. }),
  59. 'click .js-restore-list'() {
  60. const list = this.currentData();
  61. list.restore();
  62. },
  63. 'click .js-restore-all-lists'() {
  64. this.archivedLists().forEach((list) => {
  65. list.restore();
  66. });
  67. },
  68. 'click .js-delete-list': Popup.afterConfirm('listDelete', function() {
  69. this.remove();
  70. Popup.close();
  71. }),
  72. 'click .js-delete-all-lists': Popup.afterConfirm('listDelete', () => {
  73. this.archivedLists().forEach((list) => {
  74. list.remove();
  75. });
  76. Popup.close();
  77. }),
  78. 'click .js-restore-swimlane'() {
  79. const swimlane = this.currentData();
  80. swimlane.restore();
  81. },
  82. 'click .js-restore-all-swimlanes'() {
  83. this.archivedSwimlanes().forEach((swimlane) => {
  84. swimlane.restore();
  85. });
  86. },
  87. 'click .js-delete-swimlane': Popup.afterConfirm('swimlaneDelete', function() {
  88. this.remove();
  89. Popup.close();
  90. }),
  91. 'click .js-delete-all-swimlanes': Popup.afterConfirm('swimlaneDelete', () => {
  92. this.archivedSwimlanes().forEach((swimlane) => {
  93. swimlane.remove();
  94. });
  95. Popup.close();
  96. }),
  97. }];
  98. },
  99. }).register('archivesSidebar');