From e34fb728d936c4a4d9a29c0ba88d64387dd3a74e Mon Sep 17 00:00:00 2001
From: David Dorchies <david.dorchies@irstea.fr>
Date: Thu, 12 Jul 2018 15:56:52 +0200
Subject: [PATCH 1/3] #42 Ajout de la calculette Cloisons

---
 .vscode/launch.json                           |   5 +-
 package-lock.json                             |  78 ++++++-
 .../calculators/cloisons/cloisons.config.json | 199 ++++++++++++++++++
 src/app/calculators/cloisons/cloisons.fr.json |  17 ++
 .../pab-puissance/pab-puissance.config.json   |   6 +-
 .../pab-puissance/pab-puissance.en.json       |   2 +-
 .../pab-puissance/pab-puissance.fr.json       |   2 +-
 .../parallel-structures.config.json           |   4 +-
 .../parallel-structures.fr.json               |   6 -
 .../concrete/form-parallel-structures.ts      |   2 +-
 src/app/formulaire/fieldset-container.ts      |  12 +-
 src/app/formulaire/fieldset-template.ts       |   3 +
 src/app/formulaire/fieldset.ts                |  33 +--
 .../services/formulaire/formulaire.service.ts |  32 +--
 src/locale/error_messages.fr.json             |  12 ++
 15 files changed, 358 insertions(+), 55 deletions(-)
 create mode 100644 src/app/calculators/cloisons/cloisons.config.json
 create mode 100644 src/app/calculators/cloisons/cloisons.fr.json

diff --git a/.vscode/launch.json b/.vscode/launch.json
index cc0d45e04..560298a30 100644
--- a/.vscode/launch.json
+++ b/.vscode/launch.json
@@ -10,10 +10,7 @@
             "name": "Launch Chrome (local webserver)",
             "url": "http://localhost:4200",
             "webRoot": "${workspaceFolder}",
-            "runtimeExecutable": "/usr/bin/chromium",
-            "runtimeArgs": [
-                "--password-store=basic"
-            ]
+            "runtimeExecutable": "/usr/bin/chromium-browser"
         },
         {
             "name": "Launch Firefox (local webserver)",
diff --git a/package-lock.json b/package-lock.json
index 35e98049e..9ece6445c 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -238,6 +238,12 @@
       "integrity": "sha512-9vr9W1X6oRp42pbiGRIk3L+T6SoFtHlAGrzbh6rbFQDNXT4UCHarqDigow+DEL6PR2ptXZO9WeLcad4it7zNyA==",
       "dev": true
     },
+    "@types/file-saver": {
+      "version": "1.3.0",
+      "resolved": "https://registry.npmjs.org/@types/file-saver/-/file-saver-1.3.0.tgz",
+      "integrity": "sha512-fC12hKtEzVkrV/ZRcrmqvpHG/TMYDZtgpAmgMUA4F7KneDaQeFMwmPz8AfygKKJMqsdTi8bL+E+fciaaMLxUhg==",
+      "dev": true
+    },
     "@types/jasmine": {
       "version": "2.5.54",
       "resolved": "https://registry.npmjs.org/@types/jasmine/-/jasmine-2.5.54.tgz",
@@ -1322,6 +1328,17 @@
         "source-map": "0.5.7"
       }
     },
+    "clipboard": {
+      "version": "2.0.1",
+      "resolved": "https://registry.npmjs.org/clipboard/-/clipboard-2.0.1.tgz",
+      "integrity": "sha512-7yhQBmtN+uYZmfRjjVjKa0dZdWuabzpSKGtyQZN+9C8xlC788SSJjOHWh7tzurfwTqTD5UDYAhIv5fRJg3sHjQ==",
+      "optional": true,
+      "requires": {
+        "good-listener": "1.2.2",
+        "select": "1.1.2",
+        "tiny-emitter": "2.0.2"
+      }
+    },
     "cliui": {
       "version": "3.2.0",
       "resolved": "https://registry.npmjs.org/cliui/-/cliui-3.2.0.tgz",
@@ -2047,6 +2064,12 @@
       "integrity": "sha1-3zrhmayt+31ECqrgsp4icrJOxhk=",
       "dev": true
     },
+    "delegate": {
+      "version": "3.2.0",
+      "resolved": "https://registry.npmjs.org/delegate/-/delegate-3.2.0.tgz",
+      "integrity": "sha512-IofjkYBZaZivn0V8nnsMJGBr4jVLxHDheKSW88PyxS5QC4Vo9ZbZVvhzlSxY87fVq3STR6r+4cGepyHkcWOQSw==",
+      "optional": true
+    },
     "delegates": {
       "version": "1.0.0",
       "resolved": "https://registry.npmjs.org/delegates/-/delegates-1.0.0.tgz",
@@ -2873,6 +2896,11 @@
         "schema-utils": "0.3.0"
       }
     },
+    "file-saver": {
+      "version": "1.3.8",
+      "resolved": "https://registry.npmjs.org/file-saver/-/file-saver-1.3.8.tgz",
+      "integrity": "sha512-spKHSBQIxxS81N/O21WmuXA2F6wppUCsutpzenOeZzOCCJ5gEfcbqJP983IrpLXzYmXnMUa6J03SubcNPdKrlg=="
+    },
     "filename-regex": {
       "version": "2.0.1",
       "resolved": "https://registry.npmjs.org/filename-regex/-/filename-regex-2.0.1.tgz",
@@ -3257,6 +3285,15 @@
         "minimatch": "3.0.4"
       }
     },
