From 9dd805c3e84da100a32ed53b2ce4e96e39a1b2a3 Mon Sep 17 00:00:00 2001
From: "mathias.chouet" <mathias.chouet@irstea.fr>
Date: Wed, 25 Sep 2019 11:25:23 +0200
Subject: [PATCH] Modules diagram: show which linked parameters are calculated

---
 .../modules-diagram/modules-diagram.component.html |  3 +++
 .../modules-diagram/modules-diagram.component.ts   | 14 +++++++++-----
 src/locale/messages.en.json                        |  1 +
 src/locale/messages.fr.json                        |  1 +
 4 files changed, 14 insertions(+), 5 deletions(-)

diff --git a/src/app/components/modules-diagram/modules-diagram.component.html b/src/app/components/modules-diagram/modules-diagram.component.html
index 4eaa708ce..2eeab473b 100644
--- a/src/app/components/modules-diagram/modules-diagram.component.html
+++ b/src/app/components/modules-diagram/modules-diagram.component.html
@@ -12,6 +12,9 @@
 
         <div id="diagram" #diagram></div>
 
+        <div id="diagram-legend">
+            * {{ uitextCalculatedParam }}
+        </div>
         <!-- <a class="show-debug" (click)="initSvgPanZoom()">init zoom </a> -->
 
         <!-- <a class="show-debug" (click)="showDebug = ! showDebug"> debug</a> -->
diff --git a/src/app/components/modules-diagram/modules-diagram.component.ts b/src/app/components/modules-diagram/modules-diagram.component.ts
index 1c91b462a..3b63fb531 100644
--- a/src/app/components/modules-diagram/modules-diagram.component.ts
+++ b/src/app/components/modules-diagram/modules-diagram.component.ts
@@ -63,6 +63,10 @@ export class ModulesDiagramComponent implements AfterContentInit, AfterViewCheck
         return this.intlService.localizeText("INFO_DIAGRAM_DRAWING_ERROR");
     }
 
+    public get uitextCalculatedParam(): string {
+        return this.intlService.localizeText("INFO_DIAGRAM_CALCULATED_PARAM");
+    }
+
     public ngAfterViewChecked() {
         if (this.needsToInitSvgPanZoom) {
             this.initSvgPanZoom();
@@ -175,11 +179,11 @@ export class ModulesDiagramComponent implements AfterContentInit, AfterViewCheck
             for (const p of nub.parameterIterator) {
                 if (p.valueMode === ParamValueMode.LINK && p.isReferenceDefined()) {
                     const target = p.referencedValue.nub;
-                    // move all children links to parent for now (sections, structures...)
-                    /* if (target.parent !== undefined) {
-                        target = target.parent;
-                    } */
-                    def.push(nub.uid + "-->|" + p.symbol + "|" + target.uid);
+                    let symb = p.symbol;
+                    if (p.referencedValue.isCalculated()) {
+                        symb += "*";
+                    }
+                    def.push(nub.uid + "-->|" + symb + "|" + target.uid);
                 }
             }
         }
diff --git a/src/locale/messages.en.json b/src/locale/messages.en.json
index 2a5fbddb0..6bf3734ab 100644
--- a/src/locale/messages.en.json
+++ b/src/locale/messages.en.json
@@ -74,6 +74,7 @@
     "INFO_DEVER_TITRE": "Free flow weir stage-discharge laws",
     "INFO_DIAGRAM_TITLE": "Calculation modules diagram",
     "INFO_DIAGRAM_DRAWING_ERROR": "Error while drawing diagram",
+    "INFO_DIAGRAM_CALCULATED_PARAM": "calculated parameter",
     "INFO_DIALOG_COMPUTED_VALUE_TITLE": "Edit initial value",
     "INFO_DIALOG_EDIT_PAB_INTERPOLATION_BOUNDS": "between %s and %s",
     "INFO_DIALOG_EDIT_PAB_N_DEVICES": "%s device(s)",
diff --git a/src/locale/messages.fr.json b/src/locale/messages.fr.json
index a9211fb76..dd9b7a791 100644
--- a/src/locale/messages.fr.json
+++ b/src/locale/messages.fr.json
@@ -74,6 +74,7 @@
     "INFO_DEVER_TITRE": "Lois de déversoirs dénoyés",
     "INFO_DIAGRAM_TITLE": "Diagramme des modules de calcul",
     "INFO_DIAGRAM_DRAWING_ERROR": "Erreur lors du dessin du diagramme",
+    "INFO_DIAGRAM_CALCULATED_PARAM": "paramètre calculé",
     "INFO_DIALOG_COMPUTED_VALUE_TITLE": "Modifier la valeur initiale",
     "INFO_DIALOG_EDIT_PAB_INTERPOLATION_BOUNDS": "entre %s et %s",
     "INFO_DIALOG_EDIT_PAB_N_DEVICES": "%s ouvrage(s)",
-- 
GitLab