[31468] Don't set body class on root url

The overview dashboard matches `/projects/X/` and `/` due to projects
being optional. I haven't found a way to restrict the URL with ui-router
unfortunately.

Thus I set the body class in the abstract grid component instead.

https://community.openproject.com/wp/31468
pull/7806/head
Oliver Günther 5 years ago
parent b3a4f970bd
commit 5dffdb4919
No known key found for this signature in database
GPG Key ID: A3A8BDAD7C0C552C
  1. 10
      frontend/src/app/modules/grids/grid/page/grid-page.component.ts
  2. 1
      frontend/src/app/modules/overview/openproject-overview.module.ts

@ -1,4 +1,4 @@
import {ChangeDetectorRef, OnInit} from '@angular/core'; import {ChangeDetectorRef, OnDestroy, OnInit, Renderer2} from '@angular/core';
import {I18nService} from "core-app/modules/common/i18n/i18n.service"; import {I18nService} from "core-app/modules/common/i18n/i18n.service";
import {Title} from '@angular/platform-browser'; import {Title} from '@angular/platform-browser';
import {GridInitializationService} from "core-app/modules/grids/grid/initialization.service"; import {GridInitializationService} from "core-app/modules/grids/grid/initialization.service";
@ -8,7 +8,7 @@ import {GridAddWidgetService} from "core-app/modules/grids/grid/add-widget.servi
import {GridAreaService} from "core-app/modules/grids/grid/area.service"; import {GridAreaService} from "core-app/modules/grids/grid/area.service";
import {CurrentProjectService} from "core-components/projects/current-project.service"; import {CurrentProjectService} from "core-components/projects/current-project.service";
export abstract class GridPageComponent implements OnInit { export abstract class GridPageComponent implements OnInit, OnDestroy {
public text = { title: this.i18n.t(`js.${this.i18nNamespace()}.label`), public text = { title: this.i18n.t(`js.${this.i18nNamespace()}.label`),
html_title: this.i18n.t(`js.${this.i18nNamespace()}.label`) }; html_title: this.i18n.t(`js.${this.i18nNamespace()}.label`) };
@ -20,11 +20,13 @@ export abstract class GridPageComponent implements OnInit {
readonly cdRef:ChangeDetectorRef, readonly cdRef:ChangeDetectorRef,
readonly title:Title, readonly title:Title,
readonly addWidget:GridAddWidgetService, readonly addWidget:GridAddWidgetService,
readonly renderer:Renderer2,
readonly areas:GridAreaService) {} readonly areas:GridAreaService) {}
public grid:GridResource; public grid:GridResource;
ngOnInit() { ngOnInit() {
this.renderer.addClass(document.body, 'widget-grid-layout');
this this
.gridInitialization .gridInitialization
.initialize(this.gridScopePath()) .initialize(this.gridScopePath())
@ -36,6 +38,10 @@ export abstract class GridPageComponent implements OnInit {
this.setHtmlTitle(); this.setHtmlTitle();
} }
ngOnDestroy():void {
this.renderer.removeClass(document.body, 'widget-grid-layout');
}
private setHtmlTitle() { private setHtmlTitle() {
this.title.setTitle(this.text.html_title); this.title.setTitle(this.text.html_title);
} }

@ -42,7 +42,6 @@ export const OVERVIEW_ROUTES:Ng2StateDeclaration[] = [
// cf., https://community.openproject.com/wp/29754 // cf., https://community.openproject.com/wp/29754
url: '/', url: '/',
data: { data: {
bodyClasses: ['router--overview-view-base', 'widget-grid-layout'],
menuItem: menuItemClass menuItem: menuItemClass
}, },
component: OverviewComponent component: OverviewComponent

Loading…
Cancel
Save