Skip to content

Commit

Permalink
add Module ts interface + fix bad redirect of Accueil button in Hom…
Browse files Browse the repository at this point in the history
…ePage
  • Loading branch information
jacquesfize authored and Pierre-Narcisi committed Mar 14, 2024
1 parent e09f86f commit 0fcd5f5
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 2 deletions.
2 changes: 2 additions & 0 deletions frontend/src/app/components/nav-home/nav-home.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ export class NavHomeComponent implements OnInit, OnDestroy {

// Set the current module name in the navbar
this.onModuleChange();


// Init the sidenav instance in sidebar service
this.sideNavService.setSideNav(this.sidenav);
Expand Down Expand Up @@ -80,6 +81,7 @@ export class NavHomeComponent implements OnInit, OnDestroy {
private onModuleChange() {
this._moduleService.currentModule$.subscribe((module) => {
if (!module) {
// If in Home Page
module = this.sideNavService.getHomeItem();
module.module_doc_url = this._moduleService.geoNatureModule.module_doc_url;
}
Expand Down
9 changes: 7 additions & 2 deletions frontend/src/app/components/sidenav-items/sidenav-service.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { Injectable } from '@angular/core';
import { MatSidenav } from '@angular/material/sidenav';
import { Module } from '@geonature/models/module.model';
import { Subject } from 'rxjs';

@Injectable()
Expand Down Expand Up @@ -30,8 +31,12 @@ export class SideNavService {
return this.currentModule;
}

getHomeItem() {
return { module_url: '/', module_label: 'Accueil', module_picto: 'fa-home', id: '1' };
getHomeItem() : Module {
let abs_path = '/';
if (window.location.pathname) { // for GeoNature URL like https://demo.geonature.fr/geonature/
abs_path = window.location.pathname;
}
return { module_url: abs_path, module_label: 'Accueil', module_picto: 'fa-home', id_module: 1, module_path: "/geonature"};
}

toggleSideNav() {
Expand Down
8 changes: 8 additions & 0 deletions frontend/src/app/models/module.model.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
export interface Module{
id_module: number;
module_label: string;
module_picto?: string;
module_path:string;
module_doc_url?: string;
module_url?: string;
}

0 comments on commit 0fcd5f5

Please sign in to comment.