From 40bff3f0b4e2045c1682085afa11fb124f7ceb31 Mon Sep 17 00:00:00 2001
From: Jean-Pascal <jean-pascal.aubry@inrae.fr>
Date: Thu, 30 May 2024 09:06:14 +0000
Subject: [PATCH 1/7] fix: change way to get search parameter related
 calculator title Refs #668

---
 .../elements/select/select-field-searched-param.ts    |  5 +++--
 src/app/services/formulaire.service.ts                | 11 +++++++++++
 2 files changed, 14 insertions(+), 2 deletions(-)

diff --git a/src/app/formulaire/elements/select/select-field-searched-param.ts b/src/app/formulaire/elements/select/select-field-searched-param.ts
index 8811ef81f..2b5e1a501 100644
--- a/src/app/formulaire/elements/select/select-field-searched-param.ts
+++ b/src/app/formulaire/elements/select/select-field-searched-param.ts
@@ -23,11 +23,12 @@ export class SelectFieldSearchedParam extends SelectField {
             ntc,
             solv.targettedResult !== undefined && solv.targettedResult !== ""
         );
+
         for (const p of searchableParams) {
             if (p.visible) {
-                const calc = fs.getFormulaireFromId(p.originNub.uid).calculatorName;
+                const calcTitle = fs.getTitlebyIdOnSelectedLoadedNubs(p.originNub.uid).title;
                 const varName = fs.expandVariableName(p.originNub.calcType, p.symbol);
-                const label = `${p.symbol} - ${varName} (${calc})`;
+                const label = `${p.symbol} - ${varName} (${calcTitle})`;
                 this.addEntry(this.createOrGetEntry(this._entriesBaseId + p.getParentComputeNode(false).uid + "_" + p.symbol, p, decodeHtml(label)));
             }
         }
