From 4e725515dc2a748c1d42004abe680fee646631f1 Mon Sep 17 00:00:00 2001
From: "mathias.chouet" <mathias.chouet@irstea.fr>
Date: Wed, 30 Oct 2019 11:47:19 +0100
Subject: [PATCH] Fix #319 - module Y = A.X + B

---
 e2e/calculate-all-params.e2e-spec.ts      |  1 +
 e2e/check-translations.e2e-spec.ts        |  2 +-
 e2e/clone-all-calc.e2e-spec.ts            |  1 +
 src/app/calculators/yaxb/yaxb.config.json | 12 ++++++++++++
 src/app/calculators/yaxb/yaxb.en.json     |  8 ++++++++
 src/app/calculators/yaxb/yaxb.fr.json     |  8 ++++++++
 src/app/services/formulaire.service.ts    |  1 +
 src/locale/messages.en.json               |  3 +++
 src/locale/messages.fr.json               |  3 +++
 9 files changed, 38 insertions(+), 1 deletion(-)
 create mode 100644 src/app/calculators/yaxb/yaxb.config.json
 create mode 100644 src/app/calculators/yaxb/yaxb.en.json
 create mode 100644 src/app/calculators/yaxb/yaxb.fr.json

diff --git a/e2e/calculate-all-params.e2e-spec.ts b/e2e/calculate-all-params.e2e-spec.ts
index 9533c2fca..dcbd5b7c3 100644
--- a/e2e/calculate-all-params.e2e-spec.ts
+++ b/e2e/calculate-all-params.e2e-spec.ts
@@ -23,6 +23,7 @@ describe("ngHyd − calculate all parameters of all calculators", () => {
     11, 12, 13, 15, 17, 18, 19, 20,
     21,
     // 22 - Solveur is not calculated here because it is not independent
+    23
   ];
 
   // for each calculator
diff --git a/e2e/check-translations.e2e-spec.ts b/e2e/check-translations.e2e-spec.ts
index b0c10f970..d8491b8d9 100644
--- a/e2e/check-translations.e2e-spec.ts
+++ b/e2e/check-translations.e2e-spec.ts
@@ -25,7 +25,7 @@ describe("ngHyd − check translation of all calculators", () => {
   });
 
   // get calculators list (IDs) @TODO read it from config, but can't import jalhyd here :/
-  const calcTypes = [ 0, 1, 2, 3, 4, 5, 6, 8, 9, 10, 11, 12, 13, 15, 17, 18, 19, 20, 21, 22 ];
+  const calcTypes = [ 0, 1, 2, 3, 4, 5, 6, 8, 9, 10, 11, 12, 13, 15, 17, 18, 19, 20, 21, 22, 23 ];
 
   // options of "Language" selector on preferences page
   const langs = [ "English", "Français" ];
diff --git a/e2e/clone-all-calc.e2e-spec.ts b/e2e/clone-all-calc.e2e-spec.ts
index 8c32c1ff6..1f0ba7fcb 100644
--- a/e2e/clone-all-calc.e2e-spec.ts
+++ b/e2e/clone-all-calc.e2e-spec.ts
@@ -23,6 +23,7 @@ describe("ngHyd − clone all calculators with all possible <select> values", ()
     11, 12, 13, 15, 17, 18, 19, 20,
     21,
     // 22 - Solveur is not cloned here because it is not independent
+    23
   ];
 
   // for each calculator
diff --git a/src/app/calculators/yaxb/yaxb.config.json b/src/app/calculators/yaxb/yaxb.config.json
new file mode 100644
index 000000000..1a02898b7
--- /dev/null
+++ b/src/app/calculators/yaxb/yaxb.config.json
@@ -0,0 +1,12 @@
+[
+    {
+        "id": "fs_yaxb",
+        "type": "fieldset",
+        "fields": [ "Y", "A", "X", "B" ]
+    },
+    {
+        "type": "options",
+        "idCal": "Y",
+        "_help": "util/yaxb.html"
+    }
+]
\ No newline at end of file
diff --git a/src/app/calculators/yaxb/yaxb.en.json b/src/app/calculators/yaxb/yaxb.en.json
new file mode 100644
index 000000000..a3595ae59
--- /dev/null
+++ b/src/app/calculators/yaxb/yaxb.en.json
@@ -0,0 +1,8 @@
+{
+    "fs_yaxb": "Equation parameters",
+
+    "Y": "Y",
+    "A": "A",
+    "X": "X",
+    "B": "B"
+}
\ No newline at end of file
diff --git a/src/app/calculators/yaxb/yaxb.fr.json b/src/app/calculators/yaxb/yaxb.fr.json
new file mode 100644
index 000000000..97f602e31
--- /dev/null
+++ b/src/app/calculators/yaxb/yaxb.fr.json
@@ -0,0 +1,8 @@
+{
+    "fs_yaxb": "Paramètres de l'équation",
+
+    "Y": "Y",
+    "A": "A",
+    "X": "X",
+    "B": "B"
+}
\ No newline at end of file
diff --git a/src/app/services/formulaire.service.ts b/src/app/services/formulaire.service.ts
index 536af784a..d8b6d13f8 100644
--- a/src/app/services/formulaire.service.ts
+++ b/src/app/services/formulaire.service.ts
@@ -86,6 +86,7 @@ export class FormulaireService extends Observable {
         this.calculatorPaths[CalculatorType.Pente] = "pente";
         this.calculatorPaths[CalculatorType.Bief] = "bief";
         this.calculatorPaths[CalculatorType.Solveur] = "solveur";
+        this.calculatorPaths[CalculatorType.YAXB] = "yaxb";
     }
 
     private get _intlService(): I18nService {
diff --git a/src/locale/messages.en.json b/src/locale/messages.en.json
index b12fe6900..4d329f2cb 100644
--- a/src/locale/messages.en.json
+++ b/src/locale/messages.en.json
@@ -16,6 +16,7 @@
     "ERROR_DICHO_NULL_STEP": "Dichotomy (initial interval search): invalid null step",
     "ERROR_DICHO_TARGET_TOO_HIGH": "Dichotomy: the solution %targetSymbol%=%targetValue% is greater than the maximum computable value %targetSymbol%(%variableSymbol%=%variableExtremeValue%)=%extremeTarget%)",
     "ERROR_DICHO_TARGET_TOO_LOW": "Dichotomy: the solution %targetSymbol%=%targetValue%  is lower than the minimum computable value %targetSymbol%(%variableSymbol%=%variableExtremeValue%)=%extremeTarget%)",
+    "ERROR_DIVISION_BY_ZERO": "Division by zero",
     "ERROR_ELEVATION_ZI_LOWER_THAN_Z2": "Upstream elevation is lower than downstream elevation",
     "ERROR_IN_CALC_CHAIN": "An error occurred in calculation chain",
     "WARNING_ERROR_IN_CALC_CHAIN_STEPS": "Errors occurred during chain calculation",
@@ -466,6 +467,8 @@
     "INFO_EXAMPLE_LABEL_PAB_COMPLETE": "Standard fish ladder",
     "INFO_EXAMPLES_TITLE": "Examples",
     "INFO_EXAMPLES_SUBTITLE": "Load standard examples",
+    "INFO_YAXB_TITRE": "Y = A.X + B",
+    "INFO_YAXB_TITRE_COURT": "Y=A.X+B",
     "WARNING_WARNINGS_ABSTRACT": "%nb% warnings occurred during calculation",
     "WARNING_REMOUS_ARRET_CRITIQUE": "Calculation stopped: critical elevation reached at abscissa %x%",
     "WARNING_STRUCTUREKIVI_HP_TROP_ELEVE": "h/p must not be greater than 2.5. h/p is forced to 2.5",
diff --git a/src/locale/messages.fr.json b/src/locale/messages.fr.json
index adf9a72ce..c4ab404cf 100644
--- a/src/locale/messages.fr.json
+++ b/src/locale/messages.fr.json
@@ -16,6 +16,7 @@
     "ERROR_DICHO_NULL_STEP": "Dichotomie&nbsp;: le pas pour la recherche de l'intervalle de départ ne devrait pas être nul",
     "ERROR_DICHO_TARGET_TOO_HIGH": "Dichotomie&nbsp;: la solution %targetSymbol%=%targetValue% est supérieure à la valeur maximale calculable %targetSymbol%(%variableSymbol%=%variableExtremeValue%)=%extremeTarget%)",
     "ERROR_DICHO_TARGET_TOO_LOW": "Dichotomie&nbsp;: la solution %targetSymbol%=%targetValue% est inférieure à la valeur minimale calculable %targetSymbol%(%variableSymbol%=%variableExtremeValue%)=%extremeTarget%)",
+    "ERROR_DIVISION_BY_ZERO": "Division par zéro",
     "ERROR_ELEVATION_ZI_LOWER_THAN_Z2": "La cote amont est plus basse que la cote aval",
     "ERROR_IN_CALC_CHAIN": "Une erreur est survenue dans la chaîne de calcul",
     "WARNING_ERROR_IN_CALC_CHAIN_STEPS": "Des erreurs sont survenues durant le calcul en chaîne",
@@ -465,6 +466,8 @@
     "INFO_EXAMPLE_LABEL_PAB_COMPLETE": "Passe à bassins type",
     "INFO_EXAMPLES_TITLE": "Exemples",
     "INFO_EXAMPLES_SUBTITLE": "Charger des exemples types",
+    "INFO_YAXB_TITRE": "Y = A.X + B",
+    "INFO_YAXB_TITRE_COURT": "Y=A.X+B",
     "WARNING_WARNINGS_ABSTRACT": "%nb% avertissements rencontrés lors du calcul",
     "WARNING_REMOUS_ARRET_CRITIQUE": "Arrêt du calcul&nbsp;: hauteur critique atteinte à l'abscisse %x%",
     "WARNING_STRUCTUREKIVI_HP_TROP_ELEVE": "h/p ne doit pas être supérieur à 2,5. h/p est forcé à 2,5",
-- 
GitLab