+    "good-listener": {
+      "version": "1.2.2",
+      "resolved": "https://registry.npmjs.org/good-listener/-/good-listener-1.2.2.tgz",
+      "integrity": "sha1-1TswzfkxPf+33JoNR3CWqm0UXFA=",
+      "optional": true,
+      "requires": {
+        "delegate": "3.2.0"
+      }
+    },
     "graceful-fs": {
       "version": "4.1.11",
       "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.1.11.tgz",
@@ -4291,7 +4328,7 @@
     },
     "jalhyd": {
       "version": "file:../jalhyd/jalhyd-1.0.0.tgz",
-      "integrity": "sha1-H2apKCsHjGkSyLgWnm7m8VgqWdM="
+      "integrity": "sha1-EUjX7Sy8Zv6R/MU7BEfJn3KCtvM="
     },
     "jasmine": {
       "version": "2.8.0",
@@ -4856,12 +4893,22 @@
       "integrity": "sha1-2TPOuSBdgr3PSIb2dCvcK03qFG0=",
       "dev": true
     },
+    "marked": {
+      "version": "0.3.19",
+      "resolved": "https://registry.npmjs.org/marked/-/marked-0.3.19.tgz",
+      "integrity": "sha512-ea2eGWOqNxPcXv8dyERdSr/6FmzvWwzjMxpfGB/sbMccXoct+xY+YukPD+QTUZwyvK7BZwcr4m21WBOW41pAkg=="
+    },
     "math-expression-evaluator": {
       "version": "1.2.17",
       "resolved": "https://registry.npmjs.org/math-expression-evaluator/-/math-expression-evaluator-1.2.17.tgz",
       "integrity": "sha1-3oGf282E3M2PrlnGrreWFbnSZqw=",
       "dev": true
     },
+    "mathjax": {
+      "version": "2.7.4",
+      "resolved": "https://registry.npmjs.org/mathjax/-/mathjax-2.7.4.tgz",
+      "integrity": "sha512-B6SLtoETmV08kqTepRyz8eqMRGFzllPy2QASKFdFl0g0YB6SNgQVnWae11RaF3/y8ZKLTJNJ7hLbMIqmBEkLzw=="
+    },
     "md5": {
       "version": "2.2.1",
       "resolved": "https://registry.npmjs.org/md5/-/md5-2.2.1.tgz",
@@ -5168,6 +5215,15 @@
       "integrity": "sha1-KzJxhOiZIQEXeyhWP7XnECrNDKk=",
       "dev": true
     },
+    "ngx-md": {
+      "version": "3.1.1",
+      "resolved": "https://registry.npmjs.org/ngx-md/-/ngx-md-3.1.1.tgz",
+      "integrity": "sha512-3pvEprJLkBt3jlQWT4YyhzKOSXDvLk16tSLJDKs5KpOkLPA7D7ASNFnDvm0bRLgEnnJcrB8db4A3EdbAHcvpjA==",
+      "requires": {
+        "marked": "0.3.19",
+        "prismjs": "1.15.0"
+      }
+    },
     "no-case": {
       "version": "2.3.2",
       "resolved": "https://registry.npmjs.org/no-case/-/no-case-2.3.2.tgz",
@@ -6598,6 +6654,14 @@
         "utila": "0.4.0"
       }
     },
+    "prismjs": {
+      "version": "1.15.0",
+      "resolved": "https://registry.npmjs.org/prismjs/-/prismjs-1.15.0.tgz",
+      "integrity": "sha512-Lf2JrFYx8FanHrjoV5oL8YHCclLQgbJcVZR+gikGGMqz6ub5QVWDTM6YIwm3BuPxM/LOV+rKns3LssXNLIf+DA==",
+      "requires": {
+        "clipboard": "2.0.1"
+      }
+    },
     "process": {
       "version": "0.11.10",
       "resolved": "https://registry.npmjs.org/process/-/process-0.11.10.tgz",
@@ -7333,6 +7397,12 @@
         }
       }
     },
+    "select": {
+      "version": "1.1.2",
+      "resolved": "https://registry.npmjs.org/select/-/select-1.1.2.tgz",
+      "integrity": "sha1-DnNQrN7ICxEIUoeG7B1EGNEbOW0=",
+      "optional": true
+    },
     "select-hose": {
       "version": "2.0.0",
       "resolved": "https://registry.npmjs.org/select-hose/-/select-hose-2.0.0.tgz",
@@ -8148,6 +8218,12 @@
         "setimmediate": "1.0.5"
       }
     },
