boardArchive.js 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. BlazeComponent.extendComponent({
  2. onCreated() {
  3. this.subscribe('archivedBoards');
  4. },
  5. archivedBoards() {
  6. return Boards.find({ archived: true }, {
  7. sort: ['title'],
  8. });
  9. },
  10. events() {
  11. return [{
  12. 'click .js-restore-board'() {
  13. // TODO : Make isSandstorm variable global
  14. const isSandstorm = Meteor.settings && Meteor.settings.public &&
  15. Meteor.settings.public.sandstorm;
  16. if (isSandstorm && Session.get('currentBoard')) {
  17. const currentBoard = Boards.findOne(Session.get('currentBoard'));
  18. currentBoard.archive();
  19. }
  20. const board = this.currentData();
  21. board.restore();
  22. Utils.goBoardId(board._id);
  23. },
  24. 'click .js-delete-board': Popup.afterConfirm('boardDelete', function() {
  25. Popup.close();
  26. const isSandstorm = Meteor.settings && Meteor.settings.public &&
  27. Meteor.settings.public.sandstorm;
  28. if (isSandstorm && Session.get('currentBoard')) {
  29. const currentBoard = Boards.findOne(Session.get('currentBoard'));
  30. Boards.remove(currentBoard._id);
  31. }
  32. Boards.remove(this._id);
  33. FlowRouter.go('home');
  34. }),
  35. }];
  36. },
  37. }).register('archivedBoards');