boardArchive.js 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. import { ReactiveCache } from '/imports/reactiveCache';
  2. BlazeComponent.extendComponent({
  3. onCreated() {
  4. this.subscribe('archivedBoards');
  5. },
  6. isBoardAdmin() {
  7. return ReactiveCache.getCurrentUser().isBoardAdmin();
  8. },
  9. archivedBoards() {
  10. return Boards.find(
  11. { archived: true },
  12. {
  13. sort: { archivedAt: -1, modifiedAt: -1 },
  14. },
  15. );
  16. },
  17. events() {
  18. return [
  19. {
  20. 'click .js-restore-board'() {
  21. // TODO : Make isSandstorm variable global
  22. const isSandstorm =
  23. Meteor.settings &&
  24. Meteor.settings.public &&
  25. Meteor.settings.public.sandstorm;
  26. if (isSandstorm && Utils.getCurrentBoardId()) {
  27. const currentBoard = Utils.getCurrentBoard();
  28. currentBoard.archive();
  29. }
  30. const board = this.currentData();
  31. board.restore();
  32. Utils.goBoardId(board._id);
  33. },
  34. 'click .js-delete-board': Popup.afterConfirm('boardDelete', function() {
  35. Popup.back();
  36. const isSandstorm =
  37. Meteor.settings &&
  38. Meteor.settings.public &&
  39. Meteor.settings.public.sandstorm;
  40. if (isSandstorm && Utils.getCurrentBoardId()) {
  41. const currentBoard = Utils.getCurrentBoard();
  42. Boards.remove(currentBoard._id);
  43. }
  44. Boards.remove(this._id);
  45. FlowRouter.go('home');
  46. }),
  47. },
  48. ];
  49. },
  50. }).register('archivedBoards');