+    "tiny-emitter": {
+      "version": "2.0.2",
+      "resolved": "https://registry.npmjs.org/tiny-emitter/-/tiny-emitter-2.0.2.tgz",
+      "integrity": "sha512-2NM0auVBGft5tee/OxP4PI3d8WItkDM+fPnaRAVo6xTDI2knbz9eC5ArWGqtGlYqiH3RU5yMpdyTTO7MguC4ow==",
+      "optional": true
+    },
     "tmp": {
       "version": "0.0.31",
       "resolved": "https://registry.npmjs.org/tmp/-/tmp-0.0.31.tgz",
diff --git a/src/app/calculators/cloisons/cloisons.config.json b/src/app/calculators/cloisons/cloisons.config.json
new file mode 100644
index 000000000..f79419373
--- /dev/null
+++ b/src/app/calculators/cloisons/cloisons.config.json
@@ -0,0 +1,199 @@
+[
+    {
+        "id": "fs_param_hydro",
+        "type": "fieldset",
+        "calcType": "Dever",
+        "option": "cal",
+        "fields": [
+            {
+                "type": "input",
+                "id": "Q",
+                "symbol": "Q",
+                "unit": "m³/s"
+            },
+            {
+                "type": "input",
+                "id": "LB",
+                "unit": "m"
+            },
+            {
+                "type": "input",
+                "id": "BB",
+                "unit": "m"
+            },
+            {
+                "type": "input",
+                "id": "PB",
+                "unit": "m"
+            },
+            {
+                "type": "input",
+                "id": "DH",
+                "unit": "m"
+            }
+        ]
+    },
+    {
+        "id": "fs_ouvrage",
+        "type": "fieldset_template",
+        "calcType": "Structure",
+        "defaultNodeType": "StructureRectangle",
+        "defaultStructType": "Orifice",
+        "defaultLoiDebit": "OrificeSubmerged",
+        "option": "cal",
+        "fields": [
+            {
+                "id": "select_ouvrage",
+                "type": "select",
+                "select": [
+                    {
+                        "id": "select_ouvrage_seuil_rect",
+                        "enum": "StructureType.SeuilRectangulaire"
+                    },
+                    {
+                        "id": "select_ouvrage_orifice",
+                        "enum": "StructureType.Orifice"
+                    }
+                ]
+            },
+            {
+                "id": "select_loidebit1",
+                "type": "select",
+                "select": [
+                    {
+                        "id": "select_loidebit1_fente",
+                        "enum": "LoiDebit.WeirSubmergedLarinier"
+                    },
+                    {
+                        "id": "select_loidebit1_kivi",
+                        "enum": "LoiDebit.KIVI"
+                    }
+                ],
+                "dep_exist": [
+                    {
+                        "refid": "select_ouvrage",
+                        "refvalue": "select_ouvrage_seuil_rect"
+                    }
+                ]
+            },
+            {
+                "id": "select_loidebit2",
+                "type": "select",
+                "select": [
+                    {
+                        "id": "select_loidebit2_orifice",
+                        "enum": "LoiDebit.OrificeSubmerged"
+                    }
+                ],
+                "dep_exist": [
+                    {
+                        "refid": "select_ouvrage",
+                        "refvalue": "select_ouvrage_orifice"
+                    }
+                ]
+            },
+            {
+                "type": "input",
+                "id": "ZDV",
+                "unit": "m",
+                "nodeType": "StructureRectangle",
+                "dep_exist": [
+                    {
+                        "refid": "select_ouvrage",
+                        "refvalue": "select_ouvrage_seuil_rect"
+                    }
+                ]
+            },
+            {
+                "type": "input",
+                "id": "L",
+                "unit": "m",
+                "nodeType": "StructureRectangle",
+                "dep_exist": [
+                    {
+                        "refid": "select_ouvrage",
+                        "refvalue": "select_ouvrage_seuil_rect"
+                    }
+                ]
+            },
+            {
+                "type": "input",
+                "id": "Cd",
+                "unit": "",
+                "nodeType": "StructureRectangle"
+            },
+            {
+                "type": "input",
+                "id": "S",
+                "unit": "",
+                "nodeType": "StructureRectangle",
+                "dep_exist": [
+                    {
+                        "refid": "select_loidebit2",
+                        "refvalue": "select_loidebit2_orifice"
+                    }
+                ]
+            },
+            {
+                "type": "input",
+                "id": "alpha",
+                "unit": "",
+                "nodeType": "StructureRectangle",
+                "dep_exist": [
+                    {
+                        "refid": "select_loidebit1",
+                        "refvalue": "select_loidebit1_kivi"
+                    }
+                ]
+            },
+            {
+                "type": "input",
+                "id": "beta",
+                "unit": "",
+                "nodeType": "StructureRectangle",
+                "dep_exist": [
+                    {
+                        "refid": "select_loidebit1",
+                        "refvalue": "select_loidebit1_kivi"
+                    }
+                ]
+            },
+            {
+                "type": "input",
+                "id": "ZRAM",
+                "unit": "",
+                "nodeType": "StructureRectangle",
+                "dep_exist": [
+                    {
+                        "refid": "select_loidebit1",
+                        "refvalue": "select_loidebit1_kivi"
+                    }
+                ]
+            }
+        ]
+    },
+    {
+        "id": "struct_container",
+        "type": "template_container",
+        "templates": [
+            "fs_ouvrage"
+        ]
+    },
+    {
+        "id": "fs_param_calc",
+        "type": "fieldset",
+        "calcType": "ParallelStructure",
+        "option": "fix",
+        "fields": [
+            {
+                "type": "input",
+                "id": "Pr"
+            }
+        ]
+    },
+    {
+        "type": "options",
+        "ouvrageSelectId": "select_ouvrage",
+        "idCal": "Q"
+    }
+]
\ No newline at end of file
diff --git a/src/app/calculators/cloisons/cloisons.fr.json b/src/app/calculators/cloisons/cloisons.fr.json
new file mode 100644
index 000000000..c8bc712cd
--- /dev/null
+++ b/src/app/calculators/cloisons/cloisons.fr.json
@@ -0,0 +1,17 @@
+{
+    "fs_param_hydro": "Paramètres hydrauliques",
+    "Q": "Débit total",
+    "Z1": "Cote de l'eau amont",
+    "ZR": "Cote du lit amont",
+    "LB": "Longueur du bassin",
+    "BB": "Largeur du bassin",
+    "PB": "Profondeur moyenne du bassin",
+    "DH": "Chute",
+    "S": "Surface de l'orifice",
+    "select_ouvrage_orifice": "Orifice",
+    "select_ouvrage_seuil_rect": "Seuil rectangulaire",
+    "select_loidebit1_kivi": "Kindsvater-Carter et Villemonte",
+    "select_loidebit1_fente": "Fente noyée (Larinier 1992)",
+    "select_loidebit2_orifice": "Orifice noyé",
+    "struct_container": "Ouvrages"
+}
\ No newline at end of file
diff --git a/src/app/calculators/pab-puissance/pab-puissance.config.json b/src/app/calculators/pab-puissance/pab-puissance.config.json
index 59b06d658..5806d41c5 100644
--- a/src/app/calculators/pab-puissance/pab-puissance.config.json
+++ b/src/app/calculators/pab-puissance/pab-puissance.config.json
@@ -21,8 +21,8 @@
             },
             {
                 "type": "input",
-                "id": "Pv",
-                "unit": "W"
+                "id": "PV",
+                "unit": "W/m³"
             }
         ]
     },
