From a64fa36b3d134a3a04990bb0b9b8eda9ae8f91e5 Mon Sep 17 00:00:00 2001 From: "mathias.chouet" <mathias.chouet@irstea.fr> Date: Fri, 25 Jan 2019 10:37:14 +0100 Subject: [PATCH] Fix #106 --- src/app/app.component.html | 9 ++++++++- src/app/app.component.ts | 16 +++++++++++++++- src/locale/messages.en.json | 1 + src/locale/messages.fr.json | 1 + 4 files changed, 25 insertions(+), 2 deletions(-) diff --git a/src/app/app.component.html b/src/app/app.component.html index ca2794862..549dff498 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 f83d8007f..a6607adc6 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 c6f0d1796..7b28cd7c1 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 ea07fae8e..4e5037eb7 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é", -- GitLab