boardArchive.js 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  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. const ret = ReactiveCache.getBoards(
  11. { archived: true },
  12. {
  13. sort: { archivedAt: -1, modifiedAt: -1 },
  14. },
  15. );
  16. return ret;
  17. },
  18. events() {
  19. return [
  20. {
  21. 'click .js-restore-board'() {
  22. // TODO : Make isSandstorm variable global
  23. const isSandstorm =
  24. Meteor.settings &&
  25. Meteor.settings.public &&
  26. Meteor.settings.public.sandstorm;
  27. if (isSandstorm && Utils.getCurrentBoardId()) {
  28. const currentBoard = Utils.getCurrentBoard();
  29. currentBoard.archive();
  30. }
  31. const board = this.currentData();
  32. board.restore();
  33. Utils.goBoardId(board._id);
  34. },
  35. 'click .js-delete-board': Popup.afterConfirm('boardDelete', function() {
  36. Popup.back();
  37. const isSandstorm =
  38. Meteor.settings &&
  39. Meteor.settings.public &&
  40. Meteor.settings.public.sandstorm;
  41. if (isSandstorm && Utils.getCurrentBoardId()) {
  42. const currentBoard = Utils.getCurrentBoard();
  43. Boards.remove(currentBoard._id);
  44. }
  45. Boards.remove(this._id);
  46. FlowRouter.go('home');
  47. }),
  48. },
  49. ];
  50. },
  51. }).register('archivedBoards');