@@ -39,6 +39,6 @@
     },
     {
         "type": "options",
-        "idCal": "Pv"
+        "idCal": "PV"
     }
 ]
\ No newline at end of file
diff --git a/src/app/calculators/pab-puissance/pab-puissance.en.json b/src/app/calculators/pab-puissance/pab-puissance.en.json
index 0588c37fe..582ca3f45 100644
--- a/src/app/calculators/pab-puissance/pab-puissance.en.json
+++ b/src/app/calculators/pab-puissance/pab-puissance.en.json
@@ -3,5 +3,5 @@
     "DH": "Drop",
     "Q": "Discharge",
     "V": "Volume",
-    "Pv": "Dissipated power"
+    "PV": "Dissipated power"
 }
\ No newline at end of file
diff --git a/src/app/calculators/pab-puissance/pab-puissance.fr.json b/src/app/calculators/pab-puissance/pab-puissance.fr.json
index 6020d6e45..c3b45436c 100644
--- a/src/app/calculators/pab-puissance/pab-puissance.fr.json
+++ b/src/app/calculators/pab-puissance/pab-puissance.fr.json
@@ -3,5 +3,5 @@
     "DH": "Chute entre bassins",
     "Q": "Débit",
     "V": "Volume",
-    "Pv": "Puissance dissipée"
+    "PV": "Puissance dissipée"
 }
