diff --git a/src/app/app.component.html b/src/app/app.component.html index ca2794862eea9043082527226751ce9fb714eff1..549dff4987b5846b5d1f593d9236935617653af0 100644 --- a/src/app/app.component.html +++ b/src/app/app.component.html @@ -14,13 +14,20 @@ <!-- calculators list as a dropdown menu--> <div [hidden]="tabsFitInNavbar"> + <button *ngIf="! currentCalc" mat-button [matMenuTriggerFor]="menu" color="primary" class="calculators-menu-title"> + <mat-icon class="dropdown-icon">arrow_drop_down</mat-icon> + <span class="calc-name"> + {{ uitextSelectCalc }} + </span> + </button> <button *ngIf="currentCalc" mat-button [matMenuTriggerFor]="menu" color="primary" class="calculators-menu-title"> <mat-icon class="dropdown-icon">arrow_drop_down</mat-icon> <span class="calc-name"> - {{ currentCalc.title }} + {{ currentCalc.title }} </span> <span class="calc-type" [innerHTML]="'( ' + currentCalc ? currentCalc.type : '' + ' )'"></span> </button> + <mat-menu #menu="matMenu" colo="accent"> <button mat-button *ngFor="let c of calculators" class="calculator-menu-item" [title]="c.title" [routerLink]="['/calculator/',c.uid]" [color]="c.active ? 'primary' : ''" [class.active]="c.active" diff --git a/src/app/app.component.ts b/src/app/app.component.ts index f83d8007f55546bd189a2bcd0d5332ea8abde0c7..a6607adc619e2667e7e66047bf841fea291def20 100644 --- a/src/app/app.component.ts +++ b/src/app/app.component.ts @@ -1,5 +1,5 @@ import { Component, ApplicationRef, OnInit, OnDestroy, HostListener, ViewChild, ComponentRef } from "@angular/core"; -import { Router, Event, NavigationEnd } from "@angular/router"; +import { Router, Event, NavigationEnd, ActivationEnd } from "@angular/router"; import { Observer, jalhydDateRev } from "jalhyd"; @@ -88,6 +88,16 @@ export class AppComponent implements OnInit, OnDestroy, Observer { if (event instanceof NavigationEnd) { this.sidenav.close(); } + // [de]activate calc tabs depending on loaded route + if (event instanceof ActivationEnd) { + const path = event.snapshot.url[0].path; + if (path === "calculator") { + const calcUid = event.snapshot.params.uid; + this.setActiveCalc(calcUid); + } else { + this.setActiveCalc(null); + } + } }); } @@ -134,6 +144,10 @@ export class AppComponent implements OnInit, OnDestroy, Observer { return this.intlService.localizeText("INFO_MENU_HELP_TITLE"); } + public get uitextSelectCalc() { + return this.intlService.localizeText("INFO_MENU_SELECT_CALC"); + } + public get calculators() { return this._calculators; } diff --git a/src/locale/messages.en.json b/src/locale/messages.en.json index c6f0d1796b3bc3e9d259f85ea39180f965242351..7b28cd7c10d90bc9ab8268a4549ca7020accf885 100644 --- a/src/locale/messages.en.json +++ b/src/locale/messages.en.json @@ -115,6 +115,7 @@ "INFO_MENU_LOAD_SESSION_TITLE": "Load session", "INFO_MENU_NOUVELLE_CALC": "New calculation module", "INFO_MENU_SAVE_SESSION_TITLE": "Save session", + "INFO_MENU_SELECT_CALC": "Select calculator module", "INFO_MENU_EMPTY_SESSION_TITLE": "New session", "INFO_OPTION_NO": "No", "INFO_OPTION_YES": "Yes", diff --git a/src/locale/messages.fr.json b/src/locale/messages.fr.json index ea07fae8ea1b7971905e34c2f8e21e8905797961..4e5037eb7db699ee7fd407fd9a8965f3cf32a62f 100644 --- a/src/locale/messages.fr.json +++ b/src/locale/messages.fr.json @@ -110,6 +110,7 @@ "INFO_MENU_HELP_TITLE": "Aide", "INFO_MENU_LOAD_SESSION_TITLE": "Charger une session", "INFO_MENU_SAVE_SESSION_TITLE": "Enregistrer la session", + "INFO_MENU_SELECT_CALC": "Choisir un module de calcul", "INFO_MENU_EMPTY_SESSION_TITLE": "Nouvelle session", "INFO_MENU_NOUVELLE_CALC": "Nouveau module de calcul", "INFO_MACRORUGO_TITRE": "Passe à macro-rugosité",