From a1f77c02c8ca7facffbaaa7d70a8230a97e07983 Mon Sep 17 00:00:00 2001 From: Jake Renzella Date: Thu, 13 Jan 2022 00:19:07 +1100 Subject: [PATCH] feat: add new header hiding --- src/app/common/header/header.component.ts | 8 ++++++++ src/app/home/states/home/home.component.ts | 1 + .../states/index/global-state.service.ts | 18 +++++++++++++++++- src/app/sessions/states/sign-in/sign-in.coffee | 2 ++ .../sessions/states/sign-out/sign-out.coffee | 1 + 5 files changed, 29 insertions(+), 1 deletion(-) diff --git a/src/app/common/header/header.component.ts b/src/app/common/header/header.component.ts index 69efd3005..a53b41459 100644 --- a/src/app/common/header/header.component.ts +++ b/src/app/common/header/header.component.ts @@ -27,6 +27,7 @@ export class HeaderComponent implements OnInit { filteredUnitRoles: any; currentUnitOrProject: any; currentView: ViewType; + showHeader: boolean = true; constructor( @Inject(currentUser) private CurrentUser, @Inject(userSettingsModal) private UserSettingsModal, @@ -39,6 +40,13 @@ export class HeaderComponent implements OnInit { ) { this.currentUser = this.CurrentUser.profile; + this.globalState.showHideHeader.subscribe({ + next: (shouldShow) => { + this.showHeader = shouldShow; + }, + error: (err) => {}, + }); + this.globalState.unitRolesSubject.subscribe({ next: (unitRoles) => { if (unitRoles == null) return; // might be signing out, or the data has been cleared diff --git a/src/app/home/states/home/home.component.ts b/src/app/home/states/home/home.component.ts index e660520c7..06cd50c46 100644 --- a/src/app/home/states/home/home.component.ts +++ b/src/app/home/states/home/home.component.ts @@ -42,6 +42,7 @@ export class HomeComponent implements OnInit, OnDestroy { ngOnInit(): void { this.AnalyticsService.event('Home', 'Viewed Home page'); this.globalState.setView(ViewType.OTHER); + this.globalState.showHeader(); this.testForNewUserWizard(); diff --git a/src/app/projects/states/index/global-state.service.ts b/src/app/projects/states/index/global-state.service.ts index f2ba6a341..1c5daca79 100644 --- a/src/app/projects/states/index/global-state.service.ts +++ b/src/app/projects/states/index/global-state.service.ts @@ -1,5 +1,5 @@ import { Inject, Injectable } from '@angular/core'; -import { BehaviorSubject } from 'rxjs'; +import { BehaviorSubject, Subject } from 'rxjs'; import { projectService, unitService } from 'src/app/ajs-upgraded-providers'; export class DoubtfireViewState { @@ -52,6 +52,8 @@ export class GlobalStateService { */ public projectsSubject: BehaviorSubject = new BehaviorSubject(null); + public showHideHeader: Subject = new Subject(); + constructor(@Inject(unitService) private UnitService: any, @Inject(projectService) private ProjectService: any) { this.loadUnitsAndProjects(); } @@ -84,4 +86,18 @@ export class GlobalStateService { public setView(kind: ViewType, entity?: any) { this.currentViewAndEntitySubject.next({ viewType: kind, entity: entity }); } + + /** + * Show the header + */ + public showHeader() { + this.showHideHeader.next(true); + } + + /** + * Show the header + */ + public hideHeader() { + this.showHideHeader.next(false); + } } diff --git a/src/app/sessions/states/sign-in/sign-in.coffee b/src/app/sessions/states/sign-in/sign-in.coffee index 96297a703..0a4200bc0 100644 --- a/src/app/sessions/states/sign-in/sign-in.coffee +++ b/src/app/sessions/states/sign-in/sign-in.coffee @@ -18,6 +18,7 @@ angular.module("doubtfire.sessions.states.sign-in", []) .controller("SignInCtrl", ($scope, $state, $stateParams, DoubtfireConstants, usernameCookie, $timeout, $http, $modal, currentUser, auth, alertService, localStorageService, rememberDoubtfireCredentialsCookie, doubtfireLoginTimeCookie, AboutDoubtfireModal, GlobalStateService) -> GlobalStateService.setView("OTHER") + GlobalStateService.hideHeader() # we aren't logged in yet... isIE = -> window.navigator.appName is "Microsoft Internet Explorer" ieVersion = -> @@ -82,6 +83,7 @@ angular.module("doubtfire.sessions.states.sign-in", []) if auth.isAuthenticated() $state.go "home" + GlobalStateService.showHeader() else $scope.signIn = (signInCredentials) -> $scope.signingIn = true diff --git a/src/app/sessions/states/sign-out/sign-out.coffee b/src/app/sessions/states/sign-out/sign-out.coffee index a74ee40ae..e966bb237 100644 --- a/src/app/sessions/states/sign-out/sign-out.coffee +++ b/src/app/sessions/states/sign-out/sign-out.coffee @@ -16,6 +16,7 @@ angular.module("doubtfire.sessions.states.sign-out", []) ) .controller("SignOutCtrl", ($state, $timeout, $http, auth, DoubtfireConstants, currentUser, GlobalStateService) -> auth.signOut() + GlobalStateService.hideHeader() GlobalStateService.setView("OTHER") GlobalStateService.clearUnitsAndProjects()