From 3b20bdd6dc7402b0723e038c57f0606131e20e54 Mon Sep 17 00:00:00 2001 From: Rigel Kent Date: Sat, 7 Mar 2020 13:50:26 +0100 Subject: Servicify menu, close menu on admin for small and medium screens --- client/src/app/app.component.ts | 29 +++++------------------------ 1 file changed, 5 insertions(+), 24 deletions(-) (limited to 'client/src/app/app.component.ts') diff --git a/client/src/app/app.component.ts b/client/src/app/app.component.ts index 59966243b..629549ef2 100644 --- a/client/src/app/app.component.ts +++ b/client/src/app/app.component.ts @@ -18,6 +18,7 @@ import { InstanceConfigWarningModalComponent } from '@app/modal/instance-config- import { ServerConfig, UserRole } from '@shared/models' import { User } from '@app/shared' import { InstanceService } from '@app/shared/instance/instance.service' +import { MenuService } from './core/menu/menu.service' @Component({ selector: 'my-app', @@ -28,9 +29,6 @@ export class AppComponent implements OnInit { @ViewChild('welcomeModal') welcomeModal: WelcomeModalComponent @ViewChild('instanceConfigWarningModal') instanceConfigWarningModal: InstanceConfigWarningModalComponent - isMenuDisplayed = true - isMenuChangedByUser = false - customCSS: SafeHtml private serverConfig: ServerConfig @@ -50,7 +48,8 @@ export class AppComponent implements OnInit { private themeService: ThemeService, private hooks: HooksService, private location: PlatformLocation, - private modalService: NgbModal + private modalService: NgbModal, + public menu: MenuService ) { } get instanceName () { @@ -78,21 +77,12 @@ export class AppComponent implements OnInit { this.authService.refreshUserInformation() } - // Do not display menu on small screens - if (this.screenService.isInSmallView()) { - this.isMenuDisplayed = false - } - this.initRouteEvents() this.injectJS() this.injectCSS() this.initHotkeys() - fromEvent(window, 'resize') - .pipe(debounceTime(200)) - .subscribe(() => this.onResize()) - this.location.onPopState(() => this.modalService.dismissAll(POP_STATE_MODAL_DISMISS)) this.openModalsIfNeeded() @@ -102,15 +92,6 @@ export class AppComponent implements OnInit { return this.authService.isLoggedIn() } - toggleMenu () { - this.isMenuDisplayed = !this.isMenuDisplayed - this.isMenuChangedByUser = true - } - - onResize () { - this.isMenuDisplayed = window.innerWidth >= 800 && !this.isMenuChangedByUser - } - private initRouteEvents () { let resetScroll = true const eventsObs = this.router.events @@ -176,7 +157,7 @@ export class AppComponent implements OnInit { eventsObs.pipe( filter((e: Event): e is GuardsCheckStart => e instanceof GuardsCheckStart), filter(() => this.screenService.isInSmallView()) - ).subscribe(() => this.isMenuDisplayed = false) // User clicked on a link in the menu, change the page + ).subscribe(() => this.menu.isMenuDisplayed = false) // User clicked on a link in the menu, change the page } private injectJS () { @@ -249,7 +230,7 @@ export class AppComponent implements OnInit { }, undefined, this.i18n('Focus the search bar')), new Hotkey('b', (event: KeyboardEvent): boolean => { - this.toggleMenu() + this.menu.toggleMenu() return false }, undefined, this.i18n('Toggle the left menu')), -- cgit v1.2.3