boardArchive.js 1.3 KB

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