\ No newline at end of file
diff --git a/src/app/calculators/parallel-structures/parallel-structures.config.json b/src/app/calculators/parallel-structures/parallel-structures.config.json
index 6151865b5..cefbd84a9 100644
--- a/src/app/calculators/parallel-structures/parallel-structures.config.json
+++ b/src/app/calculators/parallel-structures/parallel-structures.config.json
@@ -100,11 +100,11 @@
                     },
                     {
                         "id": "select_loidebit2_vannedenoye",
-                        "enum": "LoiDebit.OrificeFree"
+                        "enum": "LoiDebit.RectangularOrificeFree"
                     },
                     {
                         "id": "select_loidebit2_vannenoye",
-                        "enum": "LoiDebit.OrificeSubmerged"
+                        "enum": "LoiDebit.RectangularOrificeSubmerged"
                     },
                     {
                         "id": "select_loidebit2_cunge80",
diff --git a/src/app/calculators/parallel-structures/parallel-structures.fr.json b/src/app/calculators/parallel-structures/parallel-structures.fr.json
index f6db43aaf..41e093726 100644
--- a/src/app/calculators/parallel-structures/parallel-structures.fr.json
+++ b/src/app/calculators/parallel-structures/parallel-structures.fr.json
@@ -25,12 +25,6 @@
     "select_loidebit2_cem88v": "Déversoir/Vanne de fond Cemagref 88",
     "select_loidebit3_seuiltriang": "Déversoir triangulaire dénoyé",
     "select_loidebit4_seuiltriangtrunc": "Déversoir triangulaire tronqué dénoyé",
-    "ZDV": "Cote de la crête du déversoir ou du radier de la vanne",
-    "L": "Largeur du déversoir (m)",
-    "Cd": "Coefficient de débit",
-    "alpha": "Coefficient alpha",
-    "beta": "Coefficient béta",
-    "ZRAM": "Cote du radier amont (m)",
     "alpha2": "Demi-angle au sommet (°)",
     "BT": "Demi-ouverture du triangle (m)",
     "ZT": "Cote haute du triangle (m)",
diff --git a/src/app/formulaire/definition/concrete/form-parallel-structures.ts b/src/app/formulaire/definition/concrete/form-parallel-structures.ts
index dae370e98..d629a2cf9 100644
--- a/src/app/formulaire/definition/concrete/form-parallel-structures.ts
+++ b/src/app/formulaire/definition/concrete/form-parallel-structures.ts
@@ -157,7 +157,7 @@ export class FormulaireParallelStructure extends FormulaireDefinition {
     }
 
     /**
-     * gestion du clic sur les radios "paramètre fixé, à varier, à calculer"    
+     * gestion du clic sur les radios "paramètre fixé, à varier, à calculer"
      */
     public onRadioClick(info: string) {
         super.onRadioClick(info);
diff --git a/src/app/formulaire/fieldset-container.ts b/src/app/formulaire/fieldset-container.ts
index 6d8c093b0..4e2ec5b4a 100644
--- a/src/app/formulaire/fieldset-container.ts
+++ b/src/app/formulaire/fieldset-container.ts
@@ -105,13 +105,11 @@ export class FieldsetContainer extends FormulaireElement {
                     this.addTemplate(d);
     }
 
-    public updateLocalisation(loc?: StringMap) {
-        if (loc == undefined)
-            loc = this._localisation;
-        else
-            this._localisation = loc;
-
-        super.updateLocalisation(loc);
+    public updateLocalisation(loc: StringMap = this._localisation) {
+        this._localisation = loc;
+        if (loc !== undefined) {
+            super.updateLocalisation(loc);
+        }
     }
 
     /**
diff --git a/src/app/formulaire/fieldset-template.ts b/src/app/formulaire/fieldset-template.ts
index 8ba2da3ba..3b12fa0d1 100644
--- a/src/app/formulaire/fieldset-template.ts
+++ b/src/app/formulaire/fieldset-template.ts
@@ -31,6 +31,9 @@ export class FieldsetTemplate {
 
     public get defaultLoiDebitFromConfig(): LoiDebit {
         const ld: string = this._jsonConfig["defaultLoiDebit"];
+        if (LoiDebit[ld] === undefined) {
+            throw new Error(`FieldsetTemplate.defaultLoiDebitFromConfig: La loi de débit ${ld} n'est pas définie`);
+        }
         return LoiDebit[ld];
     }
 
diff --git a/src/app/formulaire/fieldset.ts b/src/app/formulaire/fieldset.ts
index 2719cd61f..a4777cecf 100644
--- a/src/app/formulaire/fieldset.ts
+++ b/src/app/formulaire/fieldset.ts
@@ -321,23 +321,30 @@ export class FieldSet extends FormulaireElement implements Observer {
     // interface Observer
 
     update(sender: any, data: any) {
-        if (data.action)
+        if (data.action) {
             switch (data.action) {
                 case "select":
-                    if (sender.id === "select_section")  // sections paramétrées
-                        this.setPropValue("nodeType", data.value.value);
-                    if (sender.id === "select_ouvrage") // ouvrages parallèles
-                        this.setPropValue("structureType", data.value.value);
-                    else if (sender.id === "select_loidebit1") // ouvrages parallèles
-                        this.setPropValue("loiDebit", data.value.value);
-                    else if (sender.id === "select_loidebit2") // ouvrages parallèles
-                        this.setPropValue("loiDebit", data.value.value);
-                    else if (sender.id === "select_resolution") // courbes de remous, méthode de résolution
-                        this.setPropValue("methodeResolution", data.value.value);
-                    else if (sender.id === "select_target") // courbes de remous, variable à calculer
-                        this.setPropValue("varCalc", data.value.value);
+                    const senderId: string = sender.id.replace(/\d+$/, "");
+                    switch (senderId) {
+                        case "select_section": // sections paramétrées
+                            this.setPropValue("nodeType", data.value.value);
+                            break;
+                        case "select_ouvrage": // ouvrages parallèles
+                            this.setPropValue("structureType", data.value.value);
+                            break;
+                        case "select_loidebit": // ouvrages parallèles et dérivées
+                            this.setPropValue("loiDebit", data.value.value);
+                            break;
+                        case "select_resolution": // courbes de remous, méthode de résolution
+                            this.setPropValue("methodeResolution", data.value.value);
+                            break;
+                        case "select_target": // courbes de remous, variable à calculer
+                            this.setPropValue("varCalc", data.value.value);
+                            break;
+                    }
                     break;
             }
+        }
     }
 
     /**
diff --git a/src/app/services/formulaire/formulaire.service.ts b/src/app/services/formulaire/formulaire.service.ts
index ce222c998..b58aedfd1 100644
--- a/src/app/services/formulaire/formulaire.service.ts
+++ b/src/app/services/formulaire/formulaire.service.ts
@@ -24,7 +24,6 @@ import { FormulaireRegimeUniforme } from "../../formulaire/definition/concrete/f
 import { FormulairePasseBassinDimensions } from "../../formulaire/definition/concrete/form-passe-bassin-dim";
 import { FormulairePasseBassinPuissance } from "../../formulaire/definition/concrete/form-passe-bassin-puissance";
 import { FormulaireParallelStructure } from "../../formulaire/definition/concrete/form-parallel-structures";
-import { FormulaireDever } from "../../formulaire/definition/concrete/form-dever";
 import { NgParameter } from "../../formulaire/ngparam";
 
 @Injectable()
@@ -153,15 +152,13 @@ export class FormulaireService extends Observable {
                 break;
 
             case CalculatorType.ParallelStructure:
-                f = new FormulaireParallelStructure();
-                break;
-
             case CalculatorType.Dever:
-                f = new FormulaireDever();
+            case CalculatorType.Cloisons:
+                f = new FormulaireParallelStructure();
                 break;
 
             default:
-                throw new Error(`FormulaireService.createFormulaire() : type de calculette ${ct} non pris en charge`)
+                throw new Error(`FormulaireService.newFormulaire() : type de calculette ${CalculatorType[ct]} non pris en charge`)
         }
 
         f.defaultProperties["calcType"] = ct;
@@ -221,30 +218,30 @@ export class FormulaireService extends Observable {
     }
 
     public getInputField(formId: number, elemId: string): InputField {
-        let s = this.getFormulaireElementById(formId, elemId);
+        const s = this.getFormulaireElementById(formId, elemId);
         if (!(s instanceof InputField))
             throw "Form element with id '" + elemId + "' is not an input";
         return <InputField>s;
     }
 
     public getCheckField(formId: number, elemId: string): CheckField {
-        let s = this.getFormulaireElementById(formId, elemId);
+        const s = this.getFormulaireElementById(formId, elemId);
         if (!(s instanceof CheckField))
-            throw "Form element with id '" + elemId + "' is not a checkbox";
+            throw new Error("Form element with id '" + elemId + "' is not a checkbox");
         return <CheckField>s;
     }
 
     public getSelectField(formId: number, elemId: string): SelectField {
-        let s = this.getFormulaireElementById(formId, elemId);
+        const s = this.getFormulaireElementById(formId, elemId);
         if (!(s instanceof SelectField))
-            throw "Form element with id '" + elemId + "' is not a select";
+            throw new Error("Form element with id '" + elemId + "' is not a select");
         return <SelectField>s;
     }
 
     private getFormulaireElementById(formId: number, elemId: string): FormulaireElement {
         for (let f of this._formulaires)
             if (f.uid === formId) {
-                let s = f.getFormulaireNodeById(elemId);
+                const s = f.getFormulaireNodeById(elemId);
                 if (s !== undefined)
                     return s as FormulaireElement;
             }
@@ -262,7 +259,7 @@ export class FormulaireService extends Observable {
 
     public getConfigPathPrefix(ct: CalculatorType): string {
         if (ct === undefined)
-            throw "FormulaireService.getConfigPathPrefix() : invalid undefined CalculatorType"
+            throw new Error("FormulaireService.getConfigPathPrefix() : invalid undefined CalculatorType")
 
         switch (ct) {
             case CalculatorType.ConduiteDistributrice:
@@ -295,6 +292,9 @@ export class FormulaireService extends Observable {
             case CalculatorType.Dever:
                 return "app/calculators/dever/dever.";
 
+            case CalculatorType.Cloisons:
+                return "app/calculators/cloisons/cloisons.";
+
             default:
                 throw new Error("FormulaireService.getConfigPathPrefix() : valeur de CalculatorType " + ct + " non implémentée")
         }
@@ -347,7 +347,7 @@ export class FormulaireService extends Observable {
 
     private readSingleFile(file: File): Promise<any> {
         return new Promise<any>((resolve, reject) => {
-            var fr = new FileReader();
+            const fr = new FileReader();
 
             fr.onload = () => {
                 resolve(fr.result);
@@ -470,7 +470,7 @@ export class FormulaireService extends Observable {
      * @param p paramètre qui sert de clé de recherche des paramètres liables
      */
     public getLinkableValues(p: NgParameter): any[] {
-        let res: any[] = [];
+        const res: any[] = [];
 
         if (p !== undefined)
             for (const f of this._formulaires) {
@@ -513,7 +513,7 @@ export class FormulaireService extends Observable {
                 const parentForm: FormulaireDefinition = this.getParamdefParentForm(prm);
 
                 // ... on cherche s'il est affiché dans son parent
-                let found: boolean = false;
+                let found = false;
                 if (parentForm !== undefined)
                     for (const fe of parentForm.allFormElements)
                         if (fe instanceof NgParameter)
diff --git a/src/locale/error_messages.fr.json b/src/locale/error_messages.fr.json
index df2de9ae5..4a4368baf 100644
--- a/src/locale/error_messages.fr.json
+++ b/src/locale/error_messages.fr.json
@@ -31,6 +31,7 @@
     "INFO_CALCULATOR_CALCULER": "Calculer",
     "INFO_CALCULATOR_PARAMFIXES": "Paramètres fixés",
     "INFO_CALCULATOR_VALEURS": "Valeurs",
+    "INFO_CLOISONS_TITRE": "Passe à bassin&nbsp;: Cloisons",
     "INFO_CLOSE_DIALOGUE_TEXT": "Attention&nbsp! Les paramètres et résultats de la calculette seront perdus. Vraiment fermer&nbsp;?",
     "INFO_CLOSE_DIALOGUE_TITRE": "Confirmer la fermeture",
     "INFO_CONDUITEDISTRIBUTRICE_TITRE": "Conduite distributrice",
@@ -58,6 +59,7 @@
     "INFO_EXTRARES_LIB_OUVRAGE_Q_MODE": "Type d'écoulement",
     "INFO_EXTRARES_LIB_OUVRAGE_Q_REGIME": "Régime",
     "INFO_EXTRARES_LIB_P": "Périmètre mouillé (m)",
+    "INFO_EXTRARES_LIB_PV": "Puissance volumique dissipée (W/m³)",
     "INFO_EXTRARES_LIB_Q": "Débit (m³/s)",
     "INFO_EXTRARES_LIB_R": "Rayon hydraulique (m)",
     "INFO_EXTRARES_LIB_S": "Surface mouillée (m²)",
@@ -71,8 +73,18 @@
     "INFO_EXTRARES_LIB_YT": "Tirant d'eau torrentiel (m)",
     "INFO_LECHAPTCALMON_TITRE": "Lechapt-Calmon",
     "INFO_LIB_FS_PARAM_CALC": "Paramètres de calcul",
+    "INFO_LIB_FS_OUVRAGE": "Ouvrage",
     "INFO_LIB_PR": "Précision de calcul",
     "INFO_LIB_SELECT_LOIDEBIT": "Loi de débit",
+    "INFO_LIB_SELECT_LOIDEBIT1_KIVI": "Kindsvater-Carter et Villemonte",
+    "INFO_LIB_SELECT_OUVRAGE": "Ouvrage",
+    "INFO_LIB_SELECT_OUVRAGE_SEUIL_RECT": "Seuil rectangulaire",
+    "INFO_LIB_ZDV": "Cote de la crête du déversoir ou du radier de la vanne",
+    "INFO_LIB_L": "Largeur du déversoir (m)",
+    "INFO_LIB_CD": "Coefficient de débit",
+    "INFO_LIB_ALPHA": "Coefficient alpha",
+    "INFO_LIB_BETA": "Coefficient béta",
+    "INFO_LIB_ZRAM": "Cote du radier amont (m)",
     "INFO_MENU_NOUVELLE_CALC": "Nouvelle calculette",
     "INFO_OPTION_NO": "Non",
     "INFO_OPTION_YES": "Oui",
-- 
GitLab


From 51f9fb086b56c2b65ce1d6aea4605b91a82d6e72 Mon Sep 17 00:00:00 2001
From: David Dorchies <david.dorchies@irstea.fr>
Date: Thu, 12 Jul 2018 16:18:14 +0200
Subject: [PATCH 2/3] #42 Ajout de Z1 + Update jalhyd_branch pour serveur de
 test

---
 jalhyd_branch                                     | 2 +-
 src/app/calculators/cloisons/cloisons.config.json | 5 +++++
 2 files changed, 6 insertions(+), 1 deletion(-)

diff --git a/jalhyd_branch b/jalhyd_branch
index d918178ee..22e635103 100644
--- a/jalhyd_branch
+++ b/jalhyd_branch
@@ -1 +1 @@
-45-importation-d-un-parametre-resultat-ou-resultat-complementaire-d-une-autre-calculette
+28-ajout-de-l-outil-passe-a-bassins-cloisons-loi-de-debit-entre-bassins
diff --git a/src/app/calculators/cloisons/cloisons.config.json b/src/app/calculators/cloisons/cloisons.config.json
index f79419373..cbb86479f 100644
--- a/src/app/calculators/cloisons/cloisons.config.json
+++ b/src/app/calculators/cloisons/cloisons.config.json
@@ -11,6 +11,11 @@
                 "symbol": "Q",
                 "unit": "m³/s"
             },
+            {
+                "type": "input",
+                "id": "Z1",
+                "unit": "m"
+            },
             {
                 "type": "input",
                 "id": "LB",
-- 
GitLab


From 3ae114ad52afeb72e72c244b02ff36ab7c9c5150 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Fran=C3=A7ois?= <francois.grand@irstea.fr>
Date: Fri, 13 Jul 2018 14:42:44 +0200
Subject: [PATCH 3/3] =?UTF-8?q?=20#42=20passe=20=C3=A0=20cloisons=20:=20co?=
 =?UTF-8?q?rrection=20d'un=20bug=20quand=20on=20change=20le=20type=20de=20?=
 =?UTF-8?q?structure=20de=20orifice=20=C3=A0=20seuil=20rectangulaire=20con?=
 =?UTF-8?q?texte=20:=20quand=20on=20changeait=20le=20type=20de=20structure?=
 =?UTF-8?q?,=20on=20recherchait=20la=201=C3=A8re=20loi=20de=20d=C3=A9bit?=
 =?UTF-8?q?=20compatible=20avec=20la=20nouvelle=20valeur,=20mais=20sans=20?=
 =?UTF-8?q?tenir=20compte=20des=20valeurs=20possibles=20dans=20le=20select?=
 =?UTF-8?q?=20'loi=20de=20d=C3=A9bit'.?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 .../concrete/form-parallel-structures.ts      | 116 ++++++++++++++++--
 src/app/formulaire/fieldset.ts                |   6 +-
 2 files changed, 109 insertions(+), 13 deletions(-)

diff --git a/src/app/formulaire/definition/concrete/form-parallel-structures.ts b/src/app/formulaire/definition/concrete/form-parallel-structures.ts
index d629a2cf9..5606c737e 100644
--- a/src/app/formulaire/definition/concrete/form-parallel-structures.ts
+++ b/src/app/formulaire/definition/concrete/form-parallel-structures.ts
@@ -193,25 +193,117 @@ export class FormulaireParallelStructure extends FormulaireDefinition {
     }
 
     /**
-     * après une modification, détermine si les propriétés sont compatibles entre elles et les ajuste au besoin
+     * recherche dans une config le 1er select avec une entrée "enum" avec une valeur donnée
+     */
+    private findSelectWithEnum(conf: {}, enumName: string, enumVal: string): {
+        "select": { [key: string]: string; },
+        "entry": { [key: string]: string; }
+    } {
+        let select; // select 
+        let selectEntry; // entrée du select correspondant à la valeur de l'enum
+
+        for (const k in conf) {
+            const kid = conf[k];
+            if (kid.type === "select") {
+                // entrées
+                for (const e of kid.select) {
+                    if (e.enum !== undefined) {
+                        const tmp = e.enum.split(".");
+                        const found = tmp[0] === enumName && tmp[1] === enumVal;
+                        if (found) {
+                            select = kid;
+                            selectEntry = e;
+                            break;
+                        }
+                    }
+                }
+                if (select !== undefined)
+                    break;
+            }
+        }
+
+        if (select === undefined)
+            return undefined;
+
+        return { "select": select, "entry": selectEntry };
+    }
+
+    /**
+     * recherche dans une config le 1er objet avec dépendance donnée
+     */
+    private findObjectWithDependency(conf: {}, refid: string, refvalue: string): {} {
+        for (const k in conf) {
+            const kid = conf[k];
+            if (kid.dep_exist !== undefined) {
+                for (const dep of kid.dep_exist)
+                    if (dep.refid === refid && dep.refvalue === refvalue)
+                        return kid;
+            }
+        }
+
+        return undefined;
+    }
+
+    /**
+     * trouve une loi de débit compatible avec un type de structure dans un Fieldset en tenant compte des dépendances entre selects
+     * @param fs 
+     * @param structType
+     */
+    private adjustLoiDebit(fs: FieldSet, structType: StructureType): Props {
+        const res: Props = fs.properties.clone();
+
+        // recherche du select "type de structure"
+
+        const structSelect = this.findSelectWithEnum(fs.jsonConfig["fields"], "StructureType", StructureType[structType]);
+        if (structSelect === undefined)
+            throw new Error(`pas de select trouvé pour la propriété StructureType=${StructureType[structType]}`);
+
+        // recherche du select dépendant (lois de débit)
+
+        const loidebitSelect = this.findObjectWithDependency(fs.jsonConfig["fields"], structSelect.select.id, structSelect.entry.id);
+        if (loidebitSelect === undefined || loidebitSelect["type"] !== "select")
+            throw new Error(`pas de select trouvé avec une dépendance au select 'type de structure' pour la valeur ${structSelect.select.id}=${structSelect.entry.id} (1)`);
+
+        // liste des enums du select dépendant
+
+        const loisDebit = [];
+        for (const e of loidebitSelect["select"])
+            if (e.enum !== undefined) {
+                const tmp = e.enum.split(".");
+                loisDebit.push(LoiDebit[tmp[1]]);
+            }
+
+        if (loisDebit.length === 0)
+            throw new Error(`pas de select trouvé avec une dépendance au select 'type de structure' pour la valeur ${structSelect.select.id}=${structSelect.entry.id} (2)`);
+
+        res.setPropValue("loiDebit", StructureProperties.findCompatibleLoiDebit(structType, loisDebit));
+
+        return res;
+    }
+
+    // private adjustTypeStruct(fs: FieldSet, loiDebit: LoiDebit): Props {
+    //     return undefined;
+    // }
+
+    /**
+     * après une modification, détermine si les propriétés d'un Fieldset sont compatibles entre elles et les ajuste au besoin
      * @param props propriétés à vérifier
      * @param name nom de la propriété qui vient de changer
      * @param val nouvelle valeur de la propriété
      */
-    private adjustProperties(props: Props, name: string, val: any) {
-        const res: Props = props.clone();
-
-        // si prop=type d'ouvrage, on prend une loi de débit compatible avec (spécifique aux ouvrages //) comme valeur par défaut
+    private adjustProperties(fs: FieldSet, name: string, val: any): Props {
+        // si prop=type d'ouvrage, on prend la 1ère loi de débit compatible avec (spécifique aux ouvrages //), en tenant compte des dépendances.
+        // (par ex, s'il existe un select de lois de débit dépendant du select de types d'ouvrage, on prend la 1ère entrée du select de lois de débit compatible)
         if (name === "structureType") {
-            if (!StructureProperties.isCompatibleValues(val, res.getPropValue("loiDebit")))
-                res.setPropValue("loiDebit", StructureProperties.findCompatibleLoiDebit(val));
+            if (!StructureProperties.isCompatibleValues(val, fs.properties.getPropValue("loiDebit")))
+                return this.adjustLoiDebit(fs, val);
         }
         // si prop=loi débit, on prend un type d'ouvrage compatible
-        else if (name === "loiDebit")
-            if (!StructureProperties.isCompatibleValues(res.getPropValue("structureType"), val))
-                res.setPropValue("structureType", StructureProperties.findCompatibleStructure(val));
+        // else if (name === "loiDebit")
+        //     if (!StructureProperties.isCompatibleValues(fs.properties.getPropValue("structureType"), val))
+        //         return this.adjustTypeStruct(fs, val);
 
-        return res;
+        return fs.properties;
     }
 
     /**
@@ -251,7 +343,7 @@ export class FormulaireParallelStructure extends FormulaireDefinition {
         else if (sender instanceof FieldSet && data.action == "propertyChange") {
             switch (sender.id) {
                 case "fs_ouvrage":
-                    const props = this.adjustProperties(sender.properties, data["name"], data["value"]);
+                    const props = this.adjustProperties(sender, data["name"], data["value"]);
                     const newNub = this.replaceSessionNub(sender.sessionNub, props);
                     sender.setSessionNub(newNub);
                     this.reset();
diff --git a/src/app/formulaire/fieldset.ts b/src/app/formulaire/fieldset.ts
index a4777cecf..cfcd138fa 100644
--- a/src/app/formulaire/fieldset.ts
+++ b/src/app/formulaire/fieldset.ts
@@ -112,6 +112,10 @@ export class FieldSet extends FormulaireElement implements Observer {
         return this._sessionNub.nub.getParameter(symbol);
     }
 
+    public get jsonConfig(): {} {
+        return this._jsonConfig;
+    }
+
     /**
      * crée un input
      * @param json definition de l'input, extrait du fichier de conf de la calculette
@@ -332,7 +336,7 @@ export class FieldSet extends FormulaireElement implements Observer {
                         case "select_ouvrage": // ouvrages parallèles
                             this.setPropValue("structureType", data.value.value);
                             break;
-                        case "select_loidebit": // ouvrages parallèles et dérivées
+                        case "select_loidebit": // ouvrages parallèles et dérivés
                             this.setPropValue("loiDebit", data.value.value);
                             break;
                         case "select_resolution": // courbes de remous, méthode de résolution
-- 
GitLab