From 42c21f96a39827286cdcee9e2872fa6b51164ade Mon Sep 17 00:00:00 2001
From: Jean-Pascal <jean-pascal.aubry@inrae.fr>
Date: Mon, 22 Jan 2024 15:24:23 +0000
Subject: [PATCH 1/2] fix:  select the right pam when generate back water. Keep
 session state when a session is saved and loaded after. Refs #650

---
 .../generic-calculator/calculator.component.ts    | 11 ++++++-----
 .../elements/select/select-field-target-pam.ts    | 15 ++++++++++-----
 2 files changed, 16 insertions(+), 10 deletions(-)

diff --git a/src/app/components/generic-calculator/calculator.component.ts b/src/app/components/generic-calculator/calculator.component.ts
index e0977639f..52de7313d 100644
--- a/src/app/components/generic-calculator/calculator.component.ts
+++ b/src/app/components/generic-calculator/calculator.component.ts
@@ -26,7 +26,8 @@ import {
     Espece,
     VariatedDetails,
     ParallelStructure,
-    MacrorugoRemous
+    MacrorugoRemous,
+    Props
 } from "jalhyd";
 
 import { generateValuesCombination, getUnformattedIthResult, getUnformattedIthValue } from "../../util/util";
@@ -1273,10 +1274,10 @@ export class GenericCalculatorComponent implements OnInit, DoCheck, AfterViewChe
     }
 
     public async generateBackwaterInPAM() {
-        const f: FormulaireDefinition = await this.formulaireService.createFormulaire(CalculatorType.MacrorugoRemous);
-        const mrr = (f.currentNub as MacrorugoRemous);
-        mrr.setPropValue("nubMacroRugo", this.formulaire.currentNub.uid);
-        mrr.syncSectionMacroRugo();
+        const nub = Session.getInstance().createSessionNub(
+            new Props({ calcType: CalculatorType.MacrorugoRemous, nubMacroRugo: this.formulaire.currentNub.uid})
+        ) as MacrorugoRemous;
+        const f: FormulaireDefinition = await this.formulaireService.createFormulaire(CalculatorType.MacrorugoRemous, nub);
         this.router.navigate(["/calculator", f.uid]);
     }
 
diff --git a/src/app/formulaire/elements/select/select-field-target-pam.ts b/src/app/formulaire/elements/select/select-field-target-pam.ts
index 3d0c09ad4..99fdd0404 100644
--- a/src/app/formulaire/elements/select/select-field-target-pam.ts
+++ b/src/app/formulaire/elements/select/select-field-target-pam.ts
@@ -4,12 +4,13 @@ import { CalculatorType, MacrorugoRemous, Message, MessageCode, Session } from "
 import { SelectField } from "./select-field";
 import { FormulaireNode } from "../formulaire-node";
 import { SelectEntry } from "./select-entry";
+import { VERSION } from "@angular/core";
 
 // Courbe de remous dans une passe à macro-rugo.
 export class SelectFieldTargetPam extends SelectField {
     constructor(parent: FormulaireNode) {
         super(parent);
-        // this._associatedProperty = MacrorugoRemous.nubMacroRugo;
+        this._associatedProperty = "nubMacroRugo";
         this._messageWhenEmpty = "INFO_MACRORUGOREMOUS_CREATE_PAM_FIRST";
     }
 
@@ -23,15 +24,19 @@ export class SelectFieldTargetPam extends SelectField {
         );
         for (const cn of macroForms) {
             const calc = cn.calculatorName;
-            this.addEntry(this.createOrGetEntry(this._entriesBaseId + cn.uid, cn.uid, decodeHtml(calc)));
+            this.addEntry(this.createOrGetEntry(this._entriesBaseId + cn.uid, cn.uid, decodeHtml(calc)));7
         }
     }
 
     protected initSelectedValue() {
-        const mrr = (this.nub as MacrorugoRemous).nubMacroRugo;
-        if (mrr !== undefined) {
-            this.setValueFromId(this._entriesBaseId + mrr.uid);
+        const MrUID = this.nub.getPropValue("nubMacroRugo")
+        if (MrUID !== undefined) {
+            this.setValueFromId(this._entriesBaseId + MrUID);
         }
+        // const ntv = (this.nub as MacrorugoRemous).nubToVerify;
+        // if (ntv !== undefined) {
+        //     this.setValueFromId(this._entriesBaseId + ntv.uid);
+        // }
     }
 
     public updateLocalisation() {
-- 
GitLab


From af4d441d66344e610933e56842109eab317d78d3 Mon Sep 17 00:00:00 2001
From: Jean-Pascal <jean-pascal.aubry@inrae.fr>
Date: Tue, 23 Jan 2024 08:32:58 +0000
Subject: [PATCH 2/2] fix: remove typing error on select target pam Refs #650

---
 .../formulaire/elements/select/select-field-target-pam.ts   | 6 +-----
 1 file changed, 1 insertion(+), 5 deletions(-)

diff --git a/src/app/formulaire/elements/select/select-field-target-pam.ts b/src/app/formulaire/elements/select/select-field-target-pam.ts
index 99fdd0404..6f2b380d2 100644
--- a/src/app/formulaire/elements/select/select-field-target-pam.ts
+++ b/src/app/formulaire/elements/select/select-field-target-pam.ts
@@ -24,7 +24,7 @@ export class SelectFieldTargetPam extends SelectField {
         );
         for (const cn of macroForms) {
             const calc = cn.calculatorName;
-            this.addEntry(this.createOrGetEntry(this._entriesBaseId + cn.uid, cn.uid, decodeHtml(calc)));7
+            this.addEntry(this.createOrGetEntry(this._entriesBaseId + cn.uid, cn.uid, decodeHtml(calc)));
         }
     }
 
@@ -33,10 +33,6 @@ export class SelectFieldTargetPam extends SelectField {
         if (MrUID !== undefined) {
             this.setValueFromId(this._entriesBaseId + MrUID);
         }
-        // const ntv = (this.nub as MacrorugoRemous).nubToVerify;
-        // if (ntv !== undefined) {
-        //     this.setValueFromId(this._entriesBaseId + ntv.uid);
-        // }
     }
 
     public updateLocalisation() {
-- 
GitLab