From eaa6f495c3c51a7a1399a440bb072965e8ffc799 Mon Sep 17 00:00:00 2001
From: "mathias.chouet" <mathias.chouet@irstea.fr>
Date: Thu, 25 Jul 2019 10:21:08 +0200
Subject: [PATCH] Removed CourbeRemous dependencies from config, use hardcoded
 presets from model instead

---
 src/app/calculators/remous/remous.config.json | 148 ++----------------
 .../definition/concrete/form-courbe-remous.ts |   2 +-
 src/app/formulaire/select-field.ts            |  18 ++-
 3 files changed, 26 insertions(+), 142 deletions(-)

diff --git a/src/app/calculators/remous/remous.config.json b/src/app/calculators/remous/remous.config.json
index 8fcdf1c4d..f7ea148e2 100644
--- a/src/app/calculators/remous/remous.config.json
+++ b/src/app/calculators/remous/remous.config.json
@@ -7,96 +7,43 @@
             {
                 "id": "select_section",
                 "type": "select",
-                "select": [
-                    {
-                        "id": "select_section_trapez",
-                        "enum": "ComputeNodeType.SectionTrapeze"
-                    },
-                    {
-                        "id": "select_section_rect",
-                        "enum": "ComputeNodeType.SectionRectangle"
-                    },
-                    {
-                        "id": "select_section_circ",
-                        "enum": "ComputeNodeType.SectionCercle"
-                    },
-                    {
-                        "id": "select_section_puiss",
-                        "enum": "ComputeNodeType.SectionPuissance"
-                    }
-                ]
+                "source": "acsection_available_sections"
             },
             {
                 "type": "input",
                 "id": "LargeurFond",
                 "nodeType": "SectionTrapeze",
-                "unit": "m",
-                "dep_exist": [
-                    {
-                        "refid": "select_section",
-                        "refvalue": "select_section_trapez"
-                    }
-                ]
+                "unit": "m"
             },
             {
                 "type": "input",
                 "id": "Fruit",
                 "nodeType": "SectionTrapeze",
-                "unit": "m/m",
-                "dep_exist": [
-                    {
-                        "refid": "select_section",
-                        "refvalue": "select_section_trapez"
-                    }
-                ]
+                "unit": "m/m"
             },
             {
                 "type": "input",
                 "id": "LargeurBerge",
                 "nodeType": "SectionRectangle",
-                "unit": "m",
-                "dep_exist": [
-                    {
-                        "refid": "select_section",
-                        "refvalue": "select_section_rect"
-                    }
-                ]
+                "unit": "m"
             },
             {
                 "type": "input",
                 "id": "D",
                 "nodeType": "SectionCercle",
-                "unit": "m",
-                "dep_exist": [
-                    {
-                        "refid": "select_section",
-                        "refvalue": "select_section_circ"
-                    }
-                ]
+                "unit": "m"
             },
             {
                 "type": "input",
                 "id": "k",
                 "nodeType": "SectionPuissance",
-                "unit": "",
-                "dep_exist": [
-                    {
-                        "refid": "select_section",
-                        "refvalue": "select_section_puiss"
-                    }
-                ]
+                "unit": ""
             },
             {
                 "type": "input",
                 "id": "LargeurBerge",
                 "nodeType": "SectionPuissance",
-                "unit": "m",
-                "dep_exist": [
-                    {
-                        "refid": "select_section",
-                        "refvalue": "select_section_puiss"
-                    }
-                ]
+                "unit": "m"
             }
         ]
     },
@@ -166,20 +113,7 @@
             {
                 "id": "select_resolution",
                 "type": "select",
-                "select": [
-                    {
-                        "id": "select_resolution_trap",
-                        "enum": "MethodeResolution.Trapezes"
-                    },
-                    {
-                        "id": "select_resolution_rk4",
-                        "enum": "MethodeResolution.RungeKutta4"
-                    },
-                    {
-                        "id": "select_resolution_euler",
-                        "enum": "MethodeResolution.EulerExplicite"
-                    }
-                ]
+                "source": "remous_methode_resolution"
             }
         ]
     },
