header.js 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. import { ReactiveCache } from '/imports/reactiveCache';
  2. Meteor.subscribe('user-admin');
  3. Meteor.subscribe('boards');
  4. Meteor.subscribe('setting');
  5. Meteor.subscribe('announcements');
  6. Template.header.onCreated(function(){
  7. const templateInstance = this;
  8. templateInstance.currentSetting = new ReactiveVar();
  9. templateInstance.isLoading = new ReactiveVar(false);
  10. Meteor.subscribe('setting', {
  11. onReady() {
  12. templateInstance.currentSetting.set(ReactiveCache.getCurrentSetting());
  13. let currSetting = templateInstance.currentSetting.curValue;
  14. if(currSetting && currSetting !== undefined && currSetting.customLoginLogoImageUrl !== undefined && document.getElementById("headerIsSettingDatabaseCallDone") != null)
  15. document.getElementById("headerIsSettingDatabaseCallDone").style.display = 'none';
  16. else if(document.getElementById("headerIsSettingDatabaseCallDone") != null)
  17. document.getElementById("headerIsSettingDatabaseCallDone").style.display = 'block';
  18. return this.stop();
  19. },
  20. });
  21. });
  22. Template.header.helpers({
  23. wrappedHeader() {
  24. return !Session.get('currentBoard');
  25. },
  26. hideLogo() {
  27. return Utils.isMiniScreen() && Session.get('currentBoard');
  28. },
  29. appIsOffline() {
  30. return !Meteor.status().connected;
  31. },
  32. hasAnnouncement() {
  33. const announcements = Announcements.findOne();
  34. return announcements && announcements.enabled;
  35. },
  36. announcement() {
  37. $('.announcement').show();
  38. const announcements = Announcements.findOne();
  39. return announcements && announcements.body;
  40. },
  41. });
  42. Template.header.events({
  43. 'click .js-create-board': Popup.open('headerBarCreateBoard'),
  44. 'click .js-close-announcement'() {
  45. $('.announcement').hide();
  46. },
  47. 'click .js-select-list'() {
  48. Session.set('currentList', this._id);
  49. Session.set('currentCard', null);
  50. },
  51. 'click .js-toggle-desktop-drag-handles'() {
  52. //currentUser = Meteor.user();
  53. //if (currentUser) {
  54. // Meteor.call('toggleDesktopDragHandles');
  55. //} else if (window.localStorage.getItem('showDesktopDragHandles')) {
  56. if (window.localStorage.getItem('showDesktopDragHandles')) {
  57. window.localStorage.removeItem('showDesktopDragHandles');
  58. location.reload();
  59. } else {
  60. window.localStorage.setItem('showDesktopDragHandles', 'true');
  61. location.reload();
  62. }
  63. },
  64. });
  65. Template.offlineWarning.events({
  66. 'click a.app-try-reconnect'(event) {
  67. event.preventDefault();
  68. Meteor.reconnect();
  69. },
  70. });