boardArchive.js 1.4 KB

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