boardArchive.js 1.6 KB

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