| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141 | archivedRequested = false;const subManager = new SubsManager();BlazeComponent.extendComponent({  onCreated() {    this.isArchiveReady = new ReactiveVar(false);    // The pattern we use to manually handle data loading is described here:    // https://kadira.io/academy/meteor-routing-guide/content/subscriptions-and-data-management/using-subs-manager    // XXX The boardId should be readed from some sort the component "props",    // unfortunatly, Blaze doesn't have this notion.    this.autorun(() => {      const currentBoardId = Session.get('currentBoard');      if (!currentBoardId) return;      const handle = subManager.subscribe('board', currentBoardId, true);      archivedRequested = true;      Tracker.nonreactive(() => {        Tracker.autorun(() => {          this.isArchiveReady.set(handle.ready());        });      });    });  },  tabs() {    return [      { name: TAPi18n.__('cards'), slug: 'cards' },      { name: TAPi18n.__('lists'), slug: 'lists' },      { name: TAPi18n.__('swimlanes'), slug: 'swimlanes' },    ];  },  archivedCards() {    return Cards.find({      archived: true,      boardId: Session.get('currentBoard'),    });  },  archivedLists() {    return Lists.find({      archived: true,      boardId: Session.get('currentBoard'),    });  },  archivedSwimlanes() {    return Swimlanes.find({      archived: true,      boardId: Session.get('currentBoard'),    });  },  cardIsInArchivedList() {    return this.currentData().list().archived;  },  onRendered() {    // XXX We should support dragging a card from the sidebar to the board  },  events() {    return [      {        'click .js-restore-card'() {          const card = this.currentData();          if (card.canBeRestored()) {            card.restore();          }        },        'click .js-restore-all-cards'() {          this.archivedCards().forEach(card => {            if (card.canBeRestored()) {              card.restore();            }          });        },        'click .js-delete-card': Popup.afterConfirm('cardDelete', function() {          const cardId = this._id;          Cards.remove(cardId);          Popup.close();        }),        'click .js-delete-all-cards': Popup.afterConfirm('cardDelete', () => {          this.archivedCards().forEach(card => {            Cards.remove(card._id);          });          Popup.close();        }),        'click .js-restore-list'() {          const list = this.currentData();          list.restore();        },        'click .js-restore-all-lists'() {          this.archivedLists().forEach(list => {            list.restore();          });        },        'click .js-delete-list': Popup.afterConfirm('listDelete', function() {          this.remove();          Popup.close();        }),        'click .js-delete-all-lists': Popup.afterConfirm('listDelete', () => {          this.archivedLists().forEach(list => {            list.remove();          });          Popup.close();        }),        'click .js-restore-swimlane'() {          const swimlane = this.currentData();          swimlane.restore();        },        'click .js-restore-all-swimlanes'() {          this.archivedSwimlanes().forEach(swimlane => {            swimlane.restore();          });        },        'click .js-delete-swimlane': Popup.afterConfirm(          'swimlaneDelete',          function() {            this.remove();            Popup.close();          },        ),        'click .js-delete-all-swimlanes': Popup.afterConfirm(          'swimlaneDelete',          () => {            this.archivedSwimlanes().forEach(swimlane => {              swimlane.remove();            });            Popup.close();          },        ),      },    ];  },}).register('archivesSidebar');
 |