Skip to content

Commit

Permalink
feat: add new header hiding
Browse files Browse the repository at this point in the history
  • Loading branch information
jakerenzella committed Jan 12, 2022
1 parent 1d34d02 commit a1f77c0
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 1 deletion.
8 changes: 8 additions & 0 deletions src/app/common/header/header.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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
Expand Down
1 change: 1 addition & 0 deletions src/app/home/states/home/home.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand Down
18 changes: 17 additions & 1 deletion src/app/projects/states/index/global-state.service.ts
Original file line number Diff line number Diff line change
@@ -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 {
Expand Down Expand Up @@ -52,6 +52,8 @@ export class GlobalStateService {
*/
public projectsSubject: BehaviorSubject<any> = new BehaviorSubject<any>(null);

public showHideHeader: Subject<boolean> = new Subject<boolean>();

constructor(@Inject(unitService) private UnitService: any, @Inject(projectService) private ProjectService: any) {
this.loadUnitsAndProjects();
}
Expand Down Expand Up @@ -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);
}
}
2 changes: 2 additions & 0 deletions src/app/sessions/states/sign-in/sign-in.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -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 = ->
Expand Down Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions src/app/sessions/states/sign-out/sign-out.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand Down

0 comments on commit a1f77c0

Please sign in to comment.