From 4229699c6d886a9923459994ac5765a5ce36f195 Mon Sep 17 00:00:00 2001
From: "mathias.chouet" <mathias.chouet@irstea.fr>
Date: Tue, 22 Sep 2020 10:17:17 +0200
Subject: [PATCH] PreBarrage: show selected item in results panel title

---
 .../generic-calculator/calculator.component.ts  | 17 ++++++++++++++++-
 src/locale/messages.en.json                     |  2 ++
 src/locale/messages.fr.json                     |  2 ++
 3 files changed, 20 insertions(+), 1 deletion(-)

diff --git a/src/app/components/generic-calculator/calculator.component.ts b/src/app/components/generic-calculator/calculator.component.ts
index 49d0ac47b..221c69c1e 100644
--- a/src/app/components/generic-calculator/calculator.component.ts
+++ b/src/app/components/generic-calculator/calculator.component.ts
@@ -20,6 +20,7 @@ import {
     ParSimulationParams,
     ParSimulation,
     PreBarrage,
+    PbCloison,
     Espece,
     VariatedDetails
 } from "jalhyd";
@@ -53,6 +54,7 @@ import { FormulairePrebarrage } from "../../formulaire/definition/form-prebarrag
 import { HotkeysService, Hotkey } from "angular2-hotkeys";
 
 import { MatomoTracker } from "ngx-matomo";
+import { sprintf } from 'sprintf-js';
 
 @Component({
     selector: "hydrocalc",
@@ -229,7 +231,20 @@ export class GenericCalculatorComponent implements OnInit, DoCheck, AfterViewChe
     }
 
     public get uitextResultsTitle() {
-        return this.intlService.localizeText("INFO_CALCULATOR_RESULTS_TITLE");
+        let title = this.intlService.localizeText("INFO_CALCULATOR_RESULTS_TITLE");
+        if (this.isPB) {
+            const selectedItem = (this._formulaire as FormulairePrebarrage).selectedItem;
+            if (selectedItem instanceof PbCloison) {
+                // suffix with wall name
+                title = sprintf(
+                    this.intlService.localizeText("INFO_CALCULATOR_RESULTS_TITLE_PB_WALL"),
+                    this.intlService.localizeMessage(selectedItem.description)
+                );
+            } else {
+                title = this.intlService.localizeText("INFO_CALCULATOR_RESULTS_TITLE_PB_BASINS");
+            }
+        }
+        return title;
     }
 
     public get uitextGeneratePAB() {
diff --git a/src/locale/messages.en.json b/src/locale/messages.en.json
index f3b269f33..cc742db9b 100644
--- a/src/locale/messages.en.json
+++ b/src/locale/messages.en.json
@@ -90,6 +90,8 @@
     "INFO_CALCULATOR_RESULTS_GENERATE_SP_AMONT": "Hydraulic details of upstream section",
     "INFO_CALCULATOR_RESULTS_GENERATE_SP_AVAL": "Hydraulic details of downstream section",
     "INFO_CALCULATOR_RESULTS_TITLE": "Results",
+    "INFO_CALCULATOR_RESULTS_TITLE_PB_BASINS": "Basins results",
+    "INFO_CALCULATOR_RESULTS_TITLE_PB_WALL": "Résults for %s",
     "INFO_CALCULATOR_SAVE": "Save",
     "INFO_CALCULATOR_USED_BY": "Used by",
     "INFO_CALCULATOR_VALEURS": "Values",
diff --git a/src/locale/messages.fr.json b/src/locale/messages.fr.json
index 5f9abffd1..9fba60cb0 100644
--- a/src/locale/messages.fr.json
+++ b/src/locale/messages.fr.json
@@ -90,6 +90,8 @@
     "INFO_CALCULATOR_RESULTS_GENERATE_SP_AMONT": "Détails hydrauliques de la section amont",
     "INFO_CALCULATOR_RESULTS_GENERATE_SP_AVAL": "Détails hydrauliques de la section aval",
     "INFO_CALCULATOR_RESULTS_TITLE": "Résultats",
+    "INFO_CALCULATOR_RESULTS_TITLE_PB_BASINS": "Résultats des bassins",
+    "INFO_CALCULATOR_RESULTS_TITLE_PB_WALL": "Résultats de %s",
     "INFO_CALCULATOR_SAVE": "Enregistrer",
     "INFO_CALCULATOR_USED_BY": "Utilisé par",
     "INFO_CALCULATOR_VALEURS": "Valeurs",
-- 
GitLab