diff --git a/DEVELOPERS.md b/DEVELOPERS.md index 6be017691d7c96827c9be0717205e0a7ceecaad0..066253e5406953b65f207531f3b55c2d9dc75a15 100644 --- a/DEVELOPERS.md +++ b/DEVELOPERS.md @@ -278,7 +278,7 @@ En général les valeurs autorisées sont tirées de l'**enum** correspondant, d #### configuration -Dans le fichier de configuration du module, ajouter la définition des listes déroulantes dans "fields", notamment la propriété associée et la valeur par défaut; cette dernière est optionnelle et en son absence, la 1ère valeur de la liste sera sélectionnée. +Dans le fichier de configuration du module, ajouter la définition des listes déroulantes dans "fields", notamment la propriété associée et la valeur par défaut; cette dernière est optionnelle et en son absence, la 1ère valeur de la liste sera sélectionnée. Si la propriété associée est d'un type énuméré, la valeur par défaut est une des valeurs de l'enum. Exemple dans `trigo/config.json` (ici le 2ème champ ne spécifie pas de valeur par défaut) : @@ -301,6 +301,7 @@ Exemple dans `trigo/config.json` (ici le 2ème champ ne spécifie pas de valeur ] }, ``` +Dans cet exemple, la propriété `trigoOperation` est du type énuméré TrigoOperation (cf. code). **IMPORTANT** : les ids doivent être de la forme `select_`_`unmotclesansespacenitirets`_ @@ -415,13 +416,14 @@ Dans la configuration du module, ajouter un sélecteur de section associé à la "type": "select", "property": "nodeType", "help": { - "1": "hsl/types_sections.html#section-rectangulaire", - "0": "hsl/types_sections.html#section-circulaire", - "2": "hsl/types_sections.html#section-trapezoidale", - "3": "hsl/types_sections.html#section-parabolique" + "SectionRectangle": "hsl/types_sections.html#section-rectangulaire", + "SectionCercle": "hsl/types_sections.html#section-circulaire", + "SectionTrapeze": "hsl/types_sections.html#section-trapezoidale", + "SectionPuissance": "hsl/types_sections.html#section-parabolique" } } ``` +Les clés de la section `help` reprennent les valeurs de l'enum `SectionType`. La section par défaut du formulaire sera celle du sélecteur, que celle ci soit ou non configurée explicitement par le champ `default`. ### si le module agrège des modules enfants diff --git a/e2e/pab-cloisons-empty-fields.e2e-spec.ts b/e2e/pab-cloisons-empty-fields.e2e-spec.ts index d1443fb781cda8a0d46b70bab98c06930dafdc30..548b10d2e56731511c6a46586944e713a051cd26 100644 --- a/e2e/pab-cloisons-empty-fields.e2e-spec.ts +++ b/e2e/pab-cloisons-empty-fields.e2e-spec.ts @@ -60,12 +60,12 @@ describe("ngHyd - check the cross walls calculator has empty fields - ", () => { // calculate const calcButton = await calcPage.getCalculateButton(); await calcButton.click(); - await browser.pause(200); + await browser.pause(1000); // click "generate PAB" button const genButton = await calcPage.getGeneratePabButton(); await genButton.click(); - await browser.pause(2000); + await browser.pause(3000); await calcPage.checkEmptyOrFilledFields(["generatePabNbBassins"], [true]); }); diff --git a/jalhyd_branch b/jalhyd_branch index 9426cd15474d33fe7b65ba1e719ff221566e36dc..5a7919cd94e67c1fcc80781c8010285f52683c8d 100644 --- a/jalhyd_branch +++ b/jalhyd_branch @@ -1 +1,5 @@ +<<<<<<< Updated upstream 302-structure-ajouter-une-erreur-sur-l-ennoiement +======= +335-utiliser-des-identifiants-symboliques-plutot-que-numeriques-dans-les-fichiers +>>>>>>> Stashed changes diff --git a/src/app/calculators/bief/config.json b/src/app/calculators/bief/config.json index 4c486031c82b37414774c0f30c853dffad1eb763..f6296a2ed33da25a2493e7b84ed6d4d32feb485f 100644 --- a/src/app/calculators/bief/config.json +++ b/src/app/calculators/bief/config.json @@ -21,10 +21,10 @@ "property": "nodeType", "default": "SectionRectangle", "help": { - "1": "hsl/types_sections.html#section-rectangulaire", - "0": "hsl/types_sections.html#section-circulaire", - "2": "hsl/types_sections.html#section-trapezoidale", - "3": "hsl/types_sections.html#section-parabolique" + "SectionRectangle": "hsl/types_sections.html#section-rectangulaire", + "SectionCercle": "hsl/types_sections.html#section-circulaire", + "SectionTrapeze": "hsl/types_sections.html#section-trapezoidale", + "SectionPuissance": "hsl/types_sections.html#section-parabolique" } }, "LargeurFond", diff --git a/src/app/calculators/bief/en.json b/src/app/calculators/bief/en.json index 83ef6c03f737582786d59d38359f40974a6e617a..705a69b9b0d68b13a818b2b5f3a1623ae151ace6 100644 --- a/src/app/calculators/bief/en.json +++ b/src/app/calculators/bief/en.json @@ -2,16 +2,16 @@ "fs_water_line": "Type of water line", "select_regime": "Regime", - "REGIME_0": "Fluvial", - "REGIME_1": "Torrential", + "REGIME_Fluvial": "Fluvial", + "REGIME_Torrentiel": "Torrential", "fs_section": "Type of section", "select_section": "Choice of section type", - "SECTION_2": "Trapezoidal", - "SECTION_1": "Rectangular", - "SECTION_0": "Circular", - "SECTION_3": "Parabolic", + "SECTION_SectionTrapeze": "Trapezoidal", + "SECTION_SectionRectangle": "Rectangular", + "SECTION_SectionCercle": "Circular", + "SECTION_SectionPuissance": "Parabolic", "LargeurFond": "Width at bottom", "Fruit": "Bank slope", diff --git a/src/app/calculators/bief/fr.json b/src/app/calculators/bief/fr.json index e2389fae1c101e88fafc12a363a007e4be48cd4b..cd9db18b36c02b767a46ed1d0087460b6fce3823 100644 --- a/src/app/calculators/bief/fr.json +++ b/src/app/calculators/bief/fr.json @@ -2,16 +2,16 @@ "fs_water_line": "Type de ligne d'eau", "select_regime": "Régime", - "REGIME_0": "Fluvial", - "REGIME_1": "Torrentiel", + "REGIME_Fluvial": "Fluvial", + "REGIME_Torrentiel": "Torrentiel", "fs_section": "Type de section", "select_section": "Choix du type de section", - "SECTION_2": "Trapézoïdale", - "SECTION_1": "Rectangulaire", - "SECTION_0": "Circulaire", - "SECTION_3": "Parabolique", + "SECTION_SectionTrapeze": "Trapézoïdale", + "SECTION_SectionRectangle": "Rectangulaire", + "SECTION_SectionCercle": "Circulaire", + "SECTION_SectionPuissance": "Parabolique", "LargeurFond": "Largeur au fond", "Fruit": "Fruit des berges", diff --git a/src/app/calculators/courberemous/config.json b/src/app/calculators/courberemous/config.json index 14ee8981ce2957e684510c9b379e975ea1d7c916..b4d38751b7c685906392ff8c2b9f1b1e8e951fa7 100644 --- a/src/app/calculators/courberemous/config.json +++ b/src/app/calculators/courberemous/config.json @@ -9,10 +9,10 @@ "property": "nodeType", "default": "SectionRectangle", "help": { - "1": "hsl/types_sections.html#section-rectangulaire", - "0": "hsl/types_sections.html#section-circulaire", - "2": "hsl/types_sections.html#section-trapezoidale", - "3": "hsl/types_sections.html#section-parabolique" + "SectionRectangle": "hsl/types_sections.html#section-rectangulaire", + "SectionCercle": "hsl/types_sections.html#section-circulaire", + "SectionTrapeze": "hsl/types_sections.html#section-trapezoidale", + "SectionPuissance": "hsl/types_sections.html#section-parabolique" } }, "LargeurFond", @@ -65,9 +65,9 @@ "property": "methodeResolution", "default": "Trapezes", "help": { - "0": "../methodes_numeriques/integration_trapezes.html", - "1": "../methodes_numeriques/rk4.html", - "2": "../methodes_numeriques/euler_explicite.html" + "Trapezes": "../methodes_numeriques/integration_trapezes.html", + "RungeKutta4": "../methodes_numeriques/rk4.html", + "EulerExplicite": "../methodes_numeriques/euler_explicite.html" } } ] @@ -122,4 +122,4 @@ "Tau0": "hsl/section_parametree.html#la-force-tractrice-pa" } } -] \ No newline at end of file +] diff --git a/src/app/calculators/courberemous/en.json b/src/app/calculators/courberemous/en.json index 8e4ac96ad750673367350a1a51b485dc15d12ef5..c6095e5731bed755240d4838557fb40e96b5dab1 100644 --- a/src/app/calculators/courberemous/en.json +++ b/src/app/calculators/courberemous/en.json @@ -2,10 +2,10 @@ "fs_section": "Type of section", "select_section": "Choice of section type", - "SECTION_2": "Trapezoidal", - "SECTION_1": "Rectangular", - "SECTION_0": "Circular", - "SECTION_3": "Parabolic", + "SECTION_SectionTrapeze": "Trapezoidal", + "SECTION_SectionRectangle": "Rectangular", + "SECTION_SectionCercle": "Circular", + "SECTION_SectionPuissance": "Parabolic", "LargeurFond": "Width at bottom", "Fruit": "Bank slope", @@ -44,9 +44,9 @@ "UNIT_IMP": "N", "UNIT_TAU0": "Pa", - "RESOLUTION_0": "Integration by trapezoid", - "RESOLUTION_1": "Runge Kutta fourth order", - "RESOLUTION_2": "Explicit Euler", + "RESOLUTION_Trapezes": "Integration by trapezoid", + "RESOLUTION_RungeKutta4": "Runge Kutta fourth order", + "RESOLUTION_EulerExplicite": "Explicit Euler", "fs_target_data": "Data to compute", "select_target": "Choice of the data to compute", diff --git a/src/app/calculators/courberemous/fr.json b/src/app/calculators/courberemous/fr.json index 278c16ad429b35eaef592f49187980c96087a1e5..e4c5140dd6d422e8c0a75cfd6add56bd095f942b 100644 --- a/src/app/calculators/courberemous/fr.json +++ b/src/app/calculators/courberemous/fr.json @@ -2,10 +2,10 @@ "fs_section": "Type de section", "select_section": "Choix du type de section", - "SECTION_2": "Trapézoïdale", - "SECTION_1": "Rectangulaire", - "SECTION_0": "Circulaire", - "SECTION_3": "Parabolique", + "SECTION_SectionTrapeze": "Trapézoïdale", + "SECTION_SectionRectangle": "Rectangulaire", + "SECTION_SectionCercle": "Circulaire", + "SECTION_SectionPuissance": "Parabolique", "LargeurFond": "Largeur au fond", "Fruit": "Fruit des berges", @@ -44,9 +44,9 @@ "UNIT_IMP": "N", "UNIT_TAU0": "Pa", - "RESOLUTION_0": "Intégration par trapèzes", - "RESOLUTION_1": "Runge Kutta d'ordre 4", - "RESOLUTION_2": "Euler explicite", + "RESOLUTION_Trapezes": "Intégration par trapèzes", + "RESOLUTION_RungeKutta4": "Runge Kutta d'ordre 4", + "RESOLUTION_EulerExplicite": "Euler explicite", "fs_target_data": "Donnée à calculer", "select_target": "Choix de la donnée à calculer", diff --git a/src/app/calculators/espece/en.json b/src/app/calculators/espece/en.json index f88069bf4d6d30ec6fb11d65bb8c9bc9e2cf2937..6d8117134035cf21918795ece73563f0f8f364bd 100644 --- a/src/app/calculators/espece/en.json +++ b/src/app/calculators/espece/en.json @@ -7,6 +7,6 @@ "select_divingjetsupported": "Diving jets support", - "DIVINGJETSUPPORTED_0": "Not supported", - "DIVINGJETSUPPORTED_1": "Supported" + "DIVINGJETSUPPORTED_NOT_SUPPORTED": "Not supported", + "DIVINGJETSUPPORTED_SUPPORTED": "Supported" } diff --git a/src/app/calculators/espece/fr.json b/src/app/calculators/espece/fr.json index 98bfd5344e2a259d47d442d2ffae873ba26c620a..143ecfc311744178a723c3903782238f481767f0 100644 --- a/src/app/calculators/espece/fr.json +++ b/src/app/calculators/espece/fr.json @@ -7,6 +7,6 @@ "select_divingjetsupported": "Support des jets plongeants", - "DIVINGJETSUPPORTED_0": "Non supportés", - "DIVINGJETSUPPORTED_1": "Supportés" + "DIVINGJETSUPPORTED_NOT_SUPPORTED": "Non supportés", + "DIVINGJETSUPPORTED_SUPPORTED": "Supportés" } diff --git a/src/app/calculators/grille/config.json b/src/app/calculators/grille/config.json index b01502d19326776b5a52bdbdba2cb33e10494330..4a237d19d606ed7c2b70d5ceef0298723c5857f8 100644 --- a/src/app/calculators/grille/config.json +++ b/src/app/calculators/grille/config.json @@ -24,9 +24,9 @@ "property": "gridType", "default": "Conventional", "help": { - "0": "devalaison/grille.html#grille-conventionnelle", - "1": "devalaison/grille.html#grille-orientee", - "2": "devalaison/grille.html#grille-inclinee" + "Conventional": "devalaison/grille.html#grille-conventionnelle", + "Oriented": "devalaison/grille.html#grille-orientee", + "Inclined": "devalaison/grille.html#grille-inclinee" } }, { diff --git a/src/app/calculators/grille/en.json b/src/app/calculators/grille/en.json index 2ce401b7f9b431f9fbfb5d6fdf659ed49669dbf2..00b42e11f4057ebcb74525d87a67f50ab0794341 100644 --- a/src/app/calculators/grille/en.json +++ b/src/app/calculators/grille/en.json @@ -23,13 +23,13 @@ "select_gridtype": "Grid type", "select_gridprofile": "Bars profile", - "GRIDTYPE_0": "Conventional", - "GRIDTYPE_1": "Oriented", - "GRIDTYPE_2": "Inclined", + "GRIDTYPE_Conventional": "Conventional", + "GRIDTYPE_Oriented": "Oriented", + "GRIDTYPE_Inclined": "Inclined", - "GRIDPROFILE_0": "Rectangular", - "GRIDPROFILE_1": "Hydrodynamic", - "GRIDPROFILE_2": "Custom", + "GRIDPROFILE_Rectangular": "Rectangular", + "GRIDPROFILE_Hydrodynamic": "Hydrodynamic", + "GRIDPROFILE_Custom": "Custom", "H": "Water height", "HG": "Grid height", diff --git a/src/app/calculators/grille/fr.json b/src/app/calculators/grille/fr.json index 3b15b018fa52d23713f51c5e89820e8401be53f5..5b118c5cafad05ac7ec630ad869156dfcb3c579a 100644 --- a/src/app/calculators/grille/fr.json +++ b/src/app/calculators/grille/fr.json @@ -23,13 +23,13 @@ "select_gridtype": "Type de grille", "select_gridprofile": "Profil des barreaux", - "GRIDTYPE_0": "Conventionnelle", - "GRIDTYPE_1": "Orientée", - "GRIDTYPE_2": "Inclinée", + "GRIDTYPE_Conventional": "Conventionnelle", + "GRIDTYPE_Oriented": "Orientée", + "GRIDTYPE_Inclined": "Inclinée", - "GRIDPROFILE_0": "Rectangulaire", - "GRIDPROFILE_1": "Hydrodynamique", - "GRIDPROFILE_2": "Personnalisé", + "GRIDPROFILE_Rectangular": "Rectangulaire", + "GRIDPROFILE_Hydrodynamic": "Hydrodynamique", + "GRIDPROFILE_Custom": "Personnalisé", "H": "Hauteur d'eau", "HG": "Hauteur de grille", diff --git a/src/app/calculators/macrorugocompound/en.json b/src/app/calculators/macrorugocompound/en.json index 502bbb5804a80eef573a781b5d0388ad76c21bbe..3336bce68734f7fddd52c27802b4c9fe92553b97 100644 --- a/src/app/calculators/macrorugocompound/en.json +++ b/src/app/calculators/macrorugocompound/en.json @@ -21,6 +21,6 @@ "Y": "Water depth", "xCenter": "Mid-apron abscissa", - "PASSTYPE_0": "Multiple aprons", - "PASSTYPE_1": "Inclined apron" + "PASSTYPE_NOT_INCLINED": "Multiple aprons", + "PASSTYPE_INCLINED": "Inclined apron" } \ No newline at end of file diff --git a/src/app/calculators/macrorugocompound/fr.json b/src/app/calculators/macrorugocompound/fr.json index 08b69103fd6a17fcb54c0ac34cb3cd45823468e7..b5c3d4ce65c6d5cc35f1c3a62d32006f2cbea8f2 100644 --- a/src/app/calculators/macrorugocompound/fr.json +++ b/src/app/calculators/macrorugocompound/fr.json @@ -21,6 +21,6 @@ "Y": "Profondeur", "xCenter": "Abscisse du milieu du radier", - "PASSTYPE_0": "Radiers multiples", - "PASSTYPE_1": "Radier incliné" + "PASSTYPE_NOT_INCLINED": "Radiers multiples", + "PASSTYPE_INCLINED": "Radier incliné" } \ No newline at end of file diff --git a/src/app/calculators/par/config.json b/src/app/calculators/par/config.json index 00b267c5932bfe44d9956757b8c5ac64a4e5913b..513c517ee36efb58e0cc261f06f62d7ad46acb00 100644 --- a/src/app/calculators/par/config.json +++ b/src/app/calculators/par/config.json @@ -24,10 +24,10 @@ "property": "parType", "default": "PLANE", "help": { - "0": "par/theorie_plans.html", - "1": "par/theorie_fatou.html", - "2": "par/theorie_suractif.html", - "3": "par/theorie_mixte.html" + "PLANE": "par/theorie_plans.html", + "FATOU": "par/theorie_fatou.html", + "SUPERACTIVE": "par/theorie_suractif.html", + "CHEVRON": "par/theorie_mixte.html" } }, "ha", diff --git a/src/app/calculators/par/en.json b/src/app/calculators/par/en.json index a1271a1a13c1e76cf1eb2ed92ae12f6de701818e..95473e87a92704f0e29589af3bd175898445753b 100644 --- a/src/app/calculators/par/en.json +++ b/src/app/calculators/par/en.json @@ -31,8 +31,8 @@ "Hmax": "Maximal baffle height", "select_partype": "Pass type", - "PARTYPE_0": "Plane baffles", - "PARTYPE_1": "Fatou", - "PARTYPE_2": "Superactive", - "PARTYPE_3": "Mixed / chevrons" + "PARTYPE_PLANE": "Plane baffles", + "PARTYPE_FATOU": "Fatou", + "PARTYPE_SUPERACTIVE": "Superactive", + "PARTYPE_CHEVRON": "Mixed / chevrons" } \ No newline at end of file diff --git a/src/app/calculators/par/fr.json b/src/app/calculators/par/fr.json index 4d38734cad1520a14ea23ed65b0cee17e8786282..531e762cb5f27c70c1214ad78d56fa35a5c12964 100644 --- a/src/app/calculators/par/fr.json +++ b/src/app/calculators/par/fr.json @@ -31,8 +31,8 @@ "Hmax": "Hauteur maximale du ralentisseur", "select_partype": "Type de passe", - "PARTYPE_0": "Ralentisseurs plans", - "PARTYPE_1": "Fatou", - "PARTYPE_2": "Ralentisseurs suractifs", - "PARTYPE_3": "Mixte / chevrons" + "PARTYPE_PLANE": "Ralentisseurs plans", + "PARTYPE_FATOU": "Fatou", + "PARTYPE_SUPERACTIVE": "Ralentisseurs suractifs", + "PARTYPE_CHEVRON": "Mixte / chevrons" } \ No newline at end of file diff --git a/src/app/calculators/parsimulation/config.json b/src/app/calculators/parsimulation/config.json index 64b58bfc5ba4b83593035ee3ce6cd58757d8c402..6b302e7e51a090ca166477ab5f6df8a0b62b06d1 100644 --- a/src/app/calculators/parsimulation/config.json +++ b/src/app/calculators/parsimulation/config.json @@ -21,10 +21,10 @@ "property": "parType", "default": "PLANE", "help": { - "0": "par/theorie_plans.html", - "1": "par/theorie_fatou.html", - "2": "par/theorie_suractif.html", - "3": "par/theorie_mixte.html" + "PLANE": "par/theorie_plans.html", + "FATOU": "par/theorie_fatou.html", + "SUPERACTIVE": "par/theorie_suractif.html", + "CHEVRON": "par/theorie_mixte.html" } }, "L", diff --git a/src/app/calculators/parsimulation/en.json b/src/app/calculators/parsimulation/en.json index f6812ebc5e0b5db1988749ad95beac9ae8f74b07..056b90bf9abe04403fdcea343a1108b2b42480fa 100644 --- a/src/app/calculators/parsimulation/en.json +++ b/src/app/calculators/parsimulation/en.json @@ -31,8 +31,8 @@ "Hmax": "Maximal baffle height", "select_partype": "Pass type", - "PARTYPE_0": "Plane baffles", - "PARTYPE_1": "Fatou", - "PARTYPE_2": "Superactive", - "PARTYPE_3": "Mixed / chevrons" + "PARTYPE_PLANE": "Plane baffles", + "PARTYPE_FATOU": "Fatou", + "PARTYPE_SUPERACTIVE": "Superactive", + "PARTYPE_CHEVRON": "Mixed / chevrons" } diff --git a/src/app/calculators/parsimulation/fr.json b/src/app/calculators/parsimulation/fr.json index 59cdeef4f5d6c7cc0e3e14437f5c4f616d93e43b..835ac0f1e0684dcc70c449efd4354c1daab83d43 100644 --- a/src/app/calculators/parsimulation/fr.json +++ b/src/app/calculators/parsimulation/fr.json @@ -31,8 +31,8 @@ "Hmax": "Hauteur maximale du ralentisseur", "select_partype": "Type de passe", - "PARTYPE_0": "Ralentisseurs plans", - "PARTYPE_1": "Fatou", - "PARTYPE_2": "Ralentisseurs suractifs", - "PARTYPE_3": "Mixte / chevrons" + "PARTYPE_PLANE": "Ralentisseurs plans", + "PARTYPE_FATOU": "Fatou", + "PARTYPE_SUPERACTIVE": "Ralentisseurs suractifs", + "PARTYPE_CHEVRON": "Mixte / chevrons" } diff --git a/src/app/calculators/pressureloss/config.json b/src/app/calculators/pressureloss/config.json index c4bbbd561c12cf2ad5a9fff62b02551f55d6191e..c709811645a41ec66589d157ac7d2f1fa4da6d80 100644 --- a/src/app/calculators/pressureloss/config.json +++ b/src/app/calculators/pressureloss/config.json @@ -9,8 +9,8 @@ "property": "pressureLossType", "default": "LechaptCalmon", "help": { - "0": "hyd_en_charge/lechapt-calmon.html", - "1": "hyd_en_charge/strickler.html" + "LechaptCalmon": "hyd_en_charge/lechapt-calmon.html", + "Strickler": "hyd_en_charge/strickler.html" } }, { diff --git a/src/app/calculators/pressureloss/en.json b/src/app/calculators/pressureloss/en.json index 238ce4911f254eb944394648f20f4a72d7f5de13..559864d0aeeb14de66a665f229e1e2afd9b304e1 100644 --- a/src/app/calculators/pressureloss/en.json +++ b/src/app/calculators/pressureloss/en.json @@ -1,20 +1,20 @@ { "fs_pressureloss_law": "Pressure loss", "select_pressurelosstype": "Pressure loss law", - "PRESSURELOSSTYPE_0": "Lechapt-Calmon", - "PRESSURELOSSTYPE_1": "Strickler", + "PRESSURELOSSTYPE_LechaptCalmon": "Lechapt-Calmon", + "PRESSURELOSSTYPE_Strickler": "Strickler", "fs_materiau": "Type of material", "select_material": "Choice of material", - "MATERIAL_0": "Unlined cast iron - Coarse concrete (corrosive water)", - "MATERIAL_1": "Cast steel or uncoated - Coarse concrete (somewhat corrosive water)", - "MATERIAL_2": "Cast steel or cement coating", - "MATERIAL_3": "Cast iron or steel coating bitumen - Centrifuged concrete ", - "MATERIAL_4": "Rolled steel - Smooth concrete", - "MATERIAL_5": "Cast iron or steel coating centrifuged", - "MATERIAL_6": "PVC - Polyethylene", - "MATERIAL_7": "Hydraulically smooth pipe - 0.05 ≤ D ≤ 0.2", - "MATERIAL_8": "Hydraulically smooth pipe - 0.25 ≤ D ≤ 1", + "MATERIAL_UnlinedCastIronCoarseConcrete": "Unlined cast iron - Coarse concrete (corrosive water)", + "MATERIAL_CastSteelOrUncoatedCoarseConcrete": "Cast steel or uncoated - Coarse concrete (somewhat corrosive water)", + "MATERIAL_CastSteelOrCementCoating": "Cast steel or cement coating", + "MATERIAL_CastIronOrSteelCoatingBitumen": "Cast iron or steel coating bitumen - Centrifuged concrete ", + "MATERIAL_RolledSteelSmoothConcrete": "Rolled steel - Smooth concrete", + "MATERIAL_CastIronOrSteelCoatingCentrifuged": "Cast iron or steel coating centrifuged", + "MATERIAL_PVCPolyethylene": "PVC - Polyethylene", + "MATERIAL_HydraulicallySmoothPipe005D02": "Hydraulically smooth pipe - 0.05 ≤ D ≤ 0.2", + "MATERIAL_HydraulicallySmoothPipe025D1": "Hydraulically smooth pipe - 0.25 ≤ D ≤ 1", "L": "L", "M": "M", "N": "N", diff --git a/src/app/calculators/pressureloss/fr.json b/src/app/calculators/pressureloss/fr.json index fd1bd9c2ff98254fba30dbb457da7c4cfa6a4a98..7dacfc3d5efdac555ed6ef0bdc72a3c6f825761f 100644 --- a/src/app/calculators/pressureloss/fr.json +++ b/src/app/calculators/pressureloss/fr.json @@ -1,20 +1,20 @@ { "fs_pressureloss_law": "Perte de charge", "select_pressurelosstype": "Loi de perte de charge", - "PRESSURELOSSTYPE_0": "Lechapt-Calmon", - "PRESSURELOSSTYPE_1": "Strickler", + "PRESSURELOSSTYPE_LechaptCalmon": "Lechapt-Calmon", + "PRESSURELOSSTYPE_Strickler": "Strickler", "fs_materiau": "Type du matériau", "select_material": "Choix du matériau", - "MATERIAL_0": "Fonte ou acier non revêtus - Béton grossier (eau corrosive)", - "MATERIAL_1": "Fonte ou acier non revêtus - Béton grossier (eau peu corrosive)", - "MATERIAL_2": "Fonte ou acier revêtement ciment", - "MATERIAL_3": "Fonte ou acier revêtement bitume - Béton centrifugé", - "MATERIAL_4": "Acier laminé - Béton lisse", - "MATERIAL_5": "Fonte ou acier revêtement centrifugé", - "MATERIAL_6": "PVC - Polyéthylène", - "MATERIAL_7": "Tuyau hydrauliquement lisse - 0.05 ≤ D ≤ 0.2", - "MATERIAL_8": "Tuyau hydrauliquement lisse - 0.25 ≤ D ≤ 1", + "MATERIAL_UnlinedCastIronCoarseConcrete": "Fonte ou acier non revêtus - Béton grossier (eau corrosive)", + "MATERIAL_CastSteelOrUncoatedCoarseConcrete": "Fonte ou acier non revêtus - Béton grossier (eau peu corrosive)", + "MATERIAL_CastSteelOrCementCoating": "Fonte ou acier revêtement ciment", + "MATERIAL_CastIronOrSteelCoatingBitumen": "Fonte ou acier revêtement bitume - Béton centrifugé", + "MATERIAL_RolledSteelSmoothConcrete": "Acier laminé - Béton lisse", + "MATERIAL_CastIronOrSteelCoatingCentrifuged": "Fonte ou acier revêtement centrifugé", + "MATERIAL_PVCPolyethylene": "PVC - Polyéthylène", + "MATERIAL_HydraulicallySmoothPipe005D02": "Tuyau hydrauliquement lisse - 0.05 ≤ D ≤ 0.2", + "MATERIAL_HydraulicallySmoothPipe025D1": "Tuyau hydrauliquement lisse - 0.25 ≤ D ≤ 1", "L": "L", "M": "M", "N": "N", diff --git a/src/app/calculators/regimeuniforme/config.json b/src/app/calculators/regimeuniforme/config.json index c51679f69fa6f76e0dab55e116b2087def0ec427..24bcb81adc51a1de7e64ce713ca207f63221d9a4 100644 --- a/src/app/calculators/regimeuniforme/config.json +++ b/src/app/calculators/regimeuniforme/config.json @@ -9,10 +9,10 @@ "property": "nodeType", "default": "SectionRectangle", "help": { - "1": "hsl/types_sections.html#section-rectangulaire", - "0": "hsl/types_sections.html#section-circulaire", - "2": "hsl/types_sections.html#section-trapezoidale", - "3": "hsl/types_sections.html#section-parabolique" + "SectionRectangle": "hsl/types_sections.html#section-rectangulaire", + "SectionCercle": "hsl/types_sections.html#section-circulaire", + "SectionTrapeze": "hsl/types_sections.html#section-trapezoidale", + "SectionPuissance": "hsl/types_sections.html#section-parabolique" } }, "LargeurFond", diff --git a/src/app/calculators/regimeuniforme/en.json b/src/app/calculators/regimeuniforme/en.json index f1ea50fcc1ea626eb16e607dd10eaf83ae590de8..c8f40297497a7e3216b7593b90f33a73f40a1c5e 100644 --- a/src/app/calculators/regimeuniforme/en.json +++ b/src/app/calculators/regimeuniforme/en.json @@ -2,10 +2,10 @@ "fs_section": "Type of section", "select_section": "Choice of section type", - "SECTION_2": "Trapezoidal", - "SECTION_1": "Rectangular", - "SECTION_0": "Circular", - "SECTION_3": "Parabolic", + "SECTION_SectionTrapeze": "Trapezoidal", + "SECTION_SectionRectangle": "Rectangular", + "SECTION_SectionCercle": "Circular", + "SECTION_SectionPuissance": "Parabolic", "LargeurFond": "Width at bottom", "Fruit": "Bank slope", diff --git a/src/app/calculators/regimeuniforme/fr.json b/src/app/calculators/regimeuniforme/fr.json index 1363f63037679445ecea2101dca5b79a0d389b0b..012efb53a601327b683f3f948413acb321b21dd8 100644 --- a/src/app/calculators/regimeuniforme/fr.json +++ b/src/app/calculators/regimeuniforme/fr.json @@ -2,10 +2,10 @@ "fs_section": "Type de section", "select_section": "Choix du type de section", - "SECTION_2": "Trapézoïdale", - "SECTION_1": "Rectangulaire", - "SECTION_0": "Circulaire", - "SECTION_3": "Parabolique", + "SECTION_SectionTrapeze": "Trapézoïdale", + "SECTION_SectionRectangle": "Rectangulaire", + "SECTION_SectionCercle": "Circulaire", + "SECTION_SectionPuissance": "Parabolique", "LargeurFond": "Largeur au fond", "Fruit": "Fruit des berges", diff --git a/src/app/calculators/sectionparametree/config.json b/src/app/calculators/sectionparametree/config.json index a54bed3df167cb1d21602e2da88e22f3787f80d6..c7fab63ee3f2bc76f259aafc0ffd1df6f1fcb920 100644 --- a/src/app/calculators/sectionparametree/config.json +++ b/src/app/calculators/sectionparametree/config.json @@ -9,10 +9,10 @@ "property": "nodeType", "default": "SectionRectangle", "help": { - "1": "hsl/types_sections.html#section-rectangulaire", - "0": "hsl/types_sections.html#section-circulaire", - "2": "hsl/types_sections.html#section-trapezoidale", - "3": "hsl/types_sections.html#section-parabolique" + "SectionRectangle": "hsl/types_sections.html#section-rectangulaire", + "SectionCercle": "hsl/types_sections.html#section-circulaire", + "SectionTrapeze": "hsl/types_sections.html#section-trapezoidale", + "SectionPuissance": "hsl/types_sections.html#section-parabolique" } }, "LargeurBerge", diff --git a/src/app/calculators/sectionparametree/en.json b/src/app/calculators/sectionparametree/en.json index b13efd538c2c52436eaa99a51dea2d958869c855..78b03c486893a9af86ec175b579635722bf9ee70 100644 --- a/src/app/calculators/sectionparametree/en.json +++ b/src/app/calculators/sectionparametree/en.json @@ -2,10 +2,10 @@ "fs_section": "Type of section", "select_section": "Choice of section type", - "SECTION_2": "Trapezoidal", - "SECTION_1": "Rectangular", - "SECTION_0": "Circular", - "SECTION_3": "Parabolic", + "SECTION_SectionTrapeze": "Trapezoidal", + "SECTION_SectionRectangle": "Rectangular", + "SECTION_SectionCercle": "Circular", + "SECTION_SectionPuissance": "Parabolic", "LargeurFond": "Width at bottom", "Fruit": "Bank slope", diff --git a/src/app/calculators/sectionparametree/fr.json b/src/app/calculators/sectionparametree/fr.json index 769792403f0db555e6f4e2c5a86eec60f64dce8d..0640146b2b41d659cc71e3f1f7ee93530aee10c4 100644 --- a/src/app/calculators/sectionparametree/fr.json +++ b/src/app/calculators/sectionparametree/fr.json @@ -2,10 +2,10 @@ "fs_section": "Type de section", "select_section": "Choix du type de section", - "SECTION_2": "Trapézoïdale", - "SECTION_1": "Rectangulaire", - "SECTION_0": "Circulaire", - "SECTION_3": "Parabolique", + "SECTION_SectionTrapeze": "Trapézoïdale", + "SECTION_SectionRectangle": "Rectangulaire", + "SECTION_SectionCercle": "Circulaire", + "SECTION_SectionPuissance": "Parabolique", "LargeurFond": "Largeur au fond", "Fruit": "Fruit des berges", diff --git a/src/app/calculators/spp/en.json b/src/app/calculators/spp/en.json index faa569be485addfc746f3128fd709fb6aec4e252..9dfa115e44495a080c26ce8a6946153d2b9a9423 100644 --- a/src/app/calculators/spp/en.json +++ b/src/app/calculators/spp/en.json @@ -2,8 +2,8 @@ "fs_spp": "Parameters", "select_sppoperation": "Operation", - "SPPOPERATION_0": "Sum", - "SPPOPERATION_1": "Product", + "SPPOPERATION_SUM": "Sum", + "SPPOPERATION_PRODUCT": "Product", "Y": "Y", diff --git a/src/app/calculators/spp/fr.json b/src/app/calculators/spp/fr.json index f4de7fb40a80758a0acea18c589a56a87bf9edff..50fca2e6ad1f307d265027d1f5eaabd8cf6c8ebe 100644 --- a/src/app/calculators/spp/fr.json +++ b/src/app/calculators/spp/fr.json @@ -2,8 +2,8 @@ "fs_spp": "Paramètres", "select_sppoperation": "Opération", - "SPPOPERATION_0": "Somme", - "SPPOPERATION_1": "Produit", + "SPPOPERATION_SUM": "Somme", + "SPPOPERATION_PRODUCT": "Produit", "Y": "Y", diff --git a/src/app/calculators/trigo/en.json b/src/app/calculators/trigo/en.json index 90e4f849eb92cc299d4c622e35c27b5c503044c0..248506c187de8c122e7f04e8d174dbe9b3a5b815 100644 --- a/src/app/calculators/trigo/en.json +++ b/src/app/calculators/trigo/en.json @@ -2,16 +2,16 @@ "fs_trigo": "Trigonometric parameters", "select_operation": "Operation", - "OPERATION_0": "cos", - "OPERATION_1": "sin", - "OPERATION_2": "tan", - "OPERATION_3": "cosh", - "OPERATION_4": "sinh", - "OPERATION_5": "tanh", + "OPERATION_COS": "cos", + "OPERATION_SIN": "sin", + "OPERATION_TAN": "tan", + "OPERATION_COSH": "cosh", + "OPERATION_SINH": "sinh", + "OPERATION_TANH": "tanh", "select_unit": "Unit", - "UNIT_0": "Degrees", - "UNIT_1": "Radians", + "UNIT_DEG": "Degrees", + "UNIT_RAD": "Radians", "fs_params": "Equation parameters", diff --git a/src/app/calculators/trigo/fr.json b/src/app/calculators/trigo/fr.json index 2135546caa42d5b026125a2fac09630fb124c117..b52adc748c8c16ecb535a1e2b09851bef0c58007 100644 --- a/src/app/calculators/trigo/fr.json +++ b/src/app/calculators/trigo/fr.json @@ -2,16 +2,16 @@ "fs_trigo": "Paramètres trigonométriques", "select_operation": "Opération", - "OPERATION_0": "cos", - "OPERATION_1": "sin", - "OPERATION_2": "tan", - "OPERATION_3": "cosh", - "OPERATION_4": "sinh", - "OPERATION_5": "tanh", + "OPERATION_COS": "cos", + "OPERATION_SIN": "sin", + "OPERATION_TAN": "tan", + "OPERATION_COSH": "cosh", + "OPERATION_SINH": "sinh", + "OPERATION_TANH": "tanh", "select_unit": "Unité", - "UNIT_0": "Degrés", - "UNIT_1": "Radians", + "UNIT_DEG": "Degrés", + "UNIT_RAD": "Radians", "fs_params": "Paramètres de l'équation", diff --git a/src/app/calculators/verificateur/en.json b/src/app/calculators/verificateur/en.json index eb48e983534bc5a83f22f944946958989c632053..57ac4f9ac42f73d0f78b4019df96b2118415ae5c 100644 --- a/src/app/calculators/verificateur/en.json +++ b/src/app/calculators/verificateur/en.json @@ -3,10 +3,6 @@ "select_target_pass": "Fish pass to verify", - "select_pab_jet_type": "Jet type (PAB)", - "select_pab_jet_type_0": "Diving", - "select_pab_jet_type_1": "Surface", - "fs_species": "Species parameters", "select_species_list": "Species groups" diff --git a/src/app/calculators/verificateur/fr.json b/src/app/calculators/verificateur/fr.json index 13b6430de34ec99f1e365468b50041044f551c11..595e5b96138b3aa91595a862913d588a7070bc5f 100644 --- a/src/app/calculators/verificateur/fr.json +++ b/src/app/calculators/verificateur/fr.json @@ -3,10 +3,6 @@ "select_target_pass": "Passe à vérifier", - "select_pab_jet_type": "Type de jet (PAB)", - "select_pab_jet_type_0": "Plongeant", - "select_pab_jet_type_1": "Surface", - "fs_species": "Paramètres des espèces", "select_species_list": "Groupes d'espèces" diff --git a/src/app/components/select-field-line/select-field-line.component.ts b/src/app/components/select-field-line/select-field-line.component.ts index 7c4b067efcece001ba65882f713c0e286d660f48..10e11497d85195f0660833f15dce7553689edef7 100644 --- a/src/app/components/select-field-line/select-field-line.component.ts +++ b/src/app/components/select-field-line/select-field-line.component.ts @@ -74,10 +74,8 @@ export class SelectFieldLineComponent implements OnInit { if (typeof this._select.helpLink === "string") { link = this._select.helpLink; } else { // object - if (! this.isMultiple) { // @TODO manage multiple selections ? - const cv = this._select.getValue() as SelectEntry; - const entryId = cv.id.substring(this._select.entriesBaseId.length); - link = this._select.helpLink[entryId]; + if (!this.isMultiple) { // @TODO manage multiple selections ? + link = this._select.currentEntryHelpLink; } } window.open("assets/docs/" + this.appSetupService.language + "/calculators/" + link, "_blank"); @@ -91,10 +89,8 @@ export class SelectFieldLineComponent implements OnInit { if (typeof this._select.helpLink === "string") { return true; } else { // object - if (! this.isMultiple) { // @TODO manage multiple selections ? - const cv = this._select.getValue() as SelectEntry; - const entryId = cv.id.substring(this._select.entriesBaseId.length); - return Object.keys(this._select.helpLink).includes(entryId); + if (!this.isMultiple) { // @TODO manage multiple selections ? + return this._select.currentEntryHasHelpLink; } } } diff --git a/src/app/formulaire/elements/fieldset.ts b/src/app/formulaire/elements/fieldset.ts index 179920686e21ec6afe1b3af5234d5d7a1f25fd9f..2e008e447976778cec0691e68379e293137743e7 100644 --- a/src/app/formulaire/elements/fieldset.ts +++ b/src/app/formulaire/elements/fieldset.ts @@ -16,6 +16,7 @@ import { FieldsetContainer } from "./fieldset-container"; import { SelectFieldFactory } from "./select/select-field-factory"; import { FormulaireFixedVar } from "../definition/form-fixedvar"; import { SelectEntry } from "./select/select-entry"; +import { DeepSelectFieldIterator } from "../form-iterator/deep-selectfield-iterator"; export class FieldSet extends FormulaireElement implements IProperties { @@ -223,11 +224,9 @@ export class FieldSet extends FormulaireElement implements IProperties { // for all select fields known by the form, set selected value // from associated property - if (this.parentForm instanceof FormulaireFixedVar) { - for (const sel of this.parentForm.allSelectFields) { - if (sel.hasAssociatedNubProperty) { // ie. if select is a standard select - this.setSelectValueFromProperty(sel.id); - } + for (const sel of this.allSelectFields) { + if (sel.hasAssociatedNubProperty) { // ie. if select is a standard select + this.setSelectValueFromProperty(sel.id); } } } @@ -276,16 +275,14 @@ export class FieldSet extends FormulaireElement implements IProperties { // for all select fields known by the form, apply default value // to associated property, usually from associated enum - if (this.parentForm instanceof FormulaireFixedVar) { - for (const sel of this.parentForm.allSelectFields) { - if (sel.hasAssociatedNubProperty) { // ie. if select is a standard select - const prop = sel.associatedProperty; - const defaultValue = sel.configDefaultValue; - // Sets Nub default property, unless this property is already set - const currentValue = this.getPropValue(prop); - if (defaultValue !== undefined && currentValue === undefined) { - this.setPropValue(prop, enumValueFromString(prop, defaultValue)); - } + for (const sel of this.allSelectFields) { + if (sel.hasAssociatedNubProperty) { // ie. if select is a standard select + const prop = sel.associatedProperty; + const defaultValue = sel.configDefaultValue; + // Sets Nub default property, unless this property is already set + const currentValue = this.getPropValue(prop); + if (defaultValue !== undefined && currentValue === undefined) { + this.setPropValue(prop, enumValueFromString(prop, defaultValue)); } } } @@ -312,6 +309,13 @@ export class FieldSet extends FormulaireElement implements IProperties { } } + /** + * itère sur tous les SelectField + */ + public get allSelectFields(): IterableIterator<SelectField> { + return new DeepSelectFieldIterator(this); + } + // interface Observer update(sender: any, data: any) { diff --git a/src/app/formulaire/elements/select/select-field-nub-prop.ts b/src/app/formulaire/elements/select/select-field-nub-prop.ts index 233502db06a61c1133285507ce23046cf615f396..865cd3d3bc08359184fae4c11a1ef7a81de0bc67 100644 --- a/src/app/formulaire/elements/select/select-field-nub-prop.ts +++ b/src/app/formulaire/elements/select/select-field-nub-prop.ts @@ -28,9 +28,12 @@ export class SelectFieldNubProperty extends SelectField { // find enum associated to property const enumClass = Props.enumFromProperty[this._associatedProperty]; if (enumClass !== undefined) { + const keys = Object.keys(enumClass); // add one select entry per enum entry, in the enum order for (let j = 0; j < Object.keys(enumClass).length / 2; j++) { - this.addEntry(this.createOrGetEntry(this._entriesBaseId + j, j)); + const strEnum = enumClass[j]; + const enumVal = enumClass[strEnum]; + this.addEntry(this.createOrGetEntry(this._entriesBaseId + j, enumVal, strEnum)); } } } diff --git a/src/app/formulaire/elements/select/select-field-species-list.ts b/src/app/formulaire/elements/select/select-field-species-list.ts index 7b94345aa073bbd77580775e01dfc5504d78fb64..3784ace7d64c5e8bc721673bc72088162616e6b9 100644 --- a/src/app/formulaire/elements/select/select-field-species-list.ts +++ b/src/app/formulaire/elements/select/select-field-species-list.ts @@ -32,7 +32,7 @@ export class SelectFieldSpeciesList extends SelectField { for (let j = 1; j < Object.keys(FishSpecies).length / 2; j++) { // exclude "0" (SPECIES_CUSTOM) const spgId = FishSpecies[j].substring(FishSpecies[j].lastIndexOf("_") + 1); const e = this.createOrGetEntry(this._entriesBaseId + spgId, FishSpecies[j]); - e.intlInfo = { "isnub": false, "code": FishSpecies[j] } + e.intlInfo = { "isnub": false, "code": "FISHSPECIES_" + FishSpecies[j] } this.addEntry(e); } } diff --git a/src/app/formulaire/elements/select/select-field.ts b/src/app/formulaire/elements/select/select-field.ts index b45f59c42d2581d536dc40659295cb86ed57cc62..397a2e2cfdb0b9db513d13d4846cbd634971d6f6 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, Nub } from "jalhyd"; +import { enumValueFromString, Nub, Props } from "jalhyd"; export abstract class SelectField extends Field { @@ -36,11 +36,6 @@ export abstract class SelectField extends Field { */ protected _messageWhenEmpty: string; - /** - * map id <-> select entry - */ - protected _entryMap: { [key: string]: SelectEntry } = {}; - constructor(parent: FormulaireNode) { super(parent); this.clearEntries(); @@ -217,6 +212,13 @@ export abstract class SelectField extends Field { return this._associatedProperty !== undefined; } + /** + * @returns true if select field is associated to a nub property which is an enum + */ + public get hasAssociatedEnumProperty(): boolean { + return this._associatedProperty !== undefined && Props.enumFromProperty[this._associatedProperty] !== undefined; + } + /** * default value from configuration */ @@ -237,14 +239,21 @@ export abstract class SelectField extends Field { } protected createOrGetEntry(id: string, val: any, lbl?: string): SelectEntry { - let res: SelectEntry = this._entryMap[id]; + let res = this.getEntryFromId(id); if (res === undefined) { res = new SelectEntry(id, val, lbl); - this._entryMap[id] = res; } return res; } + private getEntryFromId(id: string) { + for (const se of this._entries) { + if (se.id === id) + return se; + } + return undefined; + } + public getEntryFromValue(val: any): SelectEntry { for (const se of this._entries) { if (se.value === val) { @@ -253,6 +262,35 @@ export abstract class SelectField extends Field { } } + /** + * @returns enum value associated to the given entry + * @param val currently selected entry if undefined + */ + private getEnumFromEntry(val: SelectEntry = undefined) { + const cv = val ?? this.getValue() as SelectEntry; + const entryId = cv.value; + const enumClass = Props.enumFromProperty[this.associatedProperty]; + if (enumClass === undefined) { + return undefined; + } + return enumClass[entryId]; + } + + /** + * @returns help link associated to the current entry + */ + public get currentEntryHelpLink() { + return this._helpLink[this.getEnumFromEntry()]; + } + + /** + * @returns true if current entry has an help link + */ + public get currentEntryHasHelpLink(): boolean { + const currValue = this.getEnumFromEntry(); + return Object.keys(this._helpLink).includes(currValue); + } + /** * Reloads available entries, trying to keep the current selected * value; does not notify observers if value did not change @@ -307,9 +345,10 @@ export abstract class SelectField extends Field { public updateLocalisation() { super.updateLocalisation(); for (const e of this._entries) { - const aId = e.id.split("_"); + const tmp = e.id.split("_"); + const id = this.hasAssociatedEnumProperty ? this.getEnumFromEntry(e) : tmp[2]; const trad = ServiceFactory.formulaireService.localizeText( - `${aId[1].toUpperCase()}_${aId[2]}`, + `${tmp[1].toUpperCase()}_${id}`, this.parentForm.currentNub.calcType ); e.label = trad; diff --git a/src/app/services/internationalisation.service.ts b/src/app/services/internationalisation.service.ts index deee494fecb63836be93eeb253b8253ed708742f..2209fd17d376667f504c09f7ad89e3997a2b24a7 100644 --- a/src/app/services/internationalisation.service.ts +++ b/src/app/services/internationalisation.service.ts @@ -1,6 +1,6 @@ import { Injectable, isDevMode } from "@angular/core"; -import { Message, MessageCode, Observable, Observer, Nub, CalculatorType, PreBarrage, PbCloison, PbBassin } from "jalhyd"; +import { Message, MessageCode, Observable, Observer, Nub, CalculatorType, PreBarrage, PbCloison, PbBassin, enumValueFromString } from "jalhyd"; import { StringMap } from "../stringmap"; import { ApplicationSetupService } from "./app-setup.service"; @@ -165,14 +165,31 @@ export class I18nService extends Observable implements Observer { if (! this._Messages) { return `*** messages not loaded: ${this._currentLanguage} ***`; } - if (this._Messages[textKey] !== undefined) { - return this.translateMessage(this._Messages[textKey], vars); + + // key is an enum ? + let key = textKey; + if (key.indexOf("INFO_ENUM_") !== -1) { + // key ends with a number ? convert end number to enum symbolic value + if (key.indexOf("_FISHSPECIES_") === -1) { // do not process fish species which values include '_' and numbers'... + const re = /^((INFO_ENUM)_(.+)_)([0-9]+)$/; + const res = key.match(re); + if (res !== null) { + const enumClass = res[3]; + const value = res[4]; + const val = enumValueFromString(enumClass, value); + key = res[1] + val; + } + } + } + + if (this._Messages[key] !== undefined) { + return this.translateMessage(this._Messages[key], vars); } else { // try general message - if (this._Messages !== undefined && this._Messages["INFO_LIB_" + textKey.toUpperCase()] !== undefined) { - return decodeHtml(this._Messages["INFO_LIB_" + textKey.toUpperCase()]); + if (this._Messages !== undefined && this._Messages["INFO_LIB_" + key.toUpperCase()] !== undefined) { + return decodeHtml(this._Messages["INFO_LIB_" + key.toUpperCase()]); } - return `*** message not found: ${textKey} ***`; + return `*** message not found: ${key} ***`; } } diff --git a/src/locale/messages.en.json b/src/locale/messages.en.json index de71e8bbbce84461d413a6540659e57d45673ed2..c17b98aa4764ae89b3b0950b17a210de60f3ff9e 100755 --- a/src/locale/messages.en.json +++ b/src/locale/messages.en.json @@ -156,48 +156,41 @@ "INFO_DIALOG_SAVE_SESSION_TITLE": "Save calculator modules", "INFO_EMPTY_SESSION_DIALOGUE_TEXT": "Warning ! All open calculators will be lost. Continue ?", "INFO_EMPTY_SESSION_DIALOGUE_TITRE": "New session", - "INFO_ENUM_MACRORUGOFLOWTYPE_0": "Emergent", - "INFO_ENUM_MACRORUGOFLOWTYPE_1": "Quasi-emergent", - "INFO_ENUM_MACRORUGOFLOWTYPE_2": "Submerged", - "INFO_ENUM_OUVRAGE_Q_MODE_0": "Weir", - "INFO_ENUM_OUVRAGE_Q_MODE_1": "Orifice", - "INFO_ENUM_OUVRAGE_Q_MODE_2": "Zero flow", - "INFO_ENUM_OUVRAGE_Q_REGIME_0": "Free flow", - "INFO_ENUM_OUVRAGE_Q_REGIME_1": "Partially submerged", - "INFO_ENUM_OUVRAGE_Q_REGIME_2": "Submerged", - "INFO_ENUM_OUVRAGE_Q_REGIME_3": "Zero flow", - "INFO_ENUM_PARFLOWREGIME_0": "Free", - "INFO_ENUM_PARFLOWREGIME_1": "Submerged", - "INFO_ENUM_SPECIES_1": "Salmon, trout [50-100] (1)", - "INFO_ENUM_SPECIES_2": "Mule (2)", - "INFO_ENUM_SPECIES_3a": "Great shad (3a)", - "INFO_ENUM_SPECIES_3b": "Shad (3b)", - "INFO_ENUM_SPECIES_3c": "Sea lamprey (3c)", - "INFO_ENUM_SPECIES_4a": "Trout [25-55] (4a)", - "INFO_ENUM_SPECIES_4b": "River trout [15-30] (4b)", - "INFO_ENUM_SPECIES_5": "Aspe, pike (5)", - "INFO_ENUM_SPECIES_6": "Common grayling (6)", - "INFO_ENUM_SPECIES_7a": "Barbel, chub, nase (7a)", - "INFO_ENUM_SPECIES_7b": "River lamprey (7b)", - "INFO_ENUM_SPECIES_8a": "Common carp (8a)", - "INFO_ENUM_SPECIES_8b": "Common bream, pike-perch (8b)", - "INFO_ENUM_SPECIES_8c": "White bream, ide, burbot, perch, tench (8c)", - "INFO_ENUM_SPECIES_8d": "Common dace (8d)", - "INFO_ENUM_SPECIES_9a": "Bleak, spirlin, barbel, souffia, crucian carp, roach... (9a)", - "INFO_ENUM_SPECIES_9b": "Apron, sculpins, ruffe, loach... (9b)", - "INFO_ENUM_SPECIES_10": "Sunbleak, bitterling, stickleback, minnow (10)", - "INFO_ENUM_SPECIES_11a": "European eel [yellow] (11a)", - "INFO_ENUM_SPECIES_11b": "European Eel [glass eel] (11b)", - "INFO_ENUM_STRUCTUREFLOWMODE_0": "Weir", - "INFO_ENUM_STRUCTUREFLOWMODE_1": "Orifice", - "INFO_ENUM_STRUCTUREFLOWMODE_2": "Zero flow", - "INFO_ENUM_STRUCTUREFLOWREGIME_0": "Free flow", - "INFO_ENUM_STRUCTUREFLOWREGIME_1": "Partially submerged", - "INFO_ENUM_STRUCTUREFLOWREGIME_2": "Submerged", - "INFO_ENUM_STRUCTUREFLOWREGIME_3": "Zero flow", - "INFO_ENUM_STRUCTUREJETTYPE_0": "diving", - "INFO_ENUM_STRUCTUREJETTYPE_1": "surface", - "INFO_ENUM_STRUCTUREJETTYPE_2": "not applicable", + "INFO_ENUM_MACRORUGOFLOWTYPE_EMERGENT": "Emergent", + "INFO_ENUM_MACRORUGOFLOWTYPE_QUASI_EMERGENT": "Quasi-emergent", + "INFO_ENUM_MACRORUGOFLOWTYPE_SUBMERGED": "Submerged", + "INFO_ENUM_PARFLOWREGIME_FREE": "Free", + "INFO_ENUM_PARFLOWREGIME_SUBMERGED": "Submerged", + "INFO_ENUM_FISHSPECIES_SPECIES_1": "Salmon, trout [50-100] (1)", + "INFO_ENUM_FISHSPECIES_SPECIES_2": "Mule (2)", + "INFO_ENUM_FISHSPECIES_SPECIES_3a": "Great shad (3a)", + "INFO_ENUM_FISHSPECIES_SPECIES_3b": "Shad (3b)", + "INFO_ENUM_FISHSPECIES_SPECIES_3c": "Sea lamprey (3c)", + "INFO_ENUM_FISHSPECIES_SPECIES_4a": "Trout [25-55] (4a)", + "INFO_ENUM_FISHSPECIES_SPECIES_4b": "River trout [15-30] (4b)", + "INFO_ENUM_FISHSPECIES_SPECIES_5": "Aspe, pike (5)", + "INFO_ENUM_FISHSPECIES_SPECIES_6": "Common grayling (6)", + "INFO_ENUM_FISHSPECIES_SPECIES_7a": "Barbel, chub, nase (7a)", + "INFO_ENUM_FISHSPECIES_SPECIES_7b": "River lamprey (7b)", + "INFO_ENUM_FISHSPECIES_SPECIES_8a": "Common carp (8a)", + "INFO_ENUM_FISHSPECIES_SPECIES_8b": "Common bream, pike-perch (8b)", + "INFO_ENUM_FISHSPECIES_SPECIES_8c": "White bream, ide, burbot, perch, tench (8c)", + "INFO_ENUM_FISHSPECIES_SPECIES_8d": "Common dace (8d)", + "INFO_ENUM_FISHSPECIES_SPECIES_9a": "Bleak, spirlin, barbel, souffia, crucian carp, roach... (9a)", + "INFO_ENUM_FISHSPECIES_SPECIES_9b": "Apron, sculpins, ruffe, loach... (9b)", + "INFO_ENUM_FISHSPECIES_SPECIES_10": "Sunbleak, bitterling, stickleback, minnow (10)", + "INFO_ENUM_FISHSPECIES_SPECIES_11a": "European eel [yellow] (11a)", + "INFO_ENUM_FISHSPECIES_SPECIES_11b": "European Eel [glass eel] (11b)", + "INFO_ENUM_STRUCTUREFLOWMODE_WEIR": "Weir", + "INFO_ENUM_STRUCTUREFLOWMODE_ORIFICE": "Orifice", + "INFO_ENUM_STRUCTUREFLOWMODE_NULL": "Zero flow", + "INFO_ENUM_STRUCTUREFLOWREGIME_FREE": "Free flow", + "INFO_ENUM_STRUCTUREFLOWREGIME_PARTIAL": "Partially submerged", + "INFO_ENUM_STRUCTUREFLOWREGIME_SUBMERGED": "Submerged", + "INFO_ENUM_STRUCTUREFLOWREGIME_NULL": "Zero flow", + "INFO_ENUM_STRUCTUREJETTYPE_PLONGEANT": "diving", + "INFO_ENUM_STRUCTUREJETTYPE_SURFACE": "surface", + "INFO_ENUM_STRUCTUREJETTYPE_SO": "not applicable", "INFO_CHART_BUTTON_TITLE_RESET_ZOOM": "Restore default zoom", "INFO_CHART_BUTTON_TITLE_EXPORT_IMAGE": "Save picture", "INFO_CHART_BUTTON_TITLE_ENTER_FS": "Display fullscreen", diff --git a/src/locale/messages.fr.json b/src/locale/messages.fr.json index fa314521578af872f57c717ca91fafdc2379e03f..9b9b7c1d4cfd554b339c1513bbaac2ef318909bb 100755 --- a/src/locale/messages.fr.json +++ b/src/locale/messages.fr.json @@ -156,48 +156,41 @@ "INFO_DIALOG_SAVE_SESSION_TITLE": "Enregistrer les modules de calcul", "INFO_EMPTY_SESSION_DIALOGUE_TEXT": "Attention ! Tous les modules de calcul ouverts seront perdus.", "INFO_EMPTY_SESSION_DIALOGUE_TITRE": "Démarrer une nouvelle session", - "INFO_ENUM_MACRORUGOFLOWTYPE_0": "Émergent", - "INFO_ENUM_MACRORUGOFLOWTYPE_1": "Quasi-émergent", - "INFO_ENUM_MACRORUGOFLOWTYPE_2": "Immergé", - "INFO_ENUM_OUVRAGE_Q_MODE_0": "Surface libre", - "INFO_ENUM_OUVRAGE_Q_MODE_1": "En charge", - "INFO_ENUM_OUVRAGE_Q_MODE_2": "Débit nul", - "INFO_ENUM_OUVRAGE_Q_REGIME_0": "Dénoyé", - "INFO_ENUM_OUVRAGE_Q_REGIME_1": "Partiellement noyé", - "INFO_ENUM_OUVRAGE_Q_REGIME_2": "Noyé", - "INFO_ENUM_OUVRAGE_Q_REGIME_3": "Débit nul", - "INFO_ENUM_PARFLOWREGIME_0": "Dénoyé", - "INFO_ENUM_PARFLOWREGIME_1": "Noyé", - "INFO_ENUM_SPECIES_1": "Saumon, truite [50-100] (1)", - "INFO_ENUM_SPECIES_2": "Mulets (2)", - "INFO_ENUM_SPECIES_3a": "Grande Alose (3a)", - "INFO_ENUM_SPECIES_3b": "Alose feinte (3b)", - "INFO_ENUM_SPECIES_3c": "Lamproie marine (3c)", - "INFO_ENUM_SPECIES_4a": "Truite [25-55] (4a)", - "INFO_ENUM_SPECIES_4b": "Truite de rivière [15-30] (4b)", - "INFO_ENUM_SPECIES_5": "Aspe, brochet (5)", - "INFO_ENUM_SPECIES_6": "Ombre commun (6)", - "INFO_ENUM_SPECIES_7a": "Barbeau, chevaine, hotu (7a)", - "INFO_ENUM_SPECIES_7b": "Lamproie fluviatile (7b)", - "INFO_ENUM_SPECIES_8a": "Carpe commune (8a)", - "INFO_ENUM_SPECIES_8b": "Brème commune, sandre (8b)", - "INFO_ENUM_SPECIES_8c": "Brème bordelière, ide, lotte, perche, tanche (8c)", - "INFO_ENUM_SPECIES_8d": "Vandoises (8d)", - "INFO_ENUM_SPECIES_9a": "Ablette, blageon, carrassin, gardon... (9a)", - "INFO_ENUM_SPECIES_9b": "Apron, chabots, goujons, loche... (9b)", - "INFO_ENUM_SPECIES_10": "Able, bouvière, épinoche(tte), vairons (10)", - "INFO_ENUM_SPECIES_11a": "Anguille européenne [jaune] (11a)", - "INFO_ENUM_SPECIES_11b": "Anguille européenne [civelle] (11b)", - "INFO_ENUM_STRUCTUREFLOWMODE_0": "Surface libre", - "INFO_ENUM_STRUCTUREFLOWMODE_1": "En charge", - "INFO_ENUM_STRUCTUREFLOWMODE_2": "Débit nul", - "INFO_ENUM_STRUCTUREFLOWREGIME_0": "Dénoyé", - "INFO_ENUM_STRUCTUREFLOWREGIME_1": "Partiellement noyé", - "INFO_ENUM_STRUCTUREFLOWREGIME_2": "Noyé", - "INFO_ENUM_STRUCTUREFLOWREGIME_3": "Débit nul", - "INFO_ENUM_STRUCTUREJETTYPE_0": "plongeant", - "INFO_ENUM_STRUCTUREJETTYPE_1": "de surface", - "INFO_ENUM_STRUCTUREJETTYPE_2": "sans objet", + "INFO_ENUM_MACRORUGOFLOWTYPE_EMERGENT": "Émergent", + "INFO_ENUM_MACRORUGOFLOWTYPE_QUASI_EMERGENT": "Quasi-émergent", + "INFO_ENUM_MACRORUGOFLOWTYPE_SUBMERGED": "Immergé", + "INFO_ENUM_PARFLOWREGIME_FREE": "Dénoyé", + "INFO_ENUM_PARFLOWREGIME_SUBMERGED": "Noyé", + "INFO_ENUM_FISHSPECIES_SPECIES_1": "Saumon, truite [50-100] (1)", + "INFO_ENUM_FISHSPECIES_SPECIES_2": "Mulets (2)", + "INFO_ENUM_FISHSPECIES_SPECIES_3a": "Grande Alose (3a)", + "INFO_ENUM_FISHSPECIES_SPECIES_3b": "Alose feinte (3b)", + "INFO_ENUM_FISHSPECIES_SPECIES_3c": "Lamproie marine (3c)", + "INFO_ENUM_FISHSPECIES_SPECIES_4a": "Truite [25-55] (4a)", + "INFO_ENUM_FISHSPECIES_SPECIES_4b": "Truite de rivière [15-30] (4b)", + "INFO_ENUM_FISHSPECIES_SPECIES_5": "Aspe, brochet (5)", + "INFO_ENUM_FISHSPECIES_SPECIES_6": "Ombre commun (6)", + "INFO_ENUM_FISHSPECIES_SPECIES_7a": "Barbeau, chevaine, hotu (7a)", + "INFO_ENUM_FISHSPECIES_SPECIES_7b": "Lamproie fluviatile (7b)", + "INFO_ENUM_FISHSPECIES_SPECIES_8a": "Carpe commune (8a)", + "INFO_ENUM_FISHSPECIES_SPECIES_8b": "Brème commune, sandre (8b)", + "INFO_ENUM_FISHSPECIES_SPECIES_8c": "Brème bordelière, ide, lotte, perche, tanche (8c)", + "INFO_ENUM_FISHSPECIES_SPECIES_8d": "Vandoises (8d)", + "INFO_ENUM_FISHSPECIES_SPECIES_9a": "Ablette, blageon, carrassin, gardon... (9a)", + "INFO_ENUM_FISHSPECIES_SPECIES_9b": "Apron, chabots, goujons, loche... (9b)", + "INFO_ENUM_FISHSPECIES_SPECIES_10": "Able, bouvière, épinoche(tte), vairons (10)", + "INFO_ENUM_FISHSPECIES_SPECIES_11a": "Anguille européenne [jaune] (11a)", + "INFO_ENUM_FISHSPECIES_SPECIES_11b": "Anguille européenne [civelle] (11b)", + "INFO_ENUM_STRUCTUREFLOWMODE_WEIR": "Surface libre", + "INFO_ENUM_STRUCTUREFLOWMODE_ORIFICE": "En charge", + "INFO_ENUM_STRUCTUREFLOWMODE_NULL": "Débit nul", + "INFO_ENUM_STRUCTUREFLOWREGIME_FREE": "Dénoyé", + "INFO_ENUM_STRUCTUREFLOWREGIME_PARTIAL": "Partiellement noyé", + "INFO_ENUM_STRUCTUREFLOWREGIME_SUBMERGED": "Noyé", + "INFO_ENUM_STRUCTUREFLOWREGIME_NULL": "Débit nul", + "INFO_ENUM_STRUCTUREJETTYPE_PLONGEANT": "plongeant", + "INFO_ENUM_STRUCTUREJETTYPE_SURFACE": "de surface", + "INFO_ENUM_STRUCTUREJETTYPE_SO": "sans objet", "INFO_CHART_BUTTON_TITLE_RESET_ZOOM": "Réinitialiser le zoom", "INFO_CHART_BUTTON_TITLE_EXPORT_IMAGE": "Enregistrer l'image", "INFO_CHART_BUTTON_TITLE_ENTER_FS": "Afficher en plein écran",