@@ -190,71 +124,7 @@
             {
                 "id": "select_target",
                 "type": "select",
-                "select": [
-                    {
-                        "id": "select_target_none"
-                    },
-                    {
-                        "id": "select_target_Hs",
-                        "value": "Hs"
-                    },
-                    {
-                        "id": "select_target_Hsc",
-                        "value": "Hsc"
-                    },
-                    {
-                        "id": "select_target_B",
-                        "value": "B"
-                    },
-                    {
-                        "id": "select_target_P",
-                        "value": "P"
-                    },
-                    {
-                        "id": "select_target_S",
-                        "value": "S"
-                    },
-                    {
-                        "id": "select_target_R",
-                        "value": "R"
-                    },
-                    {
-                        "id": "select_target_V",
-                        "value": "V"
-                    },
-                    {
-                        "id": "select_target_Fr",
-                        "value": "Fr"
-                    },
-                    {
-                        "id": "select_target_Yf",
-                        "value": "Yf"
-                    },
-                    {
-                        "id": "select_target_Yt",
-                        "value": "Yt"
-                    },
-                    {
-                        "id": "select_target_Yco",
-                        "value": "Yco"
-                    },
-                    {
-                        "id": "select_target_J",
-                        "value": "J"
-                    },
-                    {
-                        "id": "select_target_I-J",
-                        "value": "I-J"
-                    },
-                    {
-                        "id": "select_target_Imp",
-                        "value": "Imp"
-                    },
-                    {
-                        "id": "select_target_Tau0",
-                        "value": "Tau0"
-                    }
-                ]
+                "source": "remous_target"
             }
         ]
     },
diff --git a/src/app/formulaire/definition/concrete/form-courbe-remous.ts b/src/app/formulaire/definition/concrete/form-courbe-remous.ts
index 319f155d2..dad046d4c 100644
--- a/src/app/formulaire/definition/concrete/form-courbe-remous.ts
+++ b/src/app/formulaire/definition/concrete/form-courbe-remous.ts
@@ -25,7 +25,7 @@ export class FormulaireCourbeRemous extends FormulaireBase {
         this._formCompute = new FormComputeCourbeRemous(this, this._formSection, (this._formResult as FormResultRemous));
         // default properties
         this._props["methodeResolution"] = MethodeResolution.Trapezes;
-        this._props["varCalc"] = undefined; // important
+        this._props["varCalc"] = ""; // important
     }
 
     protected parseOptions(json: {}) {
diff --git a/src/app/formulaire/select-field.ts b/src/app/formulaire/select-field.ts
index 22fe8775c..6f98a6419 100644
--- a/src/app/formulaire/select-field.ts
+++ b/src/app/formulaire/select-field.ts
@@ -1,4 +1,4 @@
-import { LechaptCalmon, acSection } from "jalhyd";
+import { LechaptCalmon, acSection, CourbeRemous } from "jalhyd";
 
 import { Field } from "./field";
 import { SelectEntry } from "./select-entry";
@@ -128,7 +128,21 @@ export class SelectField extends Field {
             case "acsection_available_sections":
                 for (const sec of acSection.availableSectionTypes) {
                     const e: SelectEntry = new SelectEntry("select_section_" + sec.id, sec.value);
-                    console.log(">> adding entry", e);
+                    this.addEntry(e);
+                }
+                break;
+
+            case "remous_methode_resolution":
+                for (const mr of CourbeRemous.availableMethodeResolution) {
+                    const e: SelectEntry = new SelectEntry("select_resolution_" + mr.id, mr.value);
+                    this.addEntry(e);
+                }
+                break;
+
+            case "remous_target":
+                this.addEntry(new SelectEntry("select_target_none", ""));
+                for (const at of CourbeRemous.availableTargets) {
+                    const e: SelectEntry = new SelectEntry("select_target_" + at, at);
                     this.addEntry(e);
                 }
                 break;
-- 
GitLab