diff --git a/src/app/services/formulaire.service.ts b/src/app/services/formulaire.service.ts
index ad8d6b1b1..24c3c820b 100644
--- a/src/app/services/formulaire.service.ts
+++ b/src/app/services/formulaire.service.ts
@@ -71,6 +71,8 @@ export class FormulaireService extends Observable {
 
     private _currentFormId: string = null;
 
+    private _selectedLoadedNubs: any[] = [];
+
     public static getConfigPathPrefix(ct: CalculatorType): string {
         const ctName = CalculatorType[ct].toLowerCase();
         return "app/calculators/" + ctName + "/";
@@ -91,6 +93,10 @@ export class FormulaireService extends Observable {
         return this._formulaires;
     }
 
+    public getTitlebyIdOnSelectedLoadedNubs(uid: string) {
+        return this._selectedLoadedNubs.find(selectedNub => selectedNub.uid === uid)
+    }
+
     /** Removes all formulaires from the list */
     public clearFormulaires() {
         this._formulaires = [];
@@ -646,6 +652,7 @@ export class FormulaireService extends Observable {
             // disable "empty fields" flag temporarly
             const emptyFields = ServiceFactory.applicationSetupService.enableEmptyFieldsOnFormInit;
             ServiceFactory.applicationSetupService.enableEmptyFieldsOnFormInit = false;
+            this._selectedLoadedNubs = formInfos;
 
             let s;
             if (i instanceof Blob) {
@@ -700,6 +707,10 @@ export class FormulaireService extends Observable {
         }
     }
 
+    getSelectedLoadedNubs() {
+        return this._selectedLoadedNubs;
+    }
+
     /**
      * Sends an UTF-8 text file for download
      */
-- 
GitLab


From 5b5cf8a949e04f3cf5858654c907f03246d85fac Mon Sep 17 00:00:00 2001
From: Jean-Pascal <jean-pascal.aubry@inrae.fr>
Date: Thu, 30 May 2024 14:30:33 +0000
Subject: [PATCH 2/7] fix: update jalhyd_branch Refs #669

---
 jalhyd_branch | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/jalhyd_branch b/jalhyd_branch
index 567bd6c9f..cd7e102f5 100644
--- a/jalhyd_branch
+++ b/jalhyd_branch
@@ -1 +1 @@
-340-devel
+374-solveur-les-select-d-une-session-chargee-ne-s-initialise-pas
-- 
GitLab


From 8114dc6421fc915bb690b8d6678da3265a9f838c Mon Sep 17 00:00:00 2001
From: Jean-Pascal <jean-pascal.aubry@inrae.fr>
Date: Thu, 30 May 2024 15:19:03 +0000
Subject: [PATCH 3/7] fix: add a conditionnal statement on search param field
 populate Refs #668

---
 .../elements/select/select-field-searched-param.ts     | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/src/app/formulaire/elements/select/select-field-searched-param.ts b/src/app/formulaire/elements/select/select-field-searched-param.ts
index 2b5e1a501..978cdebc9 100644
--- a/src/app/formulaire/elements/select/select-field-searched-param.ts
+++ b/src/app/formulaire/elements/select/select-field-searched-param.ts
@@ -26,7 +26,15 @@ export class SelectFieldSearchedParam extends SelectField {
 
         for (const p of searchableParams) {
             if (p.visible) {
-                const calcTitle = fs.getTitlebyIdOnSelectedLoadedNubs(p.originNub.uid).title;
+                let calcTitle;
+                // if form already exist
+                if(fs.getFormulaireFromId(p.originNub.uid)) {
+                    calcTitle = fs.getFormulaireFromId(p.originNub.uid).calculatorName;
+                }
+                // prevent issue #369 (loading session)
+                else {
+                    calcTitle = fs.getTitlebyIdOnSelectedLoadedNubs(p.originNub.uid).title;
+                }
                 const varName = fs.expandVariableName(p.originNub.calcType, p.symbol);
                 const label = `${p.symbol} - ${varName} (${calcTitle})`;
                 this.addEntry(this.createOrGetEntry(this._entriesBaseId + p.getParentComputeNode(false).uid + "_" + p.symbol, p, decodeHtml(label)));
-- 
GitLab


From 296b5750e30c90eb4abde51732e4aab0b744499f Mon Sep 17 00:00:00 2001
From: Jean-Pascal <jean-pascal.aubry@inrae.fr>
Date: Fri, 31 May 2024 15:10:46 +0000
Subject: [PATCH 4/7] feature: add translation for error message when solver
 selects are empty Refs #668

---
 src/locale/messages.en.json | 2 ++
 src/locale/messages.fr.json | 2 ++
 2 files changed, 4 insertions(+)

diff --git a/src/locale/messages.en.json b/src/locale/messages.en.json
index 97467b28b..8dbb4ec8b 100755
--- a/src/locale/messages.en.json
+++ b/src/locale/messages.en.json
@@ -678,6 +678,8 @@
     "INFO_TRIGO_DESCRIPTION": "cosinus sinus tangent arc maths mathematics",
     "INFO_TRIGO_TITRE_COURT": "Trigo. f.",
     "INFO_VERIF_CREATE_PASS_FRIST": "Create first a fish ladder, a baffle fishway or a rock-ramp fishpass",
+    "INFO_VERIF_CREATE_ATLEAST_ONE_TARGETNUB": "Create at least one targetted nub",
+    "INFO_VERIF_SOLVER_SEARCHED_PARAM": "Select another target result",
     "INFO_VERIF_SELECT_SPECIES_FIRST": "Select first one or several fish species",
     "INFO_VERIF_OK": "Crossing criteria are met for all species",
     "INFO_VERIF_VARYING_OK": "Crossing criteria are met for all species and all pass modalities",
diff --git a/src/locale/messages.fr.json b/src/locale/messages.fr.json
index e8b2752fc..5b08c1839 100755
--- a/src/locale/messages.fr.json
+++ b/src/locale/messages.fr.json
@@ -679,6 +679,8 @@
     "INFO_TRIGO_DESCRIPTION": "cosinus sinus tangente arc maths mathématiques",
     "INFO_TRIGO_TITRE_COURT": "F. trigo.",
     "INFO_VERIF_CREATE_PASS_FRIST": "Créer d'abord une passe à bassins, à ralentisseurs, ou à macrorugosités",
+    "INFO_VERIF_CREATE_ATLEAST_ONE_TARGETNUB": "Créer au moins un module cible",
+    "INFO_VERIF_SOLVER_SEARCHED_PARAM": "Sélectionner un autre résultat cible",
     "INFO_VERIF_SELECT_SPECIES_FIRST": "Selectionner d'abord une ou plusieurs espèces",
     "INFO_VERIF_OK": "Les critères de franchissement sont remplis pour toutes les espèces",
     "INFO_VERIF_VARYING_OK": "Les critères de franchissement sont remplis pour toutes les espèces et toutes les modalités de la passe",
-- 
GitLab


From 0c2247bff92baf730320dbbb7141afeb6b31b61a Mon Sep 17 00:00:00 2001
From: Jean-Pascal <jean-pascal.aubry@inrae.fr>
Date: Mon, 3 Jun 2024 13:50:58 +0000
Subject: [PATCH 5/7] fix: set mat error style as error empty field

---
 src/styles.scss | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/src/styles.scss b/src/styles.scss
index 2ecd7a51f..01a0d98c9 100644
--- a/src/styles.scss
+++ b/src/styles.scss
@@ -33,6 +33,10 @@ button {
     to { transform: translateX(400%); } */
 }
 
+.mat-error {
+    font-size: 14px !important;
+    font-weight: 500 !important;
+}
 // --------- bootstrap inspired styles ---------
 
 h1 {
-- 
GitLab


From 1522b18cd93b5ee0c4126d7e085d6007a4c818dc Mon Sep 17 00:00:00 2001
From: Jean-Pascal <jean-pascal.aubry@inrae.fr>
Date: Mon, 3 Jun 2024 15:06:22 +0000
Subject: [PATCH 6/7] fix: display solver field labels and empty error messages
 Refs #                 668

---
 .../formulaire/elements/formulaire-element.ts |  7 +++---
 .../select/select-field-searched-param.ts     | 13 ++++++++---
 .../select-field-solver-targeted-result.ts    |  3 ++-
 .../select/select-field-solveur-target.ts     | 12 ++++++++--
 .../elements/select/select-field.ts           | 22 ++++++++++---------
 5 files changed, 37 insertions(+), 20 deletions(-)

diff --git a/src/app/formulaire/elements/formulaire-element.ts b/src/app/formulaire/elements/formulaire-element.ts
index 25b5943fa..6005f2baa 100644
--- a/src/app/formulaire/elements/formulaire-element.ts
+++ b/src/app/formulaire/elements/formulaire-element.ts
@@ -71,13 +71,12 @@ export abstract class FormulaireElement extends FormulaireNode {
 
     /**
      * Updates localisation for this element: first the label then all the element's children
-     * @param loc calculator-specific localised messages map
-     * @param key Element label key
+     * @param fromConfig if false avoid call of selectField.updateLocalisation()
      */
-    public updateLocalisation() {
+    public updateLocalisation(fromConfig: boolean = true) {
         this._label = this.formulaireService.localizeText(this._confId, this.parentForm.currentNub.calcType);
         for (const f of this.getKids()) {
-            f.updateLocalisation();
+            f.updateLocalisation(fromConfig);
         }
     }
 
diff --git a/src/app/formulaire/elements/select/select-field-searched-param.ts b/src/app/formulaire/elements/select/select-field-searched-param.ts
index 978cdebc9..c4b2c779d 100644
--- a/src/app/formulaire/elements/select/select-field-searched-param.ts
+++ b/src/app/formulaire/elements/select/select-field-searched-param.ts
@@ -3,6 +3,8 @@ import { decodeHtml } from "app/util/util";
 import { acSection, Nub, Solveur } from "jalhyd";
 import { SelectEntry } from "./select-entry";
 import { SelectField } from "./select-field";
+import { FormulaireNode } from "../formulaire-node";
+import { FormulaireElement } from "../formulaire-element";
 
 /*
     "id": "select_searched_param",
@@ -12,6 +14,11 @@ import { SelectField } from "./select-field";
 
 // Solveur, paramètre recherché (à faire varier)
 export class SelectFieldSearchedParam extends SelectField {
+    constructor(parent: FormulaireNode) {
+        super(parent);
+        this._messageWhenEmpty = "INFO_VERIF_SOLVER_SEARCHED_PARAM";
+    }
+
     protected populate() {
         const fs = ServiceFactory.formulaireService;
 
@@ -28,7 +35,7 @@ export class SelectFieldSearchedParam extends SelectField {
             if (p.visible) {
                 let calcTitle;
                 // if form already exist
-                if(fs.getFormulaireFromId(p.originNub.uid)) {
+                if (fs.getFormulaireFromId(p.originNub.uid)) {
                     calcTitle = fs.getFormulaireFromId(p.originNub.uid).calculatorName;
                 }
                 // prevent issue #369 (loading session)
@@ -58,7 +65,7 @@ export class SelectFieldSearchedParam extends SelectField {
     }
 
     public updateLocalisation() {
-        // do not override localisation done in populate()
-        // ie. avoid what is done by SelectField.updateLocalisation()
+        // call grand parent updateLocalisation()
+        super.updateLocalisation(false);
     }
 }
diff --git a/src/app/formulaire/elements/select/select-field-solver-targeted-result.ts b/src/app/formulaire/elements/select/select-field-solver-targeted-result.ts
index 36094a8dd..fd1537b40 100644
--- a/src/app/formulaire/elements/select/select-field-solver-targeted-result.ts
+++ b/src/app/formulaire/elements/select/select-field-solver-targeted-result.ts
@@ -40,7 +40,8 @@ export class SelectFieldSolverTargetedResult extends SelectField {
     }
 
     public updateLocalisation() {
-        FormulaireElement.prototype.updateLocalisation.call(this);
+        // call grand parent updateLocalisation()
+        super.updateLocalisation(false);
         for (const e of this._entries) {
             // @WARNING clodo hack for Solveur
             // 1. calculated param
diff --git a/src/app/formulaire/elements/select/select-field-solveur-target.ts b/src/app/formulaire/elements/select/select-field-solveur-target.ts
index 3d752aa43..fb3eba4c3 100644
--- a/src/app/formulaire/elements/select/select-field-solveur-target.ts
+++ b/src/app/formulaire/elements/select/select-field-solveur-target.ts
@@ -9,9 +9,17 @@ import { decodeHtml } from "../../../util/util";
 import { Session, Solveur } from "jalhyd";
 import { SelectEntry } from "./select-entry";
 import { SelectField } from "./select-field";
+import { FormulaireElement } from "../formulaire-element";
+import { FormulaireNode } from "../formulaire-node";
 
 // Solveur, module cible (à calculer)
 export class SelectFieldSolverTarget extends SelectField {
+
+    constructor(parent: FormulaireNode) {
+        super(parent);
+        this._messageWhenEmpty = "INFO_VERIF_CREATE_ATLEAST_ONE_TARGETNUB";
+    }
+
     protected populate() {
 
         const fs = ServiceFactory.formulaireService;
@@ -48,7 +56,7 @@ export class SelectFieldSolverTarget extends SelectField {
     }
 
     public updateLocalisation() {
-        // do not override localisation done in populate()
-        // ie. avoid what is done by SelectField.updateLocalisation()
+        // call grand parent updateLocalisation()
+        super.updateLocalisation(false);
     }
 }
diff --git a/src/app/formulaire/elements/select/select-field.ts b/src/app/formulaire/elements/select/select-field.ts
index d4d1cf2c3..425cfd192 100644
--- a/src/app/formulaire/elements/select/select-field.ts
+++ b/src/app/formulaire/elements/select/select-field.ts
@@ -4,7 +4,7 @@ import { arraysAreEqual } from "../../../util/util";
 import { FormulaireNode } from "../formulaire-node";
 import { ServiceFactory } from "app/services/service-factory";
 import { FormulaireDefinition } from "../../definition/form-definition";
-import { enumValueFromString, Message, Nub } from "jalhyd";
+import { enumValueFromString, Message, Nub, PabChute, SectionNub } from "jalhyd";
 
 export abstract class SelectField extends Field {
 
@@ -296,7 +296,7 @@ export abstract class SelectField extends Field {
     public isEmptySelectField() {
         return this._selectedEntry !== undefined && Object.keys(this._selectedEntry).length === 0;
     }
-    
+
 
     public get messageWhenEmpty(): string {
         let msg: string;
@@ -314,15 +314,17 @@ export abstract class SelectField extends Field {
         return this._multiple;
     }
 
-    public updateLocalisation() {
+    public updateLocalisation(fromConfig: boolean = true) {
         super.updateLocalisation();
-        for (const e of this._entries) {
-            const aId = e.id.split("_");
-            const trad = ServiceFactory.formulaireService.localizeText(
-                `${aId[1].toUpperCase()}_${aId[2]}`,
-                this.parentForm.currentNub.calcType
-            );
-            e.label = trad;
+        if (fromConfig) {
+            for (const e of this._entries) {
+                const aId = e.id.split("_");
+                const trad = ServiceFactory.formulaireService.localizeText(
+                    `${aId[1].toUpperCase()}_${aId[2]}`,
+                    this.parentForm.currentNub.calcType
+                );
+                e.label = trad;
+            }
         }
     }
 }
-- 
GitLab


From ac7d85e7b763f3523ccbea58816942d207218203 Mon Sep 17 00:00:00 2001
From: Jean-Pascal <jean-pascal.aubry@inrae.fr>
Date: Mon, 3 Jun 2024 15:11:01 +0000
Subject: [PATCH 7/7] fix : display target pass field label Refs #668

---
 .../formulaire/elements/select/select-field-target-pass.ts    | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/app/formulaire/elements/select/select-field-target-pass.ts b/src/app/formulaire/elements/select/select-field-target-pass.ts
index 8438e0a0f..e6ef45495 100644
--- a/src/app/formulaire/elements/select/select-field-target-pass.ts
+++ b/src/app/formulaire/elements/select/select-field-target-pass.ts
@@ -48,7 +48,7 @@ export class SelectFieldTargetPass extends SelectField {
     }
 
     public updateLocalisation() {
-        // do not override localisation done in populate()
-        // ie. avoid what is done by SelectField.updateLocalisation()
+        // call grand parent updateLocalisation()
+        super.updateLocalisation(false);
     }
 }
-- 
GitLab