From 1a73ac2afb97ae2b30ae06d2b7235f8cd3896476 Mon Sep 17 00:00:00 2001 From: "mathias.chouet" <mathias.chouet@irstea.fr> Date: Wed, 24 Jul 2019 12:26:42 +0200 Subject: [PATCH 01/13] Set jalhyd_branch --- jalhyd_branch | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/jalhyd_branch b/jalhyd_branch index 1f7391f92..4cc13e7cb 100644 --- a/jalhyd_branch +++ b/jalhyd_branch @@ -1 +1 @@ -master +66-integrer-au-modele-un-maximum-d-informations-pour-alleger-la-configuration-des-modules-dans-nghyd -- GitLab From ab82e028855c1ecf323083a4c594c3c8fdc5f5a8 Mon Sep 17 00:00:00 2001 From: "mathias.chouet" <mathias.chouet@irstea.fr> Date: Wed, 24 Jul 2019 16:54:53 +0200 Subject: [PATCH 02/13] Removed Lechapt-Calmon and SectionParametree dependencies from config, use hardcoded presets from model instead --- README.md | 6 +- .../lechapt-calmon/lechapt-calmon.config.json | 180 +----------------- .../section-param/section-param.config.json | 67 +------ .../base-param-input.component.ts | 4 +- .../concrete/form-lechapt-calmon.ts | 10 +- src/app/formulaire/field.ts | 37 ---- src/app/formulaire/ngparam.ts | 2 +- src/app/formulaire/select-field.ts | 29 ++- 8 files changed, 51 insertions(+), 284 deletions(-) diff --git a/README.md b/README.md index 2549eceba..624bb30d2 100644 --- a/README.md +++ b/README.md @@ -76,9 +76,9 @@ Custom Material SVG Icons will only show up when the application is deployed on constructor(rL: number, rW: number, rA:number=undefined) { super(); - this._L = new ParamDefinition(this, ComputeNodeType.LechaptCalmon, 'L', ParamDomainValue.POS, rL); - this._W = new ParamDefinition(this, ComputeNodeType.LechaptCalmon, 'W', ParamDomainValue.POS, rW); - this._A = new ParamDefinition(this, ComputeNodeType.LechaptCalmon, 'A', ParamDomainValue.POS, rA); + this._L = new ParamDefinition(this, ComputeNodeType.LechaptCalmon, 'L', "m", ParamDomainValue.POS, rL); + this._W = new ParamDefinition(this, ComputeNodeType.LechaptCalmon, 'W', "m", ParamDomainValue.POS, rW); + this._A = new ParamDefinition(this, ComputeNodeType.LechaptCalmon, 'A', undefined, ParamDomainValue.POS, rA); this.addParamDefinition(this._L); this.addParamDefinition(this._W); diff --git a/src/app/calculators/lechapt-calmon/lechapt-calmon.config.json b/src/app/calculators/lechapt-calmon/lechapt-calmon.config.json index 040f73352..283d67aa2 100644 --- a/src/app/calculators/lechapt-calmon/lechapt-calmon.config.json +++ b/src/app/calculators/lechapt-calmon/lechapt-calmon.config.json @@ -7,194 +7,22 @@ { "id": "select_material", "type": "select", - "select": [ - { - "id": "select_material_0" - }, - { - "id": "select_material_1" - }, - { - "id": "select_material_2" - }, - { - "id": "select_material_3" - }, - { - "id": "select_material_4" - }, - { - "id": "select_material_5" - }, - { - "id": "select_material_6" - }, - { - "id": "select_material_7" - }, - { - "id": "select_material_8" - }, - { - "id": "select_material_9" - } - ] + "source": "lechapt_calmon_materials" }, { "type": "input", "id": "L", - "unit": "", - "dep_value": [ - { - "refid": "select_material", - "refvalue": "select_material_1", - "value": "1.863" - }, - { - "refid": "select_material", - "refvalue": "select_material_2", - "value": "1.601" - }, - { - "refid": "select_material", - "refvalue": "select_material_3", - "value": "1.40" - }, - { - "refid": "select_material", - "refvalue": "select_material_4", - "value": "1.16" - }, - { - "refid": "select_material", - "refvalue": "select_material_5", - "value": "1.1" - }, - { - "refid": "select_material", - "refvalue": "select_material_6", - "value": "1.049" - }, - { - "refid": "select_material", - "refvalue": "select_material_7", - "value": "1.01" - }, - { - "refid": "select_material", - "refvalue": "select_material_8", - "value": "0.916" - }, - { - "refid": "select_material", - "refvalue": "select_material_9", - "value": "0.971" - } - ] + "unit": "" }, { "type": "input", "id": "M", - "unit": "", - "dep_value": [ - { - "refid": "select_material", - "refvalue": "select_material_1", - "value": "2" - }, - { - "refid": "select_material", - "refvalue": "select_material_2", - "value": "1.975" - }, - { - "refid": "select_material", - "refvalue": "select_material_3", - "value": "1.96" - }, - { - "refid": "select_material", - "refvalue": "select_material_4", - "value": "1.93" - }, - { - "refid": "select_material", - "refvalue": "select_material_5", - "value": "1.89" - }, - { - "refid": "select_material", - "refvalue": "select_material_6", - "value": "1.86" - }, - { - "refid": "select_material", - "refvalue": "select_material_7", - "value": "1.84" - }, - { - "refid": "select_material", - "refvalue": "select_material_8", - "value": "1.78" - }, - { - "refid": "select_material", - "refvalue": "select_material_9", - "value": "1.81" - } - ] + "unit": "" }, { "type": "input", "id": "N", - "unit": "", - "dep_value": [ - { - "refid": "select_material", - "refvalue": "select_material_1", - "value": "5.33" - }, - { - "refid": "select_material", - "refvalue": "select_material_2", - "value": "5.25" - }, - { - "refid": "select_material", - "refvalue": "select_material_3", - "value": "5.19" - }, - { - "refid": "select_material", - "refvalue": "select_material_4", - "value": "5.11" - }, - { - "refid": "select_material", - "refvalue": "select_material_5", - "value": "5.01" - }, - { - "refid": "select_material", - "refvalue": "select_material_6", - "value": "4.93" - }, - { - "refid": "select_material", - "refvalue": "select_material_7", - "value": "4.88" - }, - { - "refid": "select_material", - "refvalue": "select_material_8", - "value": "4.78" - }, - { - "refid": "select_material", - "refvalue": "select_material_9", - "value": "4.81" - } - ] + "unit": "" } ] }, diff --git a/src/app/calculators/section-param/section-param.config.json b/src/app/calculators/section-param/section-param.config.json index b9076cd68..0d8a63323 100644 --- a/src/app/calculators/section-param/section-param.config.json +++ b/src/app/calculators/section-param/section-param.config.json @@ -7,96 +7,43 @@ { "id": "select_section", "type": "select", - "select": [ - { - "id": "select_section_trapez", - "enum": "ComputeNodeType.SectionTrapeze" - }, - { - "id": "select_section_rect", - "enum": "ComputeNodeType.SectionRectangle" - }, - { - "id": "select_section_circ", - "enum": "ComputeNodeType.SectionCercle" - }, - { - "id": "select_section_puiss", - "enum": "ComputeNodeType.SectionPuissance" - } - ] + "source": "acsection_available_sections" }, { "type": "input", "id": "LargeurFond", "unit": "m", - "nodeType": "SectionTrapeze", - "dep_exist": [ - { - "refid": "select_section", - "refvalue": "select_section_trapez" - } - ] + "nodeType": "SectionTrapeze" }, { "type": "input", "id": "Fruit", "nodeType": "SectionTrapeze", - "unit": "m/m", - "dep_exist": [ - { - "refid": "select_section", - "refvalue": "select_section_trapez" - } - ] + "unit": "m/m" }, { "type": "input", "id": "LargeurBerge", "unit": "m", - "nodeType": "SectionRectangle", - "dep_exist": [ - { - "refid": "select_section", - "refvalue": "select_section_rect" - } - ] + "nodeType": "SectionRectangle" }, { "type": "input", "id": "D", "unit": "m", - "nodeType": "SectionCercle", - "dep_exist": [ - { - "refid": "select_section", - "refvalue": "select_section_circ" - } - ] + "nodeType": "SectionCercle" }, { "type": "input", "id": "k", "unit": "", - "nodeType": "SectionPuissance", - "dep_exist": [ - { - "refid": "select_section", - "refvalue": "select_section_puiss" - } - ] + "nodeType": "SectionPuissance" }, { "type": "input", "id": "LargeurBerge", "unit": "m", - "nodeType": "SectionPuissance", - "dep_exist": [ - { - "refid": "select_section", - "refvalue": "select_section_puiss" - } - ] + "nodeType": "SectionPuissance" } ] }, diff --git a/src/app/components/base-param-input/base-param-input.component.ts b/src/app/components/base-param-input/base-param-input.component.ts index 4c31d115f..447a9900e 100644 --- a/src/app/components/base-param-input/base-param-input.component.ts +++ b/src/app/components/base-param-input/base-param-input.component.ts @@ -12,9 +12,9 @@ import { NgParameter } from "../../formulaire/ngparam"; export class NgBaseParam extends Observable { private _param: ParamDefinition; - constructor(symb: string, d: ParamDomain | ParamDomainValue, val: number) { + constructor(symb: string, d: ParamDomain | ParamDomainValue, val: number, unit?: string) { super(); - this._param = new ParamDefinition(null, symb, d, val); + this._param = new ParamDefinition(null, symb, d, unit, val); } public get param() { diff --git a/src/app/formulaire/definition/concrete/form-lechapt-calmon.ts b/src/app/formulaire/definition/concrete/form-lechapt-calmon.ts index 524994ec4..2d7376222 100644 --- a/src/app/formulaire/definition/concrete/form-lechapt-calmon.ts +++ b/src/app/formulaire/definition/concrete/form-lechapt-calmon.ts @@ -1,4 +1,4 @@ -import { Observer } from "jalhyd"; +import { LechaptCalmon, Observer } from "jalhyd"; import { SelectField } from "../../select-field"; import { FormulaireBase } from "./form-base"; import { NgParamInputComponent } from "../../../components/ngparam-input/ngparam-input.component"; @@ -24,7 +24,15 @@ export class FormulaireLechaptCalmon extends FormulaireBase implements Observer // en cas de changement de valeur du select de matériau, effacement des résultats et MAJ des champs L,M,N if (sender instanceof SelectField) { if (data.action === "select") { + if (data.value._value !== "") { + (this.currentNub as LechaptCalmon).applyMaterialPreset(data.value._value); + } + // update GUI + this.getParamFromSymbol("L").notifyValueModified(this); + this.getParamFromSymbol("M").notifyValueModified(this); + this.getParamFromSymbol("N").notifyValueModified(this); this.reset(); + } } if (sender instanceof NgParamInputComponent) { diff --git a/src/app/formulaire/field.ts b/src/app/formulaire/field.ts index 3bdbef3c0..5982118c5 100644 --- a/src/app/formulaire/field.ts +++ b/src/app/formulaire/field.ts @@ -1,44 +1,7 @@ import { FormulaireElement } from "./formulaire-element"; -import { ValueDependency } from "./dependency/value-dependency"; -import { Dependency } from "./dependency/dependency"; -import { isNumber } from "util"; export abstract class Field extends FormulaireElement { public abstract getValue(): any; public abstract setValue(sender: any, val: any): void; - - private parse_value_dependencies(json: {}) { - for (const di in json) { - const d = json[di]; - const masterValue = d["refvalue"]; - const dep = new ValueDependency(this, d["refid"], masterValue); - dep.slaveValue = d["value"]; - this._dependencies.push(dep); - } - } - - public parseDependencies(json: {}) { - super.parseDependencies(json); - - const dep = json["dep_value"]; - if (dep !== undefined) { - this.parse_value_dependencies(dep); - } - } - - /** - * applique une dépendance dont la condition a été vérifiée - */ - public applyDependency(d: Dependency) { - if (d instanceof ValueDependency) { - if (isNumber(d.slaveValue)) { - this.setValue(this, +d.slaveValue); - } else { - this.setValue(this, d.slaveValue); - } - } else { - super.applyDependency(d); - } - } } diff --git a/src/app/formulaire/ngparam.ts b/src/app/formulaire/ngparam.ts index 5cc95c11f..5562845dd 100644 --- a/src/app/formulaire/ngparam.ts +++ b/src/app/formulaire/ngparam.ts @@ -307,7 +307,7 @@ export class NgParameter extends InputField implements Observer { /** * notification envoyée après la modification de la valeur du paramètre */ - private notifyValueModified(sender: any) { + public notifyValueModified(sender: any) { let val: number; if (this._paramDef.valueMode === ParamValueMode.SINGLE) { val = this._paramDef.singleValue; diff --git a/src/app/formulaire/select-field.ts b/src/app/formulaire/select-field.ts index 77178478b..22fe8775c 100644 --- a/src/app/formulaire/select-field.ts +++ b/src/app/formulaire/select-field.ts @@ -1,4 +1,4 @@ -import { StructureType, LoiDebit, ComputeNodeType, MethodeResolution } from "jalhyd"; +import { LechaptCalmon, acSection } from "jalhyd"; import { Field } from "./field"; import { SelectEntry } from "./select-entry"; @@ -111,8 +111,29 @@ export class SelectField extends Field { public parseConfig(field: {}, data?: {}) { this._confId = field["id"]; - const values = field["select"]; - for (const v of values) { + const source = field["source"]; + // ad-hoc cases + switch (source) { + + case "lechapt_calmon_materials": + this.addEntry(new SelectEntry("select_material_empty", "")); + let i = 0; + for (const mat of LechaptCalmon.materials) { + const e: SelectEntry = new SelectEntry("select_material_" + (i + 1), i); + this.addEntry(e); + i++; + } + break; + + case "acsection_available_sections": + for (const sec of acSection.availableSectionTypes) { + const e: SelectEntry = new SelectEntry("select_section_" + sec.id, sec.value); + console.log(">> adding entry", e); + this.addEntry(e); + } + break; + } + /* for (const v of values) { let val: string; if (v.enum) { const tmp = v.enum.split("."); @@ -143,6 +164,6 @@ export class SelectField extends Field { const id = v["id"]; const e: SelectEntry = new SelectEntry(id, val); this.addEntry(e); - } + } */ } } -- GitLab From a3dcf6529668b3eff9ecc983471d7dce724dcb76 Mon Sep 17 00:00:00 2001 From: "mathias.chouet" <mathias.chouet@irstea.fr> Date: Thu, 25 Jul 2019 09:29:07 +0200 Subject: [PATCH 03/13] Removed RegimeUniforme dependencies from config, use hardcoded presets from model instead --- .../regime-uniforme.config.json | 67 ++----------------- 1 file changed, 7 insertions(+), 60 deletions(-) diff --git a/src/app/calculators/regime-uniforme/regime-uniforme.config.json b/src/app/calculators/regime-uniforme/regime-uniforme.config.json index ddd0c099a..a5623b000 100644 --- a/src/app/calculators/regime-uniforme/regime-uniforme.config.json +++ b/src/app/calculators/regime-uniforme/regime-uniforme.config.json @@ -7,96 +7,43 @@ { "id": "select_section", "type": "select", - "select": [ - { - "id": "select_section_trapez", - "enum": "ComputeNodeType.SectionTrapeze" - }, - { - "id": "select_section_rect", - "enum": "ComputeNodeType.SectionRectangle" - }, - { - "id": "select_section_circ", - "enum": "ComputeNodeType.SectionCercle" - }, - { - "id": "select_section_puiss", - "enum": "ComputeNodeType.SectionPuissance" - } - ] + "source": "acsection_available_sections" }, { "type": "input", "id": "LargeurFond", "nodeType": "SectionTrapeze", - "unit": "m", - "dep_exist": [ - { - "refid": "select_section", - "refvalue": "select_section_trapez" - } - ] + "unit": "m" }, { "type": "input", "id": "Fruit", "nodeType": "SectionTrapeze", - "unit": "m/m", - "dep_exist": [ - { - "refid": "select_section", - "refvalue": "select_section_trapez" - } - ] + "unit": "m/m" }, { "type": "input", "id": "LargeurBerge", "nodeType": "SectionRectangle", - "unit": "m", - "dep_exist": [ - { - "refid": "select_section", - "refvalue": "select_section_rect" - } - ] + "unit": "m" }, { "type": "input", "id": "D", "nodeType": "SectionCercle", - "unit": "m", - "dep_exist": [ - { - "refid": "select_section", - "refvalue": "select_section_circ" - } - ] + "unit": "m" }, { "type": "input", "id": "k", "nodeType": "SectionPuissance", - "unit": "", - "dep_exist": [ - { - "refid": "select_section", - "refvalue": "select_section_puiss" - } - ] + "unit": "" }, { "type": "input", "id": "LargeurBerge", "nodeType": "SectionPuissance", - "unit": "m", - "dep_exist": [ - { - "refid": "select_section", - "refvalue": "select_section_puiss" - } - ] + "unit": "m" } ] }, -- GitLab From bd65b7da0799988e4d18877676d93aedda535b53 Mon Sep 17 00:00:00 2001 From: "mathias.chouet" <mathias.chouet@irstea.fr> Date: Thu, 25 Jul 2019 10:21:08 +0200 Subject: [PATCH 04/13] Removed CourbeRemous dependencies from config, use hardcoded presets from model instead --- src/app/calculators/remous/remous.config.json | 148 ++---------------- .../definition/concrete/form-courbe-remous.ts | 2 +- src/app/formulaire/select-field.ts | 18 ++- 3 files changed, 26 insertions(+), 142 deletions(-) diff --git a/src/app/calculators/remous/remous.config.json b/src/app/calculators/remous/remous.config.json index 8fcdf1c4d..f7ea148e2 100644 --- a/src/app/calculators/remous/remous.config.json +++ b/src/app/calculators/remous/remous.config.json @@ -7,96 +7,43 @@ { "id": "select_section", "type": "select", - "select": [ - { - "id": "select_section_trapez", - "enum": "ComputeNodeType.SectionTrapeze" - }, - { - "id": "select_section_rect", - "enum": "ComputeNodeType.SectionRectangle" - }, - { - "id": "select_section_circ", - "enum": "ComputeNodeType.SectionCercle" - }, - { - "id": "select_section_puiss", - "enum": "ComputeNodeType.SectionPuissance" - } - ] + "source": "acsection_available_sections" }, { "type": "input", "id": "LargeurFond", "nodeType": "SectionTrapeze", - "unit": "m", - "dep_exist": [ - { - "refid": "select_section", - "refvalue": "select_section_trapez" - } - ] + "unit": "m" }, { "type": "input", "id": "Fruit", "nodeType": "SectionTrapeze", - "unit": "m/m", - "dep_exist": [ - { - "refid": "select_section", - "refvalue": "select_section_trapez" - } - ] + "unit": "m/m" }, { "type": "input", "id": "LargeurBerge", "nodeType": "SectionRectangle", - "unit": "m", - "dep_exist": [ - { - "refid": "select_section", - "refvalue": "select_section_rect" - } - ] + "unit": "m" }, { "type": "input", "id": "D", "nodeType": "SectionCercle", - "unit": "m", - "dep_exist": [ - { - "refid": "select_section", - "refvalue": "select_section_circ" - } - ] + "unit": "m" }, { "type": "input", "id": "k", "nodeType": "SectionPuissance", - "unit": "", - "dep_exist": [ - { - "refid": "select_section", - "refvalue": "select_section_puiss" - } - ] + "unit": "" }, { "type": "input", "id": "LargeurBerge", "nodeType": "SectionPuissance", - "unit": "m", - "dep_exist": [ - { - "refid": "select_section", - "refvalue": "select_section_puiss" - } - ] + "unit": "m" } ] }, @@ -166,20 +113,7 @@ { "id": "select_resolution", "type": "select", - "select": [ - { - "id": "select_resolution_trap", - "enum": "MethodeResolution.Trapezes" - }, - { - "id": "select_resolution_rk4", - "enum": "MethodeResolution.RungeKutta4" - }, - { - "id": "select_resolution_euler", - "enum": "MethodeResolution.EulerExplicite" - } - ] + "source": "remous_methode_resolution" } ] }, @@ -190,71 +124,7 @@ { "id": "select_target", "type": "select", - "select": [ - { - "id": "select_target_none" - }, - { - "id": "select_target_Hs", - "value": "Hs" - }, - { - "id": "select_target_Hsc", - "value": "Hsc" - }, - { - "id": "select_target_B", - "value": "B" - }, - { - "id": "select_target_P", - "value": "P" - }, - { - "id": "select_target_S", - "value": "S" - }, - { - "id": "select_target_R", - "value": "R" - }, - { - "id": "select_target_V", - "value": "V" - }, - { - "id": "select_target_Fr", - "value": "Fr" - }, - { - "id": "select_target_Yf", - "value": "Yf" - }, - { - "id": "select_target_Yt", - "value": "Yt" - }, - { - "id": "select_target_Yco", - "value": "Yco" - }, - { - "id": "select_target_J", - "value": "J" - }, - { - "id": "select_target_I-J", - "value": "I-J" - }, - { - "id": "select_target_Imp", - "value": "Imp" - }, - { - "id": "select_target_Tau0", - "value": "Tau0" - } - ] + "source": "remous_target" } ] }, diff --git a/src/app/formulaire/definition/concrete/form-courbe-remous.ts b/src/app/formulaire/definition/concrete/form-courbe-remous.ts index 319f155d2..dad046d4c 100644 --- a/src/app/formulaire/definition/concrete/form-courbe-remous.ts +++ b/src/app/formulaire/definition/concrete/form-courbe-remous.ts @@ -25,7 +25,7 @@ export class FormulaireCourbeRemous extends FormulaireBase { this._formCompute = new FormComputeCourbeRemous(this, this._formSection, (this._formResult as FormResultRemous)); // default properties this._props["methodeResolution"] = MethodeResolution.Trapezes; - this._props["varCalc"] = undefined; // important + this._props["varCalc"] = ""; // important } protected parseOptions(json: {}) { diff --git a/src/app/formulaire/select-field.ts b/src/app/formulaire/select-field.ts index 22fe8775c..6f98a6419 100644 --- a/src/app/formulaire/select-field.ts +++ b/src/app/formulaire/select-field.ts @@ -1,4 +1,4 @@ -import { LechaptCalmon, acSection } from "jalhyd"; +import { LechaptCalmon, acSection, CourbeRemous } from "jalhyd"; import { Field } from "./field"; import { SelectEntry } from "./select-entry"; @@ -128,7 +128,21 @@ export class SelectField extends Field { case "acsection_available_sections": for (const sec of acSection.availableSectionTypes) { const e: SelectEntry = new SelectEntry("select_section_" + sec.id, sec.value); - console.log(">> adding entry", e); + this.addEntry(e); + } + break; + + case "remous_methode_resolution": + for (const mr of CourbeRemous.availableMethodeResolution) { + const e: SelectEntry = new SelectEntry("select_resolution_" + mr.id, mr.value); + this.addEntry(e); + } + break; + + case "remous_target": + this.addEntry(new SelectEntry("select_target_none", "")); + for (const at of CourbeRemous.availableTargets) { + const e: SelectEntry = new SelectEntry("select_target_" + at, at); this.addEntry(e); } break; -- GitLab From 994f31764e5cab7f39fa92e39ddb87cc14e3e7f1 Mon Sep 17 00:00:00 2001 From: "mathias.chouet" <mathias.chouet@irstea.fr> Date: Thu, 25 Jul 2019 15:32:31 +0200 Subject: [PATCH 05/13] Removed ParallelStructures dependencies from config, use hardcoded presets from model instead completely removed dependencies system --- .../calculators/cloisons/cloisons.config.json | 147 +-------- src/app/calculators/cloisons/cloisons.en.json | 24 +- src/app/calculators/cloisons/cloisons.fr.json | 24 +- src/app/calculators/dever/dever.config.json | 130 +------- src/app/calculators/dever/dever.en.json | 15 +- src/app/calculators/dever/dever.fr.json | 15 +- .../lechapt-calmon/lechapt-calmon.config.json | 2 +- .../parallel-structures.config.json | 286 +----------------- .../parallel-structures.en.json | 48 +-- .../parallel-structures.fr.json | 51 ++-- .../regime-uniforme.config.json | 2 +- src/app/calculators/remous/remous.config.json | 2 +- .../section-param/section-param.config.json | 2 +- .../formulaire/definition/form-definition.ts | 38 --- .../dependency/dependency-condition.ts | 16 - src/app/formulaire/dependency/dependency.ts | 51 ---- .../existence-dependency-condition.ts | 8 - .../dependency/existence-dependency.ts | 17 -- .../dependency/value-dependency-condition.ts | 16 - .../formulaire/dependency/value-dependency.ts | 18 -- src/app/formulaire/fieldset.ts | 32 +- src/app/formulaire/formulaire-element.ts | 101 ------- src/app/formulaire/formulaire-node.ts | 7 - src/app/formulaire/ngparam.ts | 22 -- src/app/formulaire/pab-table.ts | 2 - src/app/formulaire/select-field.ts | 76 ++--- .../services/formulaire/formulaire.service.ts | 1 - 27 files changed, 167 insertions(+), 986 deletions(-) delete mode 100644 src/app/formulaire/dependency/dependency-condition.ts delete mode 100644 src/app/formulaire/dependency/dependency.ts delete mode 100644 src/app/formulaire/dependency/existence-dependency-condition.ts delete mode 100644 src/app/formulaire/dependency/existence-dependency.ts delete mode 100644 src/app/formulaire/dependency/value-dependency-condition.ts delete mode 100644 src/app/formulaire/dependency/value-dependency.ts diff --git a/src/app/calculators/cloisons/cloisons.config.json b/src/app/calculators/cloisons/cloisons.config.json index ea679624b..52e618a77 100644 --- a/src/app/calculators/cloisons/cloisons.config.json +++ b/src/app/calculators/cloisons/cloisons.config.json @@ -54,125 +54,24 @@ { "id": "select_ouvrage", "type": "select", - "select": [ - { - "id": "select_ouvrage_seuil_rect", - "enum": "StructureType.SeuilRectangulaire" - }, - { - "id": "select_ouvrage_orifice", - "enum": "StructureType.Orifice" - }, - { - "id": "select_ouvrage_seuil_triang", - "enum": "StructureType.SeuilTriangulaire" - }, - { - "id": "select_ouvrage_seuil_triangtrunc", - "enum": "StructureType.SeuilTriangulaireTrunc" - } - - ] + "source": "device_structure_type" }, { - "id": "select_loidebit1", + "id": "select_loidebit", "type": "select", - "select": [ - { - "id": "select_loidebit1_fente", - "enum": "LoiDebit.WeirSubmergedLarinier" - }, - { - "id": "select_loidebit1_villemonte", - "enum": "LoiDebit.WeirVillemonte" - } - ], - "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" - } - ] - }, - { - "id": "select_loidebit3", - "type": "select", - "select": [ - { - "id": "select_loidebit3_seuiltriang", - "enum": "LoiDebit.TriangularWeirFree" - } - ], - "dep_exist": [ - { - "refid": "select_ouvrage", - "refvalue": "select_ouvrage_seuil_triang" - } - ] - }, - { - "id": "select_loidebit4", - "type": "select", - "select": [ - { - "id": "select_loidebit4_seuiltriangtrunc", - "enum": "LoiDebit.TriangularTruncWeirFree" - } - ], - "dep_exist": [ - { - "refid": "select_ouvrage", - "refvalue": "select_ouvrage_seuil_triangtrunc" - } - ] + "source": "device_loi_debit" }, { "type": "input", "id": "h1", "unit": "m", - "nodeType": "StructureRectangle", - "dep_exist": [ - { - "refid": "select_ouvrage", - "refvalue": "select_ouvrage_seuil_rect" - }, - { - "refid": "select_ouvrage", - "refvalue": "select_ouvrage_seuil_triang" - }, - { - "refid": "select_ouvrage", - "refvalue": "select_ouvrage_seuil_triangtrunc" - } - ] + "nodeType": "StructureRectangle" }, { "type": "input", "id": "L", "unit": "m", - "nodeType": "StructureRectangle", - "dep_exist": [ - { - "refid": "select_ouvrage", - "refvalue": "select_ouvrage_seuil_rect" - } - ] + "nodeType": "StructureRectangle" }, { "type": "input", @@ -184,53 +83,25 @@ "type": "input", "id": "S", "unit": "", - "nodeType": "StructureRectangle", - "dep_exist": [ - { - "refid": "select_loidebit2", - "refvalue": "select_loidebit2_orifice" - } - ] + "nodeType": "StructureRectangle" }, { "type": "input", "id": "alpha2", "unit": "", - "nodeType": "StructureRectangle", - "dep_exist": [ - { - "refid": "select_ouvrage", - "refvalue": "select_ouvrage_seuil_triang" - }, - { - "refid": "select_ouvrage", - "refvalue": "select_ouvrage_seuil_triangtrunc" - } - ] + "nodeType": "StructureRectangle" }, { "type": "input", "id": "BT", "unit": "", - "nodeType": "StructureRectangle", - "dep_exist": [ - { - "refid": "select_ouvrage", - "refvalue": "select_ouvrage_seuil_triangtrunc" - } - ] + "nodeType": "StructureRectangle" }, { "type": "input", "id": "ZT", "unit": "", - "nodeType": "StructureRectangle", - "dep_exist": [ - { - "refid": "select_ouvrage", - "refvalue": "select_ouvrage_seuil_triangtrunc" - } - ] + "nodeType": "StructureRectangle" } ] }, diff --git a/src/app/calculators/cloisons/cloisons.en.json b/src/app/calculators/cloisons/cloisons.en.json index 1eaf2a56d..983d797a5 100644 --- a/src/app/calculators/cloisons/cloisons.en.json +++ b/src/app/calculators/cloisons/cloisons.en.json @@ -3,15 +3,21 @@ "ZR": "Upstream bed elevation", "PB": "Pool mean depth", "h1": "Head", - "select_ouvrage_seuil_triang": "Triangular weir", - "select_ouvrage_seuil_triangtrunc": "Truncated triangular weir", - "select_ouvrage_orifice": "Orifice", - "select_ouvrage_seuil_rect": "Rectangular weir", - "select_loidebit1_villemonte": "Villemonte 1947", - "select_loidebit1_fente": "Submerged slot (Larinier 1992)", - "select_loidebit2_orifice": "Submerged orifice", - "select_loidebit3_seuiltriang": "Free flow triangular weir", - "select_loidebit4_seuiltriangtrunc": "Free flow truncated triangular weir", + + "select_structure_SeuilTriangulaire": "Triangular weir", + "select_structure_SeuilTriangulaireTrunc": "Truncated triangular weir", + "select_structure_Orifice": "Orifice", + "select_structure_SeuilRectangulaire": "Rectangular weir", + + "select_loidebit_Orifice_OrificeSubmerged": "Submerged orifice", + + "select_loidebit_SeuilRectangulaire_WeirSubmergedLarinier": "Submerged slot (Larinier 1992)", + "select_loidebit_SeuilRectangulaire_WeirVillemonte": "Villemonte 1947", + + "select_loidebit_SeuilTriangulaire_TriangularWeirFree": "Free flow triangular weir", + + "select_loidebit_SeuilTriangulaireTrunc_TriangularTruncWeirFree": "Free flow truncated triangular weir", + "UNIT_PV": "W/m³", "UNIT_Q": "m³/s", "UNIT_YMOY": "m", diff --git a/src/app/calculators/cloisons/cloisons.fr.json b/src/app/calculators/cloisons/cloisons.fr.json index 4c2cbd9f7..f98900e22 100644 --- a/src/app/calculators/cloisons/cloisons.fr.json +++ b/src/app/calculators/cloisons/cloisons.fr.json @@ -1,14 +1,20 @@ { "Q": "Débit total", - "select_ouvrage_seuil_triang": "Seuil triangulaire", - "select_ouvrage_seuil_triangtrunc": "Seuil triangulaire tronqué", - "select_ouvrage_orifice": "Orifice", - "select_ouvrage_seuil_rect": "Seuil rectangulaire", - "select_loidebit1_villemonte": "Villemonte 1947", - "select_loidebit1_fente": "Fente noyée (Larinier 1992)", - "select_loidebit2_orifice": "Orifice noyé", - "select_loidebit3_seuiltriang": "Déversoir triangulaire dénoyé", - "select_loidebit4_seuiltriangtrunc": "Déversoir triangulaire tronqué dénoyé", + + "select_structure_SeuilTriangulaire": "Seuil triangulaire", + "select_structure_SeuilTriangulaireTrunc": "Seuil triangulaire tronqué", + "select_structure_Orifice": "Orifice", + "select_structure_SeuilRectangulaire": "Seuil rectangulaire", + + "select_loidebit_Orifice_OrificeSubmerged": "Orifice noyé", + + "select_loidebit_SeuilRectangulaire_WeirSubmergedLarinier": "Fente noyée (Larinier 1992)", + "select_loidebit_SeuilRectangulaire_WeirVillemonte": "Villemonte 1947", + + "select_loidebit_SeuilTriangulaire_TriangularWeirFree": "Déversoir triangulaire dénoyé", + + "select_loidebit_SeuilTriangulaireTrunc_TriangularTruncWeirFree": "Déversoir triangulaire tronqué dénoyé", + "UNIT_PV": "W/m³", "UNIT_Q": "m³/s", "UNIT_YMOY": "m", diff --git a/src/app/calculators/dever/dever.config.json b/src/app/calculators/dever/dever.config.json index 4bb14ec5e..c3378c6b0 100644 --- a/src/app/calculators/dever/dever.config.json +++ b/src/app/calculators/dever/dever.config.json @@ -42,160 +42,48 @@ { "id": "select_ouvrage", "type": "select", - "select": [ - { - "id": "select_ouvrage_seuil_rect", - "enum": "StructureType.SeuilRectangulaire" - }, - { - "id": "select_ouvrage_seuil_triang", - "enum": "StructureType.SeuilTriangulaire" - }, - { - "id": "select_ouvrage_seuil_triangtrunc", - "enum": "StructureType.SeuilTriangulaireTrunc" - } - ] + "source": "device_structure_type" }, { - "id": "select_loidebit1", + "id": "select_loidebit", "type": "select", - "select": [ - { - "id": "select_loidebit1_seuildenoye", - "enum": "LoiDebit.WeirFree" - } - ], - "dep_exist": [ - { - "refid": "select_ouvrage", - "refvalue": "select_ouvrage_seuil_rect" - } - ] - }, - { - "id": "select_loidebit3", - "type": "select", - "select": [ - { - "id": "select_loidebit3_seuiltriang", - "enum": "LoiDebit.TriangularWeirFree" - } - ], - "dep_exist": [ - { - "refid": "select_ouvrage", - "refvalue": "select_ouvrage_seuil_triang" - } - ] - }, - { - "id": "select_loidebit4", - "type": "select", - "select": [ - { - "id": "select_loidebit4_seuiltriangtrunc", - "enum": "LoiDebit.TriangularTruncWeirFree" - } - ], - "dep_exist": [ - { - "refid": "select_ouvrage", - "refvalue": "select_ouvrage_seuil_triangtrunc" - } - ] + "source": "device_loi_debit" }, { "type": "input", "id": "ZDV", "unit": "m", - "nodeType": "StructureRectangle", - "dep_exist": [ - { - "refid": "select_ouvrage", - "refvalue": "select_ouvrage_seuil_rect" - }, - { - "refid": "select_ouvrage", - "refvalue": "select_ouvrage_seuil_triang" - }, - { - "refid": "select_ouvrage", - "refvalue": "select_ouvrage_seuil_triangtrunc" - } - ] + "nodeType": "StructureRectangle" }, { "type": "input", "id": "L", "unit": "m", - "nodeType": "StructureRectangle", - "dep_exist": [ - { - "refid": "select_ouvrage", - "refvalue": "select_ouvrage_seuil_rect" - } - ] + "nodeType": "StructureRectangle" }, { "type": "input", "id": "Cd", "unit": "", - "nodeType": "StructureRectangle", - "dep_exist": [ - { - "refid": "select_loidebit1", - "refvalue": "select_loidebit1_seuildenoye" - }, - { - "refid": "select_loidebit3", - "refvalue": "select_loidebit3_seuiltriang" - }, - { - "refid": "select_loidebit3", - "refvalue": "select_loidebit4_seuiltriangtrunc" - } - ] + "nodeType": "StructureRectangle" }, { "type": "input", "id": "alpha2", "unit": "°", - "nodeType": "StructureRectangle", - "dep_exist": [ - { - "refid": "select_ouvrage", - "refvalue": "select_ouvrage_seuil_triang" - }, - { - "refid": "select_ouvrage", - "refvalue": "select_ouvrage_seuil_triangtrunc" - } - ] + "nodeType": "StructureRectangle" }, { "type": "input", "id": "BT", "unit": "m", - "nodeType": "StructureRectangle", - "dep_exist": [ - { - "refid": "select_ouvrage", - "refvalue": "select_ouvrage_seuil_triangtrunc" - } - ] + "nodeType": "StructureRectangle" }, { "type": "input", "id": "ZT", "unit": "m", - "nodeType": "StructureRectangle", - "dep_exist": [ - { - "refid": "select_ouvrage", - "refvalue": "select_ouvrage_seuil_triangtrunc" - } - ] + "nodeType": "StructureRectangle" } ] }, diff --git a/src/app/calculators/dever/dever.en.json b/src/app/calculators/dever/dever.en.json index a488c9945..9d4f6f0d5 100644 --- a/src/app/calculators/dever/dever.en.json +++ b/src/app/calculators/dever/dever.en.json @@ -2,14 +2,17 @@ "Q": "Total Flow", "ZR": "Upstream bed elevation", "BR": "Upstream bed width", - "select_ouvrage_seuil_rect": "Rectangular weir", - "select_ouvrage_seuil_triang": "Triangular weir", - "select_ouvrage_seuil_triangtrunc": "Truncated triangular weir", - "select_loidebit1_seuildenoye": "Free flow rectangular weir", - "select_loidebit3_seuiltriang": "Free flow triangular weir", - "select_loidebit4_seuiltriangtrunc": "Free flow truncated triangular weir", "L": "Width of the weir", "Cd": "Discharge coefficient", + + "select_structure_SeuilRectangulaire": "Rectangular weir", + "select_structure_SeuilTriangulaire": "Triangular weir", + "select_structure_SeuilTriangulaireTrunc": "Truncated triangular weir", + + "select_loidebit_SeuilRectangulaire_WeirFree": "Free flow rectangular weir", + "select_loidebit_SeuilTriangulaire_TriangularWeirFree": "Free flow triangular weir", + "select_loidebit_SeuilTriangulaireTrunc_TriangularTruncWeirFree": "Free flow truncated triangular weir", + "UNIT_CVQT": "m³/s", "UNIT_Q": "m³/s", "UNIT_EC": "m", diff --git a/src/app/calculators/dever/dever.fr.json b/src/app/calculators/dever/dever.fr.json index ec276acc3..d4e462ff3 100644 --- a/src/app/calculators/dever/dever.fr.json +++ b/src/app/calculators/dever/dever.fr.json @@ -2,14 +2,17 @@ "Q": "Débit total", "ZR": "Cote du lit amont", "BR": "Largeur du lit amont", - "select_ouvrage_seuil_rect": "Déversoir rectangulaire", - "select_ouvrage_seuil_triang": "Déversoir triangulaire", - "select_ouvrage_seuil_triangtrunc": "Déversoir triangulaire tronqué", - "select_loidebit1_seuildenoye": "Déversoir rectangulaire dénoyé", - "select_loidebit3_seuiltriang": "Déversoir triangulaire dénoyé", - "select_loidebit4_seuiltriangtrunc": "Déversoir triangulaire tronqué dénoyé", "L": "Largeur du déversoir", "Cd": "Coefficient de débit", + + "select_structure_SeuilRectangulaire": "Déversoir rectangulaire", + "select_structure_SeuilTriangulaire": "Déversoir triangulaire", + "select_structure_SeuilTriangulaireTrunc": "Déversoir triangulaire tronqué", + + "select_loidebit_SeuilRectangulaire_WeirFree": "Déversoir rectangulaire dénoyé", + "select_loidebit_SeuilTriangulaire_TriangularWeirFree": "Déversoir triangulaire dénoyé", + "select_loidebit_SeuilTriangulaireTrunc_TriangularTruncWeirFree": "Déversoir triangulaire tronqué dénoyé", + "UNIT_CVQT": "m³/s", "UNIT_Q": "m³/s", "UNIT_EC": "m", diff --git a/src/app/calculators/lechapt-calmon/lechapt-calmon.config.json b/src/app/calculators/lechapt-calmon/lechapt-calmon.config.json index 283d67aa2..d2f57ba0c 100644 --- a/src/app/calculators/lechapt-calmon/lechapt-calmon.config.json +++ b/src/app/calculators/lechapt-calmon/lechapt-calmon.config.json @@ -7,7 +7,7 @@ { "id": "select_material", "type": "select", - "source": "lechapt_calmon_materials" + "source": "lechapt_calmon_material" }, { "type": "input", diff --git a/src/app/calculators/parallel-structures/parallel-structures.config.json b/src/app/calculators/parallel-structures/parallel-structures.config.json index 07272c3a1..4a0b8a580 100644 --- a/src/app/calculators/parallel-structures/parallel-structures.config.json +++ b/src/app/calculators/parallel-structures/parallel-structures.config.json @@ -35,344 +35,90 @@ { "id": "select_ouvrage", "type": "select", - "select": [ - { - "id": "select_ouvrage_vanne_rect", - "enum": "StructureType.VanneRectangulaire" - }, - { - "id": "select_ouvrage_seuil_rect", - "enum": "StructureType.SeuilRectangulaire" - }, - { - "id": "select_ouvrage_seuil_triang", - "enum": "StructureType.SeuilTriangulaire" - }, - { - "id": "select_ouvrage_seuil_triangtrunc", - "enum": "StructureType.SeuilTriangulaireTrunc" - } - ] + "source": "device_structure_type" }, { - "id": "select_loidebit1", + "id": "select_loidebit", "type": "select", - "select": [ - { - "id": "select_loidebit1_cem88d", - "enum": "LoiDebit.WeirCem88d" - }, - { - "id": "select_loidebit1_cem88v", - "enum": "LoiDebit.WeirCem88v" - }, - { - "id": "select_loidebit1_seuildenoye", - "enum": "LoiDebit.WeirFree" - }, - { - "id": "select_loidebit1_cunge80", - "enum": "LoiDebit.WeirCunge80" - }, - { - "id": "select_loidebit1_villemonte", - "enum": "LoiDebit.WeirVillemonte" - }, - { - "id": "select_loidebit1_kivi", - "enum": "LoiDebit.KIVI" - }, - { - "id": "select_loidebit1_fente", - "enum": "LoiDebit.WeirSubmergedLarinier" - } - ], - "dep_exist": [ - { - "refid": "select_ouvrage", - "refvalue": "select_ouvrage_seuil_rect" - } - ] - }, - { - "id": "select_loidebit2", - "type": "select", - "select": [ - { - "id": "select_loidebit2_cem88v", - "enum": "LoiDebit.GateCem88v" - }, - { - "id": "select_loidebit2_cem88d", - "enum": "LoiDebit.GateCem88d" - }, - { - "id": "select_loidebit2_vannedenoye", - "enum": "LoiDebit.RectangularOrificeFree" - }, - { - "id": "select_loidebit2_vannenoye", - "enum": "LoiDebit.RectangularOrificeSubmerged" - }, - { - "id": "select_loidebit2_cunge80", - "enum": "LoiDebit.GateCunge80" - } - ], - "dep_exist": [ - { - "refid": "select_ouvrage", - "refvalue": "select_ouvrage_vanne_rect" - } - ] - }, - { - "id": "select_loidebit3", - "type": "select", - "select": [ - { - "id": "select_loidebit3_seuiltriang", - "enum": "LoiDebit.TriangularWeirFree" - } - ], - "dep_exist": [ - { - "refid": "select_ouvrage", - "refvalue": "select_ouvrage_seuil_triang" - } - ] - }, - { - "id": "select_loidebit4", - "type": "select", - "select": [ - { - "id": "select_loidebit4_seuiltriangtrunc", - "enum": "LoiDebit.TriangularTruncWeirFree" - } - ], - "dep_exist": [ - { - "refid": "select_ouvrage", - "refvalue": "select_ouvrage_seuil_triangtrunc" - } - ] + "source": "device_loi_debit" }, { "type": "input", "id": "ZDV", "unit": "m", - "nodeType": "StructureRectangle", - "dep_exist": [ - { - "refid": "select_ouvrage", - "refvalue": "select_ouvrage_vanne_rect" - }, - { - "refid": "select_ouvrage", - "refvalue": "select_ouvrage_seuil_rect" - }, - { - "refid": "select_ouvrage", - "refvalue": "select_ouvrage_seuil_triang" - }, - { - "refid": "select_ouvrage", - "refvalue": "select_ouvrage_seuil_triangtrunc" - } - ] + "nodeType": "StructureRectangle" }, { "type": "input", "id": "L", "unit": "m", - "nodeType": "StructureRectangle", - "dep_exist": [ - { - "refid": "select_ouvrage", - "refvalue": "select_ouvrage_vanne_rect" - }, - { - "refid": "select_ouvrage", - "refvalue": "select_ouvrage_seuil_rect" - }, - { - "refid": "select_loidebit1", - "refvalue": "select_loidebit1_kivi" - } - ] + "nodeType": "StructureRectangle" }, { "type": "input", "id": "W", "nodeType": "StructureRectangle", - "unit": "m", - "dep_exist": [ - { - "refid": "select_ouvrage", - "refvalue": "select_ouvrage_vanne_rect" - } - ] + "unit": "m" }, { "type": "input", "id": "CdWSL", "unit": "", - "nodeType": "StructureRectangle", - "dep_exist": [ - { - "refid": "select_loidebit1", - "refvalue": "select_loidebit1_fente" - } - ] + "nodeType": "StructureRectangle" }, { "type": "input", "id": "CdWR", "unit": "", - "nodeType": "StructureRectangle", - "dep_exist": [ - { - "refid": "select_loidebit1", - "refvalue": "select_loidebit1_seuildenoye" - }, - { - "refid": "select_loidebit1", - "refvalue": "select_loidebit1_cem88d" - }, - { - "refid": "select_loidebit2", - "refvalue": "select_loidebit2_cem88d" - }, - { - "refid": "select_loidebit1", - "refvalue": "select_loidebit1_villemonte" - } - ] + "nodeType": "StructureRectangle" }, { "type": "input", "id": "CdGR", "unit": "", - "nodeType": "StructureRectangle", - "dep_exist": [ - { - "refid": "select_loidebit1", - "refvalue": "select_loidebit1_cunge80" - }, - { - "refid": "select_loidebit1", - "refvalue": "select_loidebit1_cem88v" - }, - { - "refid": "select_loidebit2", - "refvalue": "select_loidebit2_vannedenoye" - }, - { - "refid": "select_loidebit2", - "refvalue": "select_loidebit2_vannenoye" - }, - { - "refid": "select_loidebit2", - "refvalue": "select_loidebit2_cunge80" - }, - { - "refid": "select_loidebit2", - "refvalue": "select_loidebit2_cem88v" - } - ] + "nodeType": "StructureRectangle" }, { "type": "input", "id": "CdT", "unit": "", - "nodeType": "StructureRectangle", - "dep_exist": [ - { - "refid": "select_ouvrage", - "refvalue": "select_ouvrage_seuil_triang" - }, - { - "refid": "select_ouvrage", - "refvalue": "select_ouvrage_seuil_triangtrunc" - } - ] + "nodeType": "StructureRectangle" }, { "type": "input", "id": "alpha", "unit": "", - "nodeType": "StructureRectangle", - "dep_exist": [ - { - "refid": "select_loidebit1", - "refvalue": "select_loidebit1_kivi" - } - ] + "nodeType": "StructureRectangle" }, { "type": "input", "id": "beta", "unit": "", - "nodeType": "StructureRectangle", - "dep_exist": [ - { - "refid": "select_loidebit1", - "refvalue": "select_loidebit1_kivi" - } - ] + "nodeType": "StructureRectangle" }, { "type": "input", "id": "ZRAM", "unit": "m", - "nodeType": "StructureRectangle", - "dep_exist": [ - { - "refid": "select_loidebit1", - "refvalue": "select_loidebit1_kivi" - } - ] + "nodeType": "StructureRectangle" }, { "type": "input", "id": "alpha2", "unit": "°", - "nodeType": "StructureRectangle", - "dep_exist": [ - { - "refid": "select_ouvrage", - "refvalue": "select_ouvrage_seuil_triang" - }, - { - "refid": "select_ouvrage", - "refvalue": "select_ouvrage_seuil_triangtrunc" - } - ] + "nodeType": "StructureRectangle" }, { "type": "input", "id": "BT", "unit": "m", - "nodeType": "StructureRectangle", - "dep_exist": [ - { - "refid": "select_ouvrage", - "refvalue": "select_ouvrage_seuil_triangtrunc" - } - ] + "nodeType": "StructureRectangle" }, { "type": "input", "id": "ZT", "unit": "m", - "nodeType": "StructureRectangle", - "dep_exist": [ - { - "refid": "select_ouvrage", - "refvalue": "select_ouvrage_seuil_triangtrunc" - } - ] + "nodeType": "StructureRectangle" } ] }, diff --git a/src/app/calculators/parallel-structures/parallel-structures.en.json b/src/app/calculators/parallel-structures/parallel-structures.en.json index 84154f2fe..df9a1d99a 100644 --- a/src/app/calculators/parallel-structures/parallel-structures.en.json +++ b/src/app/calculators/parallel-structures/parallel-structures.en.json @@ -1,26 +1,32 @@ { "Q": "Total Flow", - "select_ouvrage_vanne_circ": "Circular gate", - "select_ouvrage_vanne_rect": "Rectangular gate", - "select_ouvrage_seuil_rect": "Rectangular weir", - "select_ouvrage_seuil_triang": "Triangular weir", - "select_ouvrage_seuil_triangtrunc": "Truncated triangular weir", - "select_ouvrage_seuil_trap": "Trapezoidal weir", - "select_ouvrage_vanne_trap": "trapezoidal gate", "W": "Gate opening", - "select_loidebit1_seuildenoye": "Free flow weir", - "select_loidebit1_cunge80": "Cunge 80", - "select_loidebit1_cem88d": "Weir/Orifice Cemagref 88", - "select_loidebit1_cem88v": "Weir/Undershot gate Cemagref 88", - "select_loidebit1_fente": "Submerged slot (Larinier 1992)", - "select_loidebit1_kivi": "Kindsvater-Carter and Villemonte", - "select_loidebit1_villemonte": "Villemonte 1957", - "select_loidebit2_vannedenoye": "Free flow gate", - "select_loidebit2_vannenoye": "Submerged gate", - "select_loidebit2_cunge80": "Cunge 80", - "select_loidebit2_cem88d": "Weir/Orifice Cemagref 88", - "select_loidebit2_cem88v": "Weir/Undershot gate Cemagref 88", - "select_loidebit3_seuiltriang": "Triangular weir (Villemonte)", - "select_loidebit4_seuiltriangtrunc": "Truncated triangular weir (Villemonte)", + + "select_structure_Orifice": "Orifice", + "select_structure_VanneRectangulaire": "Rectangular gate", + "select_structure_SeuilRectangulaire": "Rectangular weir", + "select_structure_SeuilTriangulaire": "Triangular weir", + "select_structure_SeuilTriangulaireTrunc": "Truncated triangular weir", + + "select_loidebit_Orifice_OrificeSubmerged": "Submerged orifice", + + "select_loidebit_VanneRectangulaire_GateCem88d": "Weir/Orifice Cemagref 88", + "select_loidebit_VanneRectangulaire_GateCem88v": "Weir/Undershot gate Cemagref 88", + "select_loidebit_VanneRectangulaire_GateCunge80": "Cunge 80", + "select_loidebit_VanneRectangulaire_RectangularOrificeFree": "Free flow gate", + "select_loidebit_VanneRectangulaire_RectangularOrificeSubmerged": "Submerged gate", + + "select_loidebit_SeuilTriangulaire_TriangularWeirFree": "Triangular weir (Villemonte)", + + "select_loidebit_SeuilTriangulaireTrunc_TriangularTruncWeirFree": "Truncated triangular weir (Villemonte)", + + "select_loidebit_SeuilRectangulaire_WeirCem88d": "Weir/Orifice Cemagref 88", + "select_loidebit_SeuilRectangulaire_WeirCem88v": "Weir/Undershot gate Cemagref 88", + "select_loidebit_SeuilRectangulaire_WeirSubmergedLarinier": "Submerged slot (Larinier 1992)", + "select_loidebit_SeuilRectangulaire_WeirVillemonte": "Villemonte 1957", + "select_loidebit_SeuilRectangulaire_WeirFree": "Free flow weir", + "select_loidebit_SeuilRectangulaire_KIVI": "Kindsvater-Carter and Villemonte", + "select_loidebit_SeuilRectangulaire_WeirCunge80": "Cunge 80", + "UNIT_Q": "m³/s" } diff --git a/src/app/calculators/parallel-structures/parallel-structures.fr.json b/src/app/calculators/parallel-structures/parallel-structures.fr.json index 7b765db33..992f033e1 100644 --- a/src/app/calculators/parallel-structures/parallel-structures.fr.json +++ b/src/app/calculators/parallel-structures/parallel-structures.fr.json @@ -1,25 +1,32 @@ { "Q": "Débit total", - "select_ouvrage_vanne_circ": "Vanne circulaire", - "select_ouvrage_vanne_rect": "Vanne rectangulaire", - "select_ouvrage_seuil_rect": "Seuil rectangulaire", - "select_ouvrage_seuil_triang": "Seuil triangulaire", - "select_ouvrage_seuil_triangtrunc": "Seuil triangulaire tronqué", - "select_ouvrage_seuil_trap": "Seuil trapézoïdal", - "select_ouvrage_vanne_trap": "Vanne trapézoïdale", - "select_loidebit1_seuildenoye": "Seuil dénoyé", - "select_loidebit1_cunge80": "Cunge 80", - "select_loidebit1_cem88d": "Déversoir/Orifice Cemagref 88", - "select_loidebit1_cem88v": "Déversoir/Vanne de fond Cemagref 88", - "select_loidebit1_fente": "Fente noyée (Larinier 1992)", - "select_loidebit1_kivi": "Kindsvater-Carter et Villemonte", - "select_loidebit1_villemonte": "Villemonte 1957", - "select_loidebit2_vannedenoye": "Vanne dénoyé", - "select_loidebit2_vannenoye": "Vanne noyé", - "select_loidebit2_cunge80": "Cunge 80", - "select_loidebit2_cem88d": "Déversoir/Orifice Cemagref 88", - "select_loidebit2_cem88v": "Déversoir/Vanne de fond Cemagref 88", - "select_loidebit3_seuiltriang": "Déversoir triangulaire (Villemonte)", - "select_loidebit4_seuiltriangtrunc": "Déversoir triangulaire tronqué (Villemonte)", + "W": "Ouverture de vanne", + + "select_structure_Orifice": "Orifice", + "select_structure_SeuilRectangulaire": "Seuil rectangulaire", + "select_structure_SeuilTriangulaire": "Seuil triangulaire", + "select_structure_SeuilTriangulaireTrunc": "Seuil triangulaire tronqué", + "select_structure_VanneRectangulaire": "Vanne rectangulaire", + + "select_loidebit_Orifice_OrificeSubmerged": "Orifice noyé", + + "select_loidebit_VanneRectangulaire_GateCem88d": "Déversoir/Orifice Cemagref 88", + "select_loidebit_VanneRectangulaire_GateCem88v": "Déversoir/Vanne de fond Cemagref 88", + "select_loidebit_VanneRectangulaire_GateCunge80": "Cunge 80", + "select_loidebit_VanneRectangulaire_RectangularOrificeFree": "Vanne dénoyée", + "select_loidebit_VanneRectangulaire_RectangularOrificeSubmerged": "Vanne noyée", + + "select_loidebit_SeuilTriangulaire_TriangularWeirFree": "Déversoir triangulaire (Villemonte)", + + "select_loidebit_SeuilTriangulaireTrunc_TriangularTruncWeirFree": "Déversoir triangulaire tronqué (Villemonte)", + + "select_loidebit_SeuilRectangulaire_WeirCem88d": "Déversoir/Orifice Cemagref 88", + "select_loidebit_SeuilRectangulaire_WeirCem88v": "Déversoir/Vanne de fond Cemagref 88", + "select_loidebit_SeuilRectangulaire_WeirSubmergedLarinier": "Fente noyée (Larinier 1992)", + "select_loidebit_SeuilRectangulaire_WeirVillemonte": "Villemonte 1957", + "select_loidebit_SeuilRectangulaire_WeirFree": "Seuil dénoyé", + "select_loidebit_SeuilRectangulaire_KIVI": "Kindsvater-Carter et Villemonte", + "select_loidebit_SeuilRectangulaire_WeirCunge80": "Cunge 80", + "UNIT_Q": "m³/s" -} \ No newline at end of file +} diff --git a/src/app/calculators/regime-uniforme/regime-uniforme.config.json b/src/app/calculators/regime-uniforme/regime-uniforme.config.json index a5623b000..ac65a0ea1 100644 --- a/src/app/calculators/regime-uniforme/regime-uniforme.config.json +++ b/src/app/calculators/regime-uniforme/regime-uniforme.config.json @@ -7,7 +7,7 @@ { "id": "select_section", "type": "select", - "source": "acsection_available_sections" + "source": "acsection_section" }, { "type": "input", diff --git a/src/app/calculators/remous/remous.config.json b/src/app/calculators/remous/remous.config.json index f7ea148e2..172802242 100644 --- a/src/app/calculators/remous/remous.config.json +++ b/src/app/calculators/remous/remous.config.json @@ -7,7 +7,7 @@ { "id": "select_section", "type": "select", - "source": "acsection_available_sections" + "source": "acsection_section" }, { "type": "input", diff --git a/src/app/calculators/section-param/section-param.config.json b/src/app/calculators/section-param/section-param.config.json index 0d8a63323..acb801414 100644 --- a/src/app/calculators/section-param/section-param.config.json +++ b/src/app/calculators/section-param/section-param.config.json @@ -7,7 +7,7 @@ { "id": "select_section", "type": "select", - "source": "acsection_available_sections" + "source": "acsection_section" }, { "type": "input", diff --git a/src/app/formulaire/definition/form-definition.ts b/src/app/formulaire/definition/form-definition.ts index f10ec8662..ebeb77d4a 100644 --- a/src/app/formulaire/definition/form-definition.ts +++ b/src/app/formulaire/definition/form-definition.ts @@ -196,35 +196,6 @@ export abstract class FormulaireDefinition extends FormulaireNode implements Obs this.kids.push(tab); } - public parseDependencies(json: {}) { - // tslint:disable-next-line:forin - for (const conf_index in json) { - const conf = json[conf_index]; - const type: string = conf["type"]; - - switch (type) { - // field set - case "fieldset": - case "template_container": - for (const k of this.kids) { - if (k.id === conf["id"]) { - k.parseDependencies(conf); - break; - } - } - break; - - case "fieldset_template": - for (const k of this.kids) { - if (k instanceof FieldsetContainer) { - k.parseDependencies(conf); - } - } - break; - } - } - } - /** * 1ère passe d'analyse de la configuration */ @@ -290,7 +261,6 @@ export abstract class FormulaireDefinition extends FormulaireNode implements Obs } this.completeParse(this._jsonConfig); - this.parseDependencies(this._jsonConfig); } public hasParameter(symbol: string): boolean { @@ -381,8 +351,6 @@ export abstract class FormulaireDefinition extends FormulaireNode implements Obs */ public reset() { this.resetResults([], undefined, true); - this.applyDependencies(); - // prévenir les composants qu'il faut détecter les changements this.notifyReset(); } @@ -407,12 +375,6 @@ export abstract class FormulaireDefinition extends FormulaireNode implements Obs return select.getValue().label; } - public applyDependencies() { - for (const fe of this.topFormElements) { - fe.applyDependencies(); - } - } - public abstract resetResults(visited: string[], symbol?: string, forceResetAllDependencies?: boolean); public abstract doCompute(); public abstract get hasResults(): boolean; diff --git a/src/app/formulaire/dependency/dependency-condition.ts b/src/app/formulaire/dependency/dependency-condition.ts deleted file mode 100644 index 876e46426..000000000 --- a/src/app/formulaire/dependency/dependency-condition.ts +++ /dev/null @@ -1,16 +0,0 @@ -export enum DependencyConditionType { - HasValue, IsVariable, IsDisplayed -} - -export class DependencyCondition { - constructor(private _type: DependencyConditionType) { - } - - public get type() { - return this._type; - } - - public toString(): string { - return "cond=" + DependencyConditionType[this._type]; - } -} diff --git a/src/app/formulaire/dependency/dependency.ts b/src/app/formulaire/dependency/dependency.ts deleted file mode 100644 index fe7426f55..000000000 --- a/src/app/formulaire/dependency/dependency.ts +++ /dev/null @@ -1,51 +0,0 @@ -import { FormulaireElement } from "../formulaire-element"; -import { DependencyCondition } from "./dependency-condition"; - -/** - * Dépendance entre un élément maître et un élément esclave - * Si le maître vérifie une condition (masterCondition), alors la dépendance est appliquée à l'élément esclave, - * cad que son affichage, sa valeur, ... sont modifiés - */ -export abstract class Dependency { - private _slave: FormulaireElement; - - private _masterId: string; - - private _masterCondition: DependencyCondition; - - constructor(s: FormulaireElement, mid: string, mc: DependencyCondition) { - this._slave = s; - this._masterId = mid; - this._masterCondition = mc; - } - - private getMasterElement(id: string): FormulaireElement { - let parentNode = this._slave.parent; - while (parentNode !== undefined) { - const res: FormulaireElement = parentNode.getFormulaireNodeById(id) as FormulaireElement; - if (res !== undefined) { - return res; - } - parentNode = parentNode.parent; - } - } - - protected get masterElement(): FormulaireElement { - return this.getMasterElement(this._masterId); - } - - public get masterCondition(): DependencyCondition { - return this._masterCondition; - } - - public apply() { - const master: FormulaireElement = this.masterElement; - if (master && master.verifiesDependency(this)) { - this._slave.applyDependency(this); - } - } - - public toString(): string { - return "slave=" + this._slave.toString() + "\n mid=" + this._masterId + "\n " + this._masterCondition.toString(); - } -} diff --git a/src/app/formulaire/dependency/existence-dependency-condition.ts b/src/app/formulaire/dependency/existence-dependency-condition.ts deleted file mode 100644 index 0ec4ce094..000000000 --- a/src/app/formulaire/dependency/existence-dependency-condition.ts +++ /dev/null @@ -1,8 +0,0 @@ -import { DependencyCondition, DependencyConditionType } from "./dependency-condition"; - - -export class ExistenceDependencyCondition extends DependencyCondition { - constructor() { - super(DependencyConditionType.IsDisplayed); - } -} diff --git a/src/app/formulaire/dependency/existence-dependency.ts b/src/app/formulaire/dependency/existence-dependency.ts deleted file mode 100644 index 2f1a17f24..000000000 --- a/src/app/formulaire/dependency/existence-dependency.ts +++ /dev/null @@ -1,17 +0,0 @@ -import { Dependency } from "./dependency"; -import { FormulaireElement } from "../formulaire-element"; - -/** - * dépendance déterminant l'affichage de l'élément esclave - */ -export class ExistenceDependency extends Dependency { - /** - * true : l'élément slave est affiché si le master est affiché - * false : l'élément slave est affiché si le master n'est pas affiché - */ - // private _direct: boolean; - - public toString() { - return "existdep\n " + super.toString(); - } -} diff --git a/src/app/formulaire/dependency/value-dependency-condition.ts b/src/app/formulaire/dependency/value-dependency-condition.ts deleted file mode 100644 index b0e309568..000000000 --- a/src/app/formulaire/dependency/value-dependency-condition.ts +++ /dev/null @@ -1,16 +0,0 @@ -import { DependencyCondition, DependencyConditionType } from "./dependency-condition"; - - -export class ValueDependencyCondition extends DependencyCondition { - constructor(private _value: any) { - super(DependencyConditionType.HasValue); - } - - public get value(): any { - return this._value; - } - - public toString(): string { - return super.toString() + " " + this._value; - } -} diff --git a/src/app/formulaire/dependency/value-dependency.ts b/src/app/formulaire/dependency/value-dependency.ts deleted file mode 100644 index b94f9fc9b..000000000 --- a/src/app/formulaire/dependency/value-dependency.ts +++ /dev/null @@ -1,18 +0,0 @@ -import { Dependency } from "./dependency"; -import { FormulaireElement } from "../formulaire-element"; -import { ValueDependencyCondition } from "./value-dependency-condition"; - -/** - * dépendance déterminant la valeur de l'élément esclave - */ -export class ValueDependency extends Dependency { - public slaveValue: any; - - constructor(slave: FormulaireElement, masterId: string, masterValue: any) { - super(slave, masterId, new ValueDependencyCondition(masterValue)); - } - - public toString() { - return "valdep\n " + super.toString() + "\n slave val " + this.slaveValue; - } -} diff --git a/src/app/formulaire/fieldset.ts b/src/app/formulaire/fieldset.ts index 4f08999cc..9f112fb4c 100644 --- a/src/app/formulaire/fieldset.ts +++ b/src/app/formulaire/fieldset.ts @@ -119,6 +119,7 @@ export class FieldSet extends FormulaireElement implements Observer { let res: NgParameter; + // @TODO tabarnak !? const nt: string = json["nodeType"]; const nodeType: ComputeNodeType = nt ? ComputeNodeType[nt] : this.getPropValue("nodeType"); @@ -192,7 +193,6 @@ export class FieldSet extends FormulaireElement implements Observer { public updateFields() { this.clearFields(); this.parseFields(); - this.parseDependencies(this._jsonConfig); this.updateLocalisation(); // MAJ des selects avec les valeurs actuelles des propriétés @@ -227,9 +227,6 @@ export class FieldSet extends FormulaireElement implements Observer { break; } - - // fin MAJ selects - this.applyDependencies(); } /** @@ -239,7 +236,7 @@ export class FieldSet extends FormulaireElement implements Observer { const selectField: SelectField = this.getFormulaireNodeById(selectId) as SelectField; if (selectField) { const propVal: any = this.getPropValue(propertyKey); - const selectElement = selectField.getSelectedEntryFromValue(propVal); // @TODO juste setValue() ? + const selectElement = selectField.getSelectedEntryFromValue(propVal); try { selectField.setValue(selectElement); } catch (e) { @@ -292,31 +289,6 @@ export class FieldSet extends FormulaireElement implements Observer { this.updateFields(); } - public parseDependencies(json: {}) { - super.parseDependencies(json); - - for (const k1 in json) { - if (k1 === "fields") { - const fields = json[k1]; - for (const k2 in fields) { - const field = fields[k2]; - switch (field["type"]) { - case "input": - case "select": - case "check": - for (const k of this.kids) { - if (k.id === field["id"]) { - k.parseDependencies(field); - break; - } - } - break; - } - } - } - } - } - public getNodeParameter(symbol: string): NgParameter { for (const p of this.kids) { if (p instanceof NgParameter) { diff --git a/src/app/formulaire/formulaire-element.ts b/src/app/formulaire/formulaire-element.ts index 1bd652334..dab5ab0cb 100644 --- a/src/app/formulaire/formulaire-element.ts +++ b/src/app/formulaire/formulaire-element.ts @@ -1,9 +1,5 @@ import { FormulaireNode } from "./formulaire-node"; import { StringMap } from "../stringmap"; -import { Dependency } from "./dependency/dependency"; -import { DependencyCondition, DependencyConditionType } from "./dependency/dependency-condition"; -import { ValueDependencyCondition } from "./dependency/value-dependency-condition"; -import { ExistenceDependency } from "./dependency/existence-dependency"; import { DeepFormulaireElementIterator } from "./form-iterator/deep-element-iterator"; import { I18nService } from "../services/internationalisation/internationalisation.service"; import { ServiceFactory } from "../services/service-factory"; @@ -29,8 +25,6 @@ export abstract class FormulaireElement extends FormulaireNode { private intlService: I18nService; - protected _dependencies: Dependency[] = []; - public static removePrefix(s: string, prefix: string): string { if (s.startsWith(prefix)) { const l = prefix.length; @@ -81,101 +75,6 @@ export abstract class FormulaireElement extends FormulaireNode { return res; } - /** - * analyse les dépendances d'existence - * @param json configuration de la dépendance - */ - private parse_existence_dependencies(json: {}) { - for (const di in json) { - if (json.hasOwnProperty(di)) { - const d = json[di]; - const rv = d["refvalue"]; - let mc: DependencyCondition; - if (rv !== undefined) { - mc = new ValueDependencyCondition(rv); - } else { - const cond = d["cond"]; - if (cond !== undefined) { - switch (cond) { - case "isvar": - mc = new DependencyCondition(DependencyConditionType.IsVariable); - break; - - case "isdisp": - mc = new DependencyCondition(DependencyConditionType.IsDisplayed); - break; - - default: - throw new Error( - "Formulaire.parse_existence_dependencies() : type de condition '" + cond + "' non pris en charge" - ); - } - } else { - throw new Error("Formulaire.parse_existence_dependencies() : infos de dépendance manquantes/non prises en charge"); - } - } - const dep = new ExistenceDependency(this, d["refid"], mc); - this._dependencies.push(dep); - } - } - } - - /** - * analyse les dépendances (existence/valeur) - * @param json configuration de la dépendance - * @param parentNode node parent dans lequel rechercher l'élément master (dont l'existence dépend) - */ - public parseDependencies(json: {}) { - const dep = json["dep_exist"]; - if (dep !== undefined) { - this.parse_existence_dependencies(dep); - } - } - - public verifiesDependency(d: Dependency): boolean { - if (d.masterCondition.type === DependencyConditionType.IsDisplayed) { - return this._isDisplayed; - } - } - - /** - * applique une dépendance dont la condition a été vérifiée - */ - public applyDependency(d: Dependency) { - if (d instanceof ExistenceDependency) { - this.isDisplayed = true; - } - } - - private prepareExistenceDependencies() { - // si des FormulaireElement sont présents dans des ExistenceDependency, on met leur membre isDisplayed à false - - for (const d of this._dependencies) { - if (d instanceof ExistenceDependency) { - this.isDisplayed = false; - break; - } - } - } - - public applyDependencies() { - this.prepareExistenceDependencies(); - - for (const d of this._dependencies) { - d.apply(); - } - - for (const k of this.getKids()) { - k.applyDependencies(); - } - } - - public printDependencies() { - for (const d of this._dependencies) { - console.log(d.toString()); - } - } - /** * Updates localisation for this element: first the label then all the element's children * @param loc calculator-specific localised messages map diff --git a/src/app/formulaire/formulaire-node.ts b/src/app/formulaire/formulaire-node.ts index 918c6d8da..b1406fec9 100644 --- a/src/app/formulaire/formulaire-node.ts +++ b/src/app/formulaire/formulaire-node.ts @@ -115,13 +115,6 @@ export abstract class FormulaireNode implements IObservable { public abstract parseConfig(json: {}, data?: {}); - /** - * analyse les dépendances (existence/valeur) - * @param json configuration de la dépendance - * @param parentNode nod parent dans lequel rechercher l'élément master (dont l'existence dépend) - */ - public abstract parseDependencies(json: {}); - // interface IObservable /** diff --git a/src/app/formulaire/ngparam.ts b/src/app/formulaire/ngparam.ts index 5562845dd..07e5051f6 100644 --- a/src/app/formulaire/ngparam.ts +++ b/src/app/formulaire/ngparam.ts @@ -4,9 +4,6 @@ import { Interval, ParamDefinition, ParamDomain, ParamValueMode, INumberIterator import { sprintf } from "sprintf-js"; import { InputField } from "./input-field"; -import { Dependency } from "./dependency/dependency"; -import { DependencyConditionType } from "./dependency/dependency-condition"; -import { ValueDependencyCondition } from "./dependency/value-dependency-condition"; import { ServiceFactory } from "../services/service-factory"; import { FormulaireNode } from "./formulaire-node"; @@ -453,25 +450,6 @@ export class NgParameter extends InputField implements Observer { this.radioConfig = NgParameter.getRadioConfig(radioConfig); } - public verifiesDependency(d: Dependency): boolean { - if (super.verifiesDependency(d)) { - return true; - } - switch (d.masterCondition.type) { - case DependencyConditionType.HasValue: { - const mc: ValueDependencyCondition = <ValueDependencyCondition>d.masterCondition; - return this.getValue() === mc.value; - } - - case DependencyConditionType.IsVariable: - return this.radioState === ParamRadioConfig.VAR; - - default: - throw new Error("NgParameter.verifiesDependency() : type de condition '" - + DependencyConditionType[d.masterCondition.type] + "' non pris en charge"); - } - } - // interface Observer public update(sender: any, data: any) { diff --git a/src/app/formulaire/pab-table.ts b/src/app/formulaire/pab-table.ts index 9464eeef8..a31529bc5 100644 --- a/src/app/formulaire/pab-table.ts +++ b/src/app/formulaire/pab-table.ts @@ -16,8 +16,6 @@ export class PabTable extends FormulaireElement { super(parent); } - public parseDependencies(json: {}) { } // implements abstract method of FormulaireNode - public parseConfig(json: {}) { this._confId = json["id"]; } diff --git a/src/app/formulaire/select-field.ts b/src/app/formulaire/select-field.ts index 6f98a6419..07f944d09 100644 --- a/src/app/formulaire/select-field.ts +++ b/src/app/formulaire/select-field.ts @@ -1,12 +1,10 @@ -import { LechaptCalmon, acSection, CourbeRemous } from "jalhyd"; +import { LechaptCalmon, acSection, CourbeRemous, Nub, ParallelStructure, StructureType, LoiDebit } from "jalhyd"; import { Field } from "./field"; import { SelectEntry } from "./select-entry"; -import { Dependency } from "./dependency/dependency"; -import { DependencyConditionType } from "./dependency/dependency-condition"; -import { ValueDependencyCondition } from "./dependency/value-dependency-condition"; import { StringMap } from "../stringmap"; import { FormulaireNode } from "./formulaire-node"; +import { FormulaireDefinition } from "./definition/form-definition"; export class SelectField extends Field { @@ -86,22 +84,6 @@ export class SelectField extends Field { } } - public verifiesDependency(d: Dependency): boolean { - if (super.verifiesDependency(d)) { - return true; - } - - switch (d.masterCondition.type) { - case DependencyConditionType.HasValue: - const mc: ValueDependencyCondition = <ValueDependencyCondition>d.masterCondition; - return this._selectedEntry.id === mc.value; - - default: - throw new Error("SelectField.verifiesDependency() : type de condition '" - + DependencyConditionType[d.masterCondition.type] + "' non pris en charge"); - } - } - public updateLocalisation(loc: StringMap) { super.updateLocalisation(loc); for (const e of this._entries) { @@ -112,10 +94,11 @@ export class SelectField extends Field { public parseConfig(field: {}, data?: {}) { this._confId = field["id"]; const source = field["source"]; + const nub: Nub = (this.parentForm as FormulaireDefinition).currentNub; // ad-hoc cases switch (source) { - case "lechapt_calmon_materials": + case "lechapt_calmon_material": this.addEntry(new SelectEntry("select_material_empty", "")); let i = 0; for (const mat of LechaptCalmon.materials) { @@ -125,7 +108,7 @@ export class SelectField extends Field { } break; - case "acsection_available_sections": + case "acsection_section": for (const sec of acSection.availableSectionTypes) { const e: SelectEntry = new SelectEntry("select_section_" + sec.id, sec.value); this.addEntry(e); @@ -146,38 +129,25 @@ export class SelectField extends Field { this.addEntry(e); } break; - } - /* for (const v of values) { - let val: string; - if (v.enum) { - const tmp = v.enum.split("."); - switch (tmp[0]) { - case "ComputeNodeType": - val = ComputeNodeType[tmp[1]]; - break; - - case "StructureType": - val = StructureType[tmp[1]]; - break; - - case "LoiDebit": - val = LoiDebit[tmp[1]]; - break; - - case "MethodeResolution": - val = MethodeResolution[tmp[1]]; - break; - - default: - throw new Error(`type d'enum ${tmp[0]} non pris en charge`); + + case "device_structure_type": + for (const st in (nub as ParallelStructure).getLoisAdmissibles()) { + const e: SelectEntry = new SelectEntry("select_structure_" + st, StructureType[st]); + this.addEntry(e); } - } else if (v.value) { - val = v.value; - } + break; - const id = v["id"]; - const e: SelectEntry = new SelectEntry(id, val); - this.addEntry(e); - } */ + case "device_loi_debit": + // get current structure type from appropriate Nub child + const child = nub.getChildren()[this.parent.indexAsKid()]; + const cst = child.properties.getPropValue("structureType"); + const la = (nub as ParallelStructure).getLoisAdmissibles(); + const stName = StructureType[cst]; + for (const ld of la[stName]) { + const e: SelectEntry = new SelectEntry("select_loidebit_" + stName + "_" + LoiDebit[ld], ld); + this.addEntry(e); + } + break; + } } } diff --git a/src/app/services/formulaire/formulaire.service.ts b/src/app/services/formulaire/formulaire.service.ts index 0b499b5d8..97016de31 100644 --- a/src/app/services/formulaire/formulaire.service.ts +++ b/src/app/services/formulaire/formulaire.service.ts @@ -394,7 +394,6 @@ export class FormulaireService extends Observable { return f; }).then(fi => { - fi.applyDependencies(); this.notifyObservers({ "action": "createForm", "form": fi -- GitLab From 78de1b6672fc2e4885d0cda0d87e7e1a79ac89be Mon Sep 17 00:00:00 2001 From: "mathias.chouet" <mathias.chouet@irstea.fr> Date: Thu, 25 Jul 2019 15:58:14 +0200 Subject: [PATCH 06/13] Removed "nodeType" dependency system --- .../calculators/cloisons/cloisons.config.json | 21 ++++------- src/app/calculators/dever/dever.config.json | 18 +++------ .../parallel-structures.config.json | 37 ++++++------------- .../regime-uniforme.config.json | 11 ------ src/app/calculators/remous/remous.config.json | 11 ------ .../section-param/section-param.config.json | 27 ++++---------- src/app/formulaire/fieldset.ts | 27 ++++---------- 7 files changed, 40 insertions(+), 112 deletions(-) diff --git a/src/app/calculators/cloisons/cloisons.config.json b/src/app/calculators/cloisons/cloisons.config.json index 52e618a77..f661cde4f 100644 --- a/src/app/calculators/cloisons/cloisons.config.json +++ b/src/app/calculators/cloisons/cloisons.config.json @@ -64,44 +64,37 @@ { "type": "input", "id": "h1", - "unit": "m", - "nodeType": "StructureRectangle" + "unit": "m" }, { "type": "input", "id": "L", - "unit": "m", - "nodeType": "StructureRectangle" + "unit": "m" }, { "type": "input", "id": "Cd", - "unit": "", - "nodeType": "StructureRectangle" + "unit": "" }, { "type": "input", "id": "S", - "unit": "", - "nodeType": "StructureRectangle" + "unit": "" }, { "type": "input", "id": "alpha2", - "unit": "", - "nodeType": "StructureRectangle" + "unit": "" }, { "type": "input", "id": "BT", - "unit": "", - "nodeType": "StructureRectangle" + "unit": "" }, { "type": "input", "id": "ZT", - "unit": "", - "nodeType": "StructureRectangle" + "unit": "" } ] }, diff --git a/src/app/calculators/dever/dever.config.json b/src/app/calculators/dever/dever.config.json index c3378c6b0..873c35965 100644 --- a/src/app/calculators/dever/dever.config.json +++ b/src/app/calculators/dever/dever.config.json @@ -52,38 +52,32 @@ { "type": "input", "id": "ZDV", - "unit": "m", - "nodeType": "StructureRectangle" + "unit": "m" }, { "type": "input", "id": "L", - "unit": "m", - "nodeType": "StructureRectangle" + "unit": "m" }, { "type": "input", "id": "Cd", - "unit": "", - "nodeType": "StructureRectangle" + "unit": "" }, { "type": "input", "id": "alpha2", - "unit": "°", - "nodeType": "StructureRectangle" + "unit": "°" }, { "type": "input", "id": "BT", - "unit": "m", - "nodeType": "StructureRectangle" + "unit": "m" }, { "type": "input", "id": "ZT", - "unit": "m", - "nodeType": "StructureRectangle" + "unit": "m" } ] }, diff --git a/src/app/calculators/parallel-structures/parallel-structures.config.json b/src/app/calculators/parallel-structures/parallel-structures.config.json index 4a0b8a580..a477054df 100644 --- a/src/app/calculators/parallel-structures/parallel-structures.config.json +++ b/src/app/calculators/parallel-structures/parallel-structures.config.json @@ -45,80 +45,67 @@ { "type": "input", "id": "ZDV", - "unit": "m", - "nodeType": "StructureRectangle" + "unit": "m" }, { "type": "input", "id": "L", - "unit": "m", - "nodeType": "StructureRectangle" + "unit": "m" }, { "type": "input", "id": "W", - "nodeType": "StructureRectangle", "unit": "m" }, { "type": "input", "id": "CdWSL", - "unit": "", - "nodeType": "StructureRectangle" + "unit": "" }, { "type": "input", "id": "CdWR", - "unit": "", - "nodeType": "StructureRectangle" + "unit": "" }, { "type": "input", "id": "CdGR", - "unit": "", - "nodeType": "StructureRectangle" + "unit": "" }, { "type": "input", "id": "CdT", - "unit": "", - "nodeType": "StructureRectangle" + "unit": "" }, { "type": "input", "id": "alpha", - "unit": "", - "nodeType": "StructureRectangle" + "unit": "" }, { "type": "input", "id": "beta", - "unit": "", - "nodeType": "StructureRectangle" + "unit": "" }, { "type": "input", "id": "ZRAM", - "unit": "m", - "nodeType": "StructureRectangle" + "unit": "m" }, { "type": "input", "id": "alpha2", - "unit": "°", - "nodeType": "StructureRectangle" + "unit": "°" }, { "type": "input", "id": "BT", - "unit": "m", - "nodeType": "StructureRectangle" + "unit": "m" }, { "type": "input", "id": "ZT", - "unit": "m", - "nodeType": "StructureRectangle" + "unit": "m" } ] }, diff --git a/src/app/calculators/regime-uniforme/regime-uniforme.config.json b/src/app/calculators/regime-uniforme/regime-uniforme.config.json index ac65a0ea1..14e321955 100644 --- a/src/app/calculators/regime-uniforme/regime-uniforme.config.json +++ b/src/app/calculators/regime-uniforme/regime-uniforme.config.json @@ -12,38 +12,27 @@ { "type": "input", "id": "LargeurFond", - "nodeType": "SectionTrapeze", "unit": "m" }, { "type": "input", "id": "Fruit", - "nodeType": "SectionTrapeze", "unit": "m/m" }, { "type": "input", "id": "LargeurBerge", - "nodeType": "SectionRectangle", "unit": "m" }, { "type": "input", "id": "D", - "nodeType": "SectionCercle", "unit": "m" }, { "type": "input", "id": "k", - "nodeType": "SectionPuissance", "unit": "" - }, - { - "type": "input", - "id": "LargeurBerge", - "nodeType": "SectionPuissance", - "unit": "m" } ] }, diff --git a/src/app/calculators/remous/remous.config.json b/src/app/calculators/remous/remous.config.json index 172802242..18809cd84 100644 --- a/src/app/calculators/remous/remous.config.json +++ b/src/app/calculators/remous/remous.config.json @@ -12,38 +12,27 @@ { "type": "input", "id": "LargeurFond", - "nodeType": "SectionTrapeze", "unit": "m" }, { "type": "input", "id": "Fruit", - "nodeType": "SectionTrapeze", "unit": "m/m" }, { "type": "input", "id": "LargeurBerge", - "nodeType": "SectionRectangle", "unit": "m" }, { "type": "input", "id": "D", - "nodeType": "SectionCercle", "unit": "m" }, { "type": "input", "id": "k", - "nodeType": "SectionPuissance", "unit": "" - }, - { - "type": "input", - "id": "LargeurBerge", - "nodeType": "SectionPuissance", - "unit": "m" } ] }, diff --git a/src/app/calculators/section-param/section-param.config.json b/src/app/calculators/section-param/section-param.config.json index acb801414..d1b1f4a12 100644 --- a/src/app/calculators/section-param/section-param.config.json +++ b/src/app/calculators/section-param/section-param.config.json @@ -11,39 +11,28 @@ }, { "type": "input", - "id": "LargeurFond", - "unit": "m", - "nodeType": "SectionTrapeze" + "id": "LargeurBerge", + "unit": "m" }, { "type": "input", - "id": "Fruit", - "nodeType": "SectionTrapeze", - "unit": "m/m" + "id": "LargeurFond", + "unit": "m" }, { "type": "input", - "id": "LargeurBerge", - "unit": "m", - "nodeType": "SectionRectangle" + "id": "Fruit", + "unit": "m/m" }, { "type": "input", "id": "D", - "unit": "m", - "nodeType": "SectionCercle" + "unit": "m" }, { "type": "input", "id": "k", - "unit": "", - "nodeType": "SectionPuissance" - }, - { - "type": "input", - "id": "LargeurBerge", - "unit": "m", - "nodeType": "SectionPuissance" + "unit": "" } ] }, diff --git a/src/app/formulaire/fieldset.ts b/src/app/formulaire/fieldset.ts index 9f112fb4c..2bd0a9434 100644 --- a/src/app/formulaire/fieldset.ts +++ b/src/app/formulaire/fieldset.ts @@ -116,29 +116,16 @@ export class FieldSet extends FormulaireElement implements Observer { */ private parse_input(json: {}, default_radio_config: string): NgParameter { const input_id: string = json["id"]; - let res: NgParameter; - - // @TODO tabarnak !? - const nt: string = json["nodeType"]; - const nodeType: ComputeNodeType = nt ? ComputeNodeType[nt] : this.getPropValue("nodeType"); - - if (nodeType === this.getPropValue("nodeType")) { // si le nodeType du paramètre est le même que celui du fieldset - let nubParam: ParamDefinition; - try { - nubParam = this.getNubParamFromSymbol(input_id); - } catch (e) { - console.error(`FieldSet::parse_input : cannot find param from symbol ${input_id}`); - } - if (nubParam) { - res = new NgParameter(nubParam, this); - } - } - - if (res) { + let nubParam: ParamDefinition; + try { + nubParam = this.getNubParamFromSymbol(input_id); + res = new NgParameter(nubParam, this); res.parseConfig(json, { "radioConfig": default_radio_config }); + } catch (e) { + // parameter does not exist in Nub, it's normal, simply do not show it (silent fail) + // console.error(`FieldSet::parse_input : cannot find param from symbol ${input_id}`); } - return res; } -- GitLab From 5dcfe543b1fee78781cae0b86aa97bc535a9d4f2 Mon Sep 17 00:00:00 2001 From: "mathias.chouet" <mathias.chouet@irstea.fr> Date: Thu, 25 Jul 2019 16:25:09 +0200 Subject: [PATCH 07/13] Removed "unit" from config, read it from model instead --- .../calculators/cloisons/cloisons.config.json | 40 +++++---------- .../cond_distri/cond_distri.config.json | 15 ++---- src/app/calculators/dever/dever.config.json | 31 ++++-------- .../lechapt-calmon/lechapt-calmon.config.json | 21 +++----- .../macrorugo/macrorugo.config.json | 33 +++++-------- .../pab-chute/pab-chute.config.json | 9 ++-- .../pab-dimensions/pab-dimensions.config.json | 12 ++--- .../pab-nombre/pab-nombre.config.json | 9 ++-- .../pab-puissance/pab-puissance.config.json | 12 ++--- src/app/calculators/pab/pab.config.json | 7 +-- .../parallel-structures.config.json | 49 ++++++------------- .../regime-uniforme.config.json | 30 ++++-------- src/app/calculators/remous/remous.config.json | 39 +++++---------- .../section-param/section-param.config.json | 30 ++++-------- src/app/formulaire/ngparam.ts | 7 +-- 15 files changed, 112 insertions(+), 232 deletions(-) diff --git a/src/app/calculators/cloisons/cloisons.config.json b/src/app/calculators/cloisons/cloisons.config.json index f661cde4f..63b235b85 100644 --- a/src/app/calculators/cloisons/cloisons.config.json +++ b/src/app/calculators/cloisons/cloisons.config.json @@ -7,38 +7,31 @@ "fields": [ { "type": "input", - "id": "Q", - "symbol": "Q", - "unit": "m³/s" + "id": "Q" }, { "type": "input", "id": "Z1", - "option": "var", - "unit": "m" + "option": "var" }, { "type": "input", "id": "LB", - "option": "var", - "unit": "m" + "option": "var" }, { "type": "input", "id": "BB", - "option": "var", - "unit": "m" + "option": "var" }, { "type": "input", "id": "PB", - "option": "var", - "unit": "m" + "option": "var" }, { "type": "input", - "id": "DH", - "unit": "m" + "id": "DH" } ] }, @@ -63,38 +56,31 @@ }, { "type": "input", - "id": "h1", - "unit": "m" + "id": "h1" }, { "type": "input", - "id": "L", - "unit": "m" + "id": "L" }, { "type": "input", - "id": "Cd", - "unit": "" + "id": "Cd" }, { "type": "input", - "id": "S", - "unit": "" + "id": "S" }, { "type": "input", - "id": "alpha2", - "unit": "" + "id": "alpha2" }, { "type": "input", - "id": "BT", - "unit": "" + "id": "BT" }, { "type": "input", - "id": "ZT", - "unit": "" + "id": "ZT" } ] }, diff --git a/src/app/calculators/cond_distri/cond_distri.config.json b/src/app/calculators/cond_distri/cond_distri.config.json index 7db50cfac..822c1e17d 100644 --- a/src/app/calculators/cond_distri/cond_distri.config.json +++ b/src/app/calculators/cond_distri/cond_distri.config.json @@ -6,28 +6,23 @@ "fields": [ { "type": "input", - "id": "Q", - "unit": "m³/s" + "id": "Q" }, { "type": "input", - "id": "D", - "unit": "m" + "id": "D" }, { "type": "input", - "id": "J", - "unit": "m" + "id": "J" }, { "type": "input", - "id": "Lg", - "unit": "m" + "id": "Lg" }, { "type": "input", - "id": "Nu", - "unit": "Pa·s" + "id": "Nu" } ] }, diff --git a/src/app/calculators/dever/dever.config.json b/src/app/calculators/dever/dever.config.json index 873c35965..3d68c990c 100644 --- a/src/app/calculators/dever/dever.config.json +++ b/src/app/calculators/dever/dever.config.json @@ -7,26 +7,21 @@ "fields": [ { "type": "input", - "id": "Q", - "symbol": "Q", - "unit": "m³/s" + "id": "Q" }, { "type": "input", - "id": "Z1", - "unit": "m" + "id": "Z1" }, { "type": "input", "id": "BR", - "option": "var", - "unit": "m" + "option": "var" }, { "type": "input", "id": "ZR", - "option": "var", - "unit": "m" + "option": "var" } ] }, @@ -51,33 +46,27 @@ }, { "type": "input", - "id": "ZDV", - "unit": "m" + "id": "ZDV" }, { "type": "input", - "id": "L", - "unit": "m" + "id": "L" }, { "type": "input", - "id": "Cd", - "unit": "" + "id": "Cd" }, { "type": "input", - "id": "alpha2", - "unit": "°" + "id": "alpha2" }, { "type": "input", - "id": "BT", - "unit": "m" + "id": "BT" }, { "type": "input", - "id": "ZT", - "unit": "m" + "id": "ZT" } ] }, diff --git a/src/app/calculators/lechapt-calmon/lechapt-calmon.config.json b/src/app/calculators/lechapt-calmon/lechapt-calmon.config.json index d2f57ba0c..1741d1307 100644 --- a/src/app/calculators/lechapt-calmon/lechapt-calmon.config.json +++ b/src/app/calculators/lechapt-calmon/lechapt-calmon.config.json @@ -11,18 +11,15 @@ }, { "type": "input", - "id": "L", - "unit": "" + "id": "L" }, { "type": "input", - "id": "M", - "unit": "" + "id": "M" }, { "type": "input", - "id": "N", - "unit": "" + "id": "N" } ] }, @@ -33,23 +30,19 @@ "fields": [ { "type": "input", - "id": "Q", - "unit": "m³/s" + "id": "Q" }, { "type": "input", - "id": "D", - "unit": "m" + "id": "D" }, { "type": "input", - "id": "J", - "unit": "m" + "id": "J" }, { "type": "input", - "id": "Lg", - "unit": "m" + "id": "Lg" } ] }, diff --git a/src/app/calculators/macrorugo/macrorugo.config.json b/src/app/calculators/macrorugo/macrorugo.config.json index 253a4a984..c03c643a5 100644 --- a/src/app/calculators/macrorugo/macrorugo.config.json +++ b/src/app/calculators/macrorugo/macrorugo.config.json @@ -6,18 +6,15 @@ "fields": [ { "type": "input", - "id": "ZF1", - "unit": "m" + "id": "ZF1" }, { "type": "input", - "id": "L", - "unit": "m" + "id": "L" }, { "type": "input", - "id": "Ks", - "unit": "m" + "id": "Ks" } ] }, @@ -28,28 +25,23 @@ "fields": [ { "type": "input", - "id": "B", - "unit": "m" + "id": "B" }, { "type": "input", - "id": "If", - "unit": "m/m" + "id": "If" }, { "type": "input", - "id": "Q", - "unit": "m³/s" + "id": "Q" }, { "type": "input", - "id": "Y", - "unit": "m" + "id": "Y" }, { "type": "input", - "id": "C", - "unit": "" + "id": "C" } ] }, @@ -60,18 +52,15 @@ "fields": [ { "type": "input", - "id": "PBD", - "unit": "m" + "id": "PBD" }, { "type": "input", - "id": "PBH", - "unit": "m" + "id": "PBH" }, { "type": "input", - "id": "Cd0", - "unit": "" + "id": "Cd0" } ] }, diff --git a/src/app/calculators/pab-chute/pab-chute.config.json b/src/app/calculators/pab-chute/pab-chute.config.json index aa5107384..38f7fd5ad 100644 --- a/src/app/calculators/pab-chute/pab-chute.config.json +++ b/src/app/calculators/pab-chute/pab-chute.config.json @@ -6,18 +6,15 @@ "fields": [ { "type": "input", - "id": "Z1", - "unit": "m" + "id": "Z1" }, { "type": "input", - "id": "Z2", - "unit": "m" + "id": "Z2" }, { "type": "input", - "id": "DH", - "unit": "m" + "id": "DH" } ] }, diff --git a/src/app/calculators/pab-dimensions/pab-dimensions.config.json b/src/app/calculators/pab-dimensions/pab-dimensions.config.json index a199a643e..e617abb90 100644 --- a/src/app/calculators/pab-dimensions/pab-dimensions.config.json +++ b/src/app/calculators/pab-dimensions/pab-dimensions.config.json @@ -6,23 +6,19 @@ "fields": [ { "type": "input", - "id": "L", - "unit": "m" + "id": "L" }, { "type": "input", - "id": "W", - "unit": "m" + "id": "W" }, { "type": "input", - "id": "Y", - "unit": "m" + "id": "Y" }, { "type": "input", - "id": "V", - "unit": "m³" + "id": "V" } ] }, diff --git a/src/app/calculators/pab-nombre/pab-nombre.config.json b/src/app/calculators/pab-nombre/pab-nombre.config.json index 972eeac61..a34a10e06 100644 --- a/src/app/calculators/pab-nombre/pab-nombre.config.json +++ b/src/app/calculators/pab-nombre/pab-nombre.config.json @@ -6,18 +6,15 @@ "fields": [ { "type": "input", - "id": "DHT", - "unit": "m" + "id": "DHT" }, { "type": "input", - "id": "N", - "unit": "" + "id": "N" }, { "type": "input", - "id": "DH", - "unit": "m" + "id": "DH" } ] }, diff --git a/src/app/calculators/pab-puissance/pab-puissance.config.json b/src/app/calculators/pab-puissance/pab-puissance.config.json index 9e2e81595..6a54a0f5c 100644 --- a/src/app/calculators/pab-puissance/pab-puissance.config.json +++ b/src/app/calculators/pab-puissance/pab-puissance.config.json @@ -6,23 +6,19 @@ "fields": [ { "type": "input", - "id": "DH", - "unit": "m" + "id": "DH" }, { "type": "input", - "id": "Q", - "unit": "m³/s" + "id": "Q" }, { "type": "input", - "id": "V", - "unit": "m³" + "id": "V" }, { "type": "input", - "id": "PV", - "unit": "W/m³" + "id": "PV" } ] }, diff --git a/src/app/calculators/pab/pab.config.json b/src/app/calculators/pab/pab.config.json index d477bc7af..91f5420eb 100644 --- a/src/app/calculators/pab/pab.config.json +++ b/src/app/calculators/pab/pab.config.json @@ -7,18 +7,15 @@ "fields": [ { "type": "input", - "id": "Q", - "unit": "m³/s" + "id": "Q" }, { "type": "input", - "id": "Z1", - "unit": "m" + "id": "Z1" }, { "type": "input", "id": "Z2", - "unit": "m", "option": "var" } ] diff --git a/src/app/calculators/parallel-structures/parallel-structures.config.json b/src/app/calculators/parallel-structures/parallel-structures.config.json index a477054df..1c5853cb8 100644 --- a/src/app/calculators/parallel-structures/parallel-structures.config.json +++ b/src/app/calculators/parallel-structures/parallel-structures.config.json @@ -7,19 +7,15 @@ "fields": [ { "type": "input", - "id": "Q", - "symbol": "Q", - "unit": "m³/s" + "id": "Q" }, { "type": "input", - "id": "Z1", - "unit": "m" + "id": "Z1" }, { "type": "input", - "id": "Z2", - "unit": "m" + "id": "Z2" } ] }, @@ -44,68 +40,55 @@ }, { "type": "input", - "id": "ZDV", - "unit": "m" + "id": "ZDV" }, { "type": "input", - "id": "L", - "unit": "m" + "id": "L" }, { "type": "input", - "id": "W", - "unit": "m" + "id": "W" }, { "type": "input", - "id": "CdWSL", - "unit": "" + "id": "CdWSL" }, { "type": "input", - "id": "CdWR", - "unit": "" + "id": "CdWR" }, { "type": "input", - "id": "CdGR", - "unit": "" + "id": "CdGR" }, { "type": "input", - "id": "CdT", - "unit": "" + "id": "CdT" }, { "type": "input", - "id": "alpha", - "unit": "" + "id": "alpha" }, { "type": "input", - "id": "beta", - "unit": "" + "id": "beta" }, { "type": "input", - "id": "ZRAM", - "unit": "m" + "id": "ZRAM" }, { "type": "input", - "id": "alpha2", - "unit": "°" + "id": "alpha2" }, { "type": "input", - "id": "BT", - "unit": "m" + "id": "BT" }, { "type": "input", - "id": "ZT", - "unit": "m" + "id": "ZT" } ] }, diff --git a/src/app/calculators/regime-uniforme/regime-uniforme.config.json b/src/app/calculators/regime-uniforme/regime-uniforme.config.json index 14e321955..b025a75e3 100644 --- a/src/app/calculators/regime-uniforme/regime-uniforme.config.json +++ b/src/app/calculators/regime-uniforme/regime-uniforme.config.json @@ -11,28 +11,23 @@ }, { "type": "input", - "id": "LargeurFond", - "unit": "m" + "id": "LargeurFond" }, { "type": "input", - "id": "Fruit", - "unit": "m/m" + "id": "Fruit" }, { "type": "input", - "id": "LargeurBerge", - "unit": "m" + "id": "LargeurBerge" }, { "type": "input", - "id": "D", - "unit": "m" + "id": "D" }, { "type": "input", - "id": "k", - "unit": "" + "id": "k" } ] }, @@ -43,18 +38,15 @@ "fields": [ { "type": "input", - "id": "Ks", - "unit": "m1/3s-1" + "id": "Ks" }, { "type": "input", - "id": "If", - "unit": "m/m" + "id": "If" }, { "type": "input", - "id": "YB", - "unit": "m" + "id": "YB" } ] }, @@ -65,13 +57,11 @@ "fields": [ { "type": "input", - "id": "Q", - "unit": "m³/s" + "id": "Q" }, { "type": "input", - "id": "Y", - "unit": "m" + "id": "Y" } ] }, diff --git a/src/app/calculators/remous/remous.config.json b/src/app/calculators/remous/remous.config.json index 18809cd84..1a40f822f 100644 --- a/src/app/calculators/remous/remous.config.json +++ b/src/app/calculators/remous/remous.config.json @@ -11,28 +11,23 @@ }, { "type": "input", - "id": "LargeurFond", - "unit": "m" + "id": "LargeurFond" }, { "type": "input", - "id": "Fruit", - "unit": "m/m" + "id": "Fruit" }, { "type": "input", - "id": "LargeurBerge", - "unit": "m" + "id": "LargeurBerge" }, { "type": "input", - "id": "D", - "unit": "m" + "id": "D" }, { "type": "input", - "id": "k", - "unit": "" + "id": "k" } ] }, @@ -43,23 +38,19 @@ "fields": [ { "type": "input", - "id": "Ks", - "unit": "m1/3s-1" + "id": "Ks" }, { "type": "input", - "id": "Long", - "unit": "m" + "id": "Long" }, { "type": "input", - "id": "If", - "unit": "m/m" + "id": "If" }, { "type": "input", - "id": "YB", - "unit": "m" + "id": "YB" } ] }, @@ -70,18 +61,15 @@ "fields": [ { "type": "input", - "id": "Q", - "unit": "m³/s" + "id": "Q" }, { "type": "input", - "id": "Yaval", - "unit": "m" + "id": "Yaval" }, { "type": "input", - "id": "Yamont", - "unit": "m" + "id": "Yamont" } ] }, @@ -92,8 +80,7 @@ "fields": [ { "type": "input", - "id": "Dx", - "unit": "m" + "id": "Dx" }, { "type": "input", diff --git a/src/app/calculators/section-param/section-param.config.json b/src/app/calculators/section-param/section-param.config.json index d1b1f4a12..774e29d6c 100644 --- a/src/app/calculators/section-param/section-param.config.json +++ b/src/app/calculators/section-param/section-param.config.json @@ -11,28 +11,23 @@ }, { "type": "input", - "id": "LargeurBerge", - "unit": "m" + "id": "LargeurBerge" }, { "type": "input", - "id": "LargeurFond", - "unit": "m" + "id": "LargeurFond" }, { "type": "input", - "id": "Fruit", - "unit": "m/m" + "id": "Fruit" }, { "type": "input", - "id": "D", - "unit": "m" + "id": "D" }, { "type": "input", - "id": "k", - "unit": "" + "id": "k" } ] }, @@ -43,18 +38,15 @@ "fields": [ { "type": "input", - "id": "Ks", - "unit": "m1/3s-1" + "id": "Ks" }, { "type": "input", - "id": "If", - "unit": "m/m" + "id": "If" }, { "type": "input", - "id": "YB", - "unit": "m" + "id": "YB" } ] }, @@ -65,13 +57,11 @@ "fields": [ { "type": "input", - "id": "Q", - "unit": "m³/s" + "id": "Q" }, { "type": "input", - "id": "Y", - "unit": "m" + "id": "Y" } ] }, diff --git a/src/app/formulaire/ngparam.ts b/src/app/formulaire/ngparam.ts index 07e5051f6..46d010e42 100644 --- a/src/app/formulaire/ngparam.ts +++ b/src/app/formulaire/ngparam.ts @@ -440,13 +440,8 @@ export class NgParameter extends InputField implements Observer { public parseConfig(json: {}, data?: {}) { const radioConfig: string = json["option"] || data["radioConfig"]; - this._confId = json["id"]; - this.unit = json["unit"]; - const val: number = json["value"]; - if (val) { - this.setValue(this, +val); - } + this.unit = this.paramDefinition.unit; this.radioConfig = NgParameter.getRadioConfig(radioConfig); } -- GitLab From 0c97460fc2430a8ad629c3a6788f3fae17328ae0 Mon Sep 17 00:00:00 2001 From: "mathias.chouet" <mathias.chouet@irstea.fr> Date: Thu, 25 Jul 2019 17:42:19 +0200 Subject: [PATCH 08/13] Removed "input" from config, made it the default field type --- .../calculators/cloisons/cloisons.config.json | 13 ------------- .../cond_distri/cond_distri.config.json | 5 ----- src/app/calculators/dever/dever.config.json | 10 ---------- .../lechapt-calmon/lechapt-calmon.config.json | 7 ------- .../calculators/macrorugo/macrorugo.config.json | 11 ----------- .../calculators/pab-chute/pab-chute.config.json | 3 --- .../pab-dimensions/pab-dimensions.config.json | 4 ---- .../pab-nombre/pab-nombre.config.json | 3 --- .../pab-puissance/pab-puissance.config.json | 4 ---- src/app/calculators/pab/pab.config.json | 3 --- .../parallel-structures.config.json | 16 ---------------- .../regime-uniforme/regime-uniforme.config.json | 10 ---------- src/app/calculators/remous/remous.config.json | 14 -------------- .../section-param/section-param.config.json | 10 ---------- src/app/formulaire/fieldset.ts | 3 ++- 15 files changed, 2 insertions(+), 114 deletions(-) diff --git a/src/app/calculators/cloisons/cloisons.config.json b/src/app/calculators/cloisons/cloisons.config.json index 63b235b85..43f69863c 100644 --- a/src/app/calculators/cloisons/cloisons.config.json +++ b/src/app/calculators/cloisons/cloisons.config.json @@ -6,31 +6,25 @@ "option": "cal", "fields": [ { - "type": "input", "id": "Q" }, { - "type": "input", "id": "Z1", "option": "var" }, { - "type": "input", "id": "LB", "option": "var" }, { - "type": "input", "id": "BB", "option": "var" }, { - "type": "input", "id": "PB", "option": "var" }, { - "type": "input", "id": "DH" } ] @@ -55,31 +49,24 @@ "source": "device_loi_debit" }, { - "type": "input", "id": "h1" }, { - "type": "input", "id": "L" }, { - "type": "input", "id": "Cd" }, { - "type": "input", "id": "S" }, { - "type": "input", "id": "alpha2" }, { - "type": "input", "id": "BT" }, { - "type": "input", "id": "ZT" } ] diff --git a/src/app/calculators/cond_distri/cond_distri.config.json b/src/app/calculators/cond_distri/cond_distri.config.json index 822c1e17d..d4ebc675d 100644 --- a/src/app/calculators/cond_distri/cond_distri.config.json +++ b/src/app/calculators/cond_distri/cond_distri.config.json @@ -5,23 +5,18 @@ "option": "cal", "fields": [ { - "type": "input", "id": "Q" }, { - "type": "input", "id": "D" }, { - "type": "input", "id": "J" }, { - "type": "input", "id": "Lg" }, { - "type": "input", "id": "Nu" } ] diff --git a/src/app/calculators/dever/dever.config.json b/src/app/calculators/dever/dever.config.json index 3d68c990c..c49fe100c 100644 --- a/src/app/calculators/dever/dever.config.json +++ b/src/app/calculators/dever/dever.config.json @@ -6,20 +6,16 @@ "option": "cal", "fields": [ { - "type": "input", "id": "Q" }, { - "type": "input", "id": "Z1" }, { - "type": "input", "id": "BR", "option": "var" }, { - "type": "input", "id": "ZR", "option": "var" } @@ -45,27 +41,21 @@ "source": "device_loi_debit" }, { - "type": "input", "id": "ZDV" }, { - "type": "input", "id": "L" }, { - "type": "input", "id": "Cd" }, { - "type": "input", "id": "alpha2" }, { - "type": "input", "id": "BT" }, { - "type": "input", "id": "ZT" } ] diff --git a/src/app/calculators/lechapt-calmon/lechapt-calmon.config.json b/src/app/calculators/lechapt-calmon/lechapt-calmon.config.json index 1741d1307..3505e8fa8 100644 --- a/src/app/calculators/lechapt-calmon/lechapt-calmon.config.json +++ b/src/app/calculators/lechapt-calmon/lechapt-calmon.config.json @@ -10,15 +10,12 @@ "source": "lechapt_calmon_material" }, { - "type": "input", "id": "L" }, { - "type": "input", "id": "M" }, { - "type": "input", "id": "N" } ] @@ -29,19 +26,15 @@ "option": "cal", "fields": [ { - "type": "input", "id": "Q" }, { - "type": "input", "id": "D" }, { - "type": "input", "id": "J" }, { - "type": "input", "id": "Lg" } ] diff --git a/src/app/calculators/macrorugo/macrorugo.config.json b/src/app/calculators/macrorugo/macrorugo.config.json index c03c643a5..0f5f9b00a 100644 --- a/src/app/calculators/macrorugo/macrorugo.config.json +++ b/src/app/calculators/macrorugo/macrorugo.config.json @@ -5,15 +5,12 @@ "option": "var", "fields": [ { - "type": "input", "id": "ZF1" }, { - "type": "input", "id": "L" }, { - "type": "input", "id": "Ks" } ] @@ -24,23 +21,18 @@ "option": "cal", "fields": [ { - "type": "input", "id": "B" }, { - "type": "input", "id": "If" }, { - "type": "input", "id": "Q" }, { - "type": "input", "id": "Y" }, { - "type": "input", "id": "C" } ] @@ -51,15 +43,12 @@ "option": "var", "fields": [ { - "type": "input", "id": "PBD" }, { - "type": "input", "id": "PBH" }, { - "type": "input", "id": "Cd0" } ] diff --git a/src/app/calculators/pab-chute/pab-chute.config.json b/src/app/calculators/pab-chute/pab-chute.config.json index 38f7fd5ad..f45e9317b 100644 --- a/src/app/calculators/pab-chute/pab-chute.config.json +++ b/src/app/calculators/pab-chute/pab-chute.config.json @@ -5,15 +5,12 @@ "option": "cal", "fields": [ { - "type": "input", "id": "Z1" }, { - "type": "input", "id": "Z2" }, { - "type": "input", "id": "DH" } ] diff --git a/src/app/calculators/pab-dimensions/pab-dimensions.config.json b/src/app/calculators/pab-dimensions/pab-dimensions.config.json index e617abb90..88837dddf 100644 --- a/src/app/calculators/pab-dimensions/pab-dimensions.config.json +++ b/src/app/calculators/pab-dimensions/pab-dimensions.config.json @@ -5,19 +5,15 @@ "option": "cal", "fields": [ { - "type": "input", "id": "L" }, { - "type": "input", "id": "W" }, { - "type": "input", "id": "Y" }, { - "type": "input", "id": "V" } ] diff --git a/src/app/calculators/pab-nombre/pab-nombre.config.json b/src/app/calculators/pab-nombre/pab-nombre.config.json index a34a10e06..983a87bbf 100644 --- a/src/app/calculators/pab-nombre/pab-nombre.config.json +++ b/src/app/calculators/pab-nombre/pab-nombre.config.json @@ -5,15 +5,12 @@ "option": "cal", "fields": [ { - "type": "input", "id": "DHT" }, { - "type": "input", "id": "N" }, { - "type": "input", "id": "DH" } ] diff --git a/src/app/calculators/pab-puissance/pab-puissance.config.json b/src/app/calculators/pab-puissance/pab-puissance.config.json index 6a54a0f5c..3cf2766c7 100644 --- a/src/app/calculators/pab-puissance/pab-puissance.config.json +++ b/src/app/calculators/pab-puissance/pab-puissance.config.json @@ -5,19 +5,15 @@ "option": "cal", "fields": [ { - "type": "input", "id": "DH" }, { - "type": "input", "id": "Q" }, { - "type": "input", "id": "V" }, { - "type": "input", "id": "PV" } ] diff --git a/src/app/calculators/pab/pab.config.json b/src/app/calculators/pab/pab.config.json index 91f5420eb..1e7ae82cd 100644 --- a/src/app/calculators/pab/pab.config.json +++ b/src/app/calculators/pab/pab.config.json @@ -6,15 +6,12 @@ "option": "cal", "fields": [ { - "type": "input", "id": "Q" }, { - "type": "input", "id": "Z1" }, { - "type": "input", "id": "Z2", "option": "var" } diff --git a/src/app/calculators/parallel-structures/parallel-structures.config.json b/src/app/calculators/parallel-structures/parallel-structures.config.json index 1c5853cb8..a1ea704a2 100644 --- a/src/app/calculators/parallel-structures/parallel-structures.config.json +++ b/src/app/calculators/parallel-structures/parallel-structures.config.json @@ -6,15 +6,12 @@ "option": "cal", "fields": [ { - "type": "input", "id": "Q" }, { - "type": "input", "id": "Z1" }, { - "type": "input", "id": "Z2" } ] @@ -39,55 +36,42 @@ "source": "device_loi_debit" }, { - "type": "input", "id": "ZDV" }, { - "type": "input", "id": "L" }, { - "type": "input", "id": "W" }, { - "type": "input", "id": "CdWSL" }, { - "type": "input", "id": "CdWR" }, { - "type": "input", "id": "CdGR" }, { - "type": "input", "id": "CdT" }, { - "type": "input", "id": "alpha" }, { - "type": "input", "id": "beta" }, { - "type": "input", "id": "ZRAM" }, { - "type": "input", "id": "alpha2" }, { - "type": "input", "id": "BT" }, { - "type": "input", "id": "ZT" } ] diff --git a/src/app/calculators/regime-uniforme/regime-uniforme.config.json b/src/app/calculators/regime-uniforme/regime-uniforme.config.json index b025a75e3..e976dfaf1 100644 --- a/src/app/calculators/regime-uniforme/regime-uniforme.config.json +++ b/src/app/calculators/regime-uniforme/regime-uniforme.config.json @@ -10,23 +10,18 @@ "source": "acsection_section" }, { - "type": "input", "id": "LargeurFond" }, { - "type": "input", "id": "Fruit" }, { - "type": "input", "id": "LargeurBerge" }, { - "type": "input", "id": "D" }, { - "type": "input", "id": "k" } ] @@ -37,15 +32,12 @@ "option": "cal", "fields": [ { - "type": "input", "id": "Ks" }, { - "type": "input", "id": "If" }, { - "type": "input", "id": "YB" } ] @@ -56,11 +48,9 @@ "option": "cal", "fields": [ { - "type": "input", "id": "Q" }, { - "type": "input", "id": "Y" } ] diff --git a/src/app/calculators/remous/remous.config.json b/src/app/calculators/remous/remous.config.json index 1a40f822f..99163d72f 100644 --- a/src/app/calculators/remous/remous.config.json +++ b/src/app/calculators/remous/remous.config.json @@ -10,23 +10,18 @@ "source": "acsection_section" }, { - "type": "input", "id": "LargeurFond" }, { - "type": "input", "id": "Fruit" }, { - "type": "input", "id": "LargeurBerge" }, { - "type": "input", "id": "D" }, { - "type": "input", "id": "k" } ] @@ -37,19 +32,15 @@ "option": "fix", "fields": [ { - "type": "input", "id": "Ks" }, { - "type": "input", "id": "Long" }, { - "type": "input", "id": "If" }, { - "type": "input", "id": "YB" } ] @@ -60,15 +51,12 @@ "option": "fix", "fields": [ { - "type": "input", "id": "Q" }, { - "type": "input", "id": "Yaval" }, { - "type": "input", "id": "Yamont" } ] @@ -79,11 +67,9 @@ "option": "fix", "fields": [ { - "type": "input", "id": "Dx" }, { - "type": "input", "id": "Pr" }, { diff --git a/src/app/calculators/section-param/section-param.config.json b/src/app/calculators/section-param/section-param.config.json index 774e29d6c..41a03556a 100644 --- a/src/app/calculators/section-param/section-param.config.json +++ b/src/app/calculators/section-param/section-param.config.json @@ -10,23 +10,18 @@ "source": "acsection_section" }, { - "type": "input", "id": "LargeurBerge" }, { - "type": "input", "id": "LargeurFond" }, { - "type": "input", "id": "Fruit" }, { - "type": "input", "id": "D" }, { - "type": "input", "id": "k" } ] @@ -37,15 +32,12 @@ "option": "var", "fields": [ { - "type": "input", "id": "Ks" }, { - "type": "input", "id": "If" }, { - "type": "input", "id": "YB" } ] @@ -56,11 +48,9 @@ "option": "var", "fields": [ { - "type": "input", "id": "Q" }, { - "type": "input", "id": "Y" } ] diff --git a/src/app/formulaire/fieldset.ts b/src/app/formulaire/fieldset.ts index 2bd0a9434..e888256e4 100644 --- a/src/app/formulaire/fieldset.ts +++ b/src/app/formulaire/fieldset.ts @@ -133,9 +133,10 @@ export class FieldSet extends FormulaireElement implements Observer { const fields = this._jsonConfig["fields"]; for (const field_index in fields) { const field = fields[field_index]; + const type = field["type"] || "input"; // "input" by default let param: Field; - switch (field["type"]) { + switch (type) { case "input": const default_radio_config = this._jsonConfig["option"]; param = this.parse_input(field, default_radio_config); -- GitLab From dd6da1dffcae3c51de9923329112757b7f86cb9d Mon Sep 17 00:00:00 2001 From: "mathias.chouet" <mathias.chouet@irstea.fr> Date: Thu, 25 Jul 2019 17:51:19 +0200 Subject: [PATCH 09/13] Removed "option" from config, read acceptable modes from parameter calculability instead --- .../calculators/cloisons/cloisons.config.json | 14 +++------ .../cond_distri/cond_distri.config.json | 1 - src/app/calculators/dever/dever.config.json | 8 ++--- .../lechapt-calmon/lechapt-calmon.config.json | 2 -- .../macrorugo/macrorugo.config.json | 3 -- .../pab-chute/pab-chute.config.json | 1 - .../pab-dimensions/pab-dimensions.config.json | 1 - .../pab-nombre/pab-nombre.config.json | 1 - .../pab-puissance/pab-puissance.config.json | 1 - src/app/calculators/pab/pab.config.json | 4 +-- .../parallel-structures.config.json | 2 -- .../regime-uniforme.config.json | 3 -- src/app/calculators/remous/remous.config.json | 4 --- .../section-param/section-param.config.json | 3 -- src/app/formulaire/fieldset.ts | 12 ++++---- src/app/formulaire/ngparam.ts | 30 +++++++++---------- 16 files changed, 27 insertions(+), 63 deletions(-) diff --git a/src/app/calculators/cloisons/cloisons.config.json b/src/app/calculators/cloisons/cloisons.config.json index 43f69863c..fe39ea7f1 100644 --- a/src/app/calculators/cloisons/cloisons.config.json +++ b/src/app/calculators/cloisons/cloisons.config.json @@ -3,26 +3,21 @@ "id": "fs_param_hydro", "type": "fieldset", "calcType": "Dever", - "option": "cal", "fields": [ { "id": "Q" }, { - "id": "Z1", - "option": "var" + "id": "Z1" }, { - "id": "LB", - "option": "var" + "id": "LB" }, { - "id": "BB", - "option": "var" + "id": "BB" }, { - "id": "PB", - "option": "var" + "id": "PB" }, { "id": "DH" @@ -36,7 +31,6 @@ "defaultNodeType": "StructureRectangle", "defaultStructType": "SeuilRectangulaire", "defaultLoiDebit": "WeirSubmergedLarinier", - "option": "cal", "fields": [ { "id": "select_ouvrage", diff --git a/src/app/calculators/cond_distri/cond_distri.config.json b/src/app/calculators/cond_distri/cond_distri.config.json index d4ebc675d..27563717a 100644 --- a/src/app/calculators/cond_distri/cond_distri.config.json +++ b/src/app/calculators/cond_distri/cond_distri.config.json @@ -2,7 +2,6 @@ { "id": "fs_hydraulique", "type": "fieldset", - "option": "cal", "fields": [ { "id": "Q" diff --git a/src/app/calculators/dever/dever.config.json b/src/app/calculators/dever/dever.config.json index c49fe100c..501eb6e78 100644 --- a/src/app/calculators/dever/dever.config.json +++ b/src/app/calculators/dever/dever.config.json @@ -3,7 +3,6 @@ "id": "fs_param_hydro", "type": "fieldset", "calcType": "Dever", - "option": "cal", "fields": [ { "id": "Q" @@ -12,12 +11,10 @@ "id": "Z1" }, { - "id": "BR", - "option": "var" + "id": "BR" }, { - "id": "ZR", - "option": "var" + "id": "ZR" } ] }, @@ -28,7 +25,6 @@ "defaultNodeType": "StructureRectangle", "defaultStructType": "SeuilRectangulaire", "defaultLoiDebit": "WeirFree", - "option": "cal", "fields": [ { "id": "select_ouvrage", diff --git a/src/app/calculators/lechapt-calmon/lechapt-calmon.config.json b/src/app/calculators/lechapt-calmon/lechapt-calmon.config.json index 3505e8fa8..dcb289eec 100644 --- a/src/app/calculators/lechapt-calmon/lechapt-calmon.config.json +++ b/src/app/calculators/lechapt-calmon/lechapt-calmon.config.json @@ -2,7 +2,6 @@ { "id": "fs_materiau", "type": "fieldset", - "option": "fix", "fields": [ { "id": "select_material", @@ -23,7 +22,6 @@ { "id": "fs_hydraulique", "type": "fieldset", - "option": "cal", "fields": [ { "id": "Q" diff --git a/src/app/calculators/macrorugo/macrorugo.config.json b/src/app/calculators/macrorugo/macrorugo.config.json index 0f5f9b00a..5c7dc9968 100644 --- a/src/app/calculators/macrorugo/macrorugo.config.json +++ b/src/app/calculators/macrorugo/macrorugo.config.json @@ -2,7 +2,6 @@ { "id": "fs_hydraulique_fix", "type": "fieldset", - "option": "var", "fields": [ { "id": "ZF1" @@ -18,7 +17,6 @@ { "id": "fs_hydraulique_cal", "type": "fieldset", - "option": "cal", "fields": [ { "id": "B" @@ -40,7 +38,6 @@ { "id": "fs_bloc", "type": "fieldset", - "option": "var", "fields": [ { "id": "PBD" diff --git a/src/app/calculators/pab-chute/pab-chute.config.json b/src/app/calculators/pab-chute/pab-chute.config.json index f45e9317b..acdd425b7 100644 --- a/src/app/calculators/pab-chute/pab-chute.config.json +++ b/src/app/calculators/pab-chute/pab-chute.config.json @@ -2,7 +2,6 @@ { "id": "fs_chute", "type": "fieldset", - "option": "cal", "fields": [ { "id": "Z1" diff --git a/src/app/calculators/pab-dimensions/pab-dimensions.config.json b/src/app/calculators/pab-dimensions/pab-dimensions.config.json index 88837dddf..0dc5a6724 100644 --- a/src/app/calculators/pab-dimensions/pab-dimensions.config.json +++ b/src/app/calculators/pab-dimensions/pab-dimensions.config.json @@ -2,7 +2,6 @@ { "id": "fs_dimensions", "type": "fieldset", - "option": "cal", "fields": [ { "id": "L" diff --git a/src/app/calculators/pab-nombre/pab-nombre.config.json b/src/app/calculators/pab-nombre/pab-nombre.config.json index 983a87bbf..152afc882 100644 --- a/src/app/calculators/pab-nombre/pab-nombre.config.json +++ b/src/app/calculators/pab-nombre/pab-nombre.config.json @@ -2,7 +2,6 @@ { "id": "fs_nombre", "type": "fieldset", - "option": "cal", "fields": [ { "id": "DHT" diff --git a/src/app/calculators/pab-puissance/pab-puissance.config.json b/src/app/calculators/pab-puissance/pab-puissance.config.json index 3cf2766c7..d7e9228a5 100644 --- a/src/app/calculators/pab-puissance/pab-puissance.config.json +++ b/src/app/calculators/pab-puissance/pab-puissance.config.json @@ -2,7 +2,6 @@ { "id": "fs_puissance", "type": "fieldset", - "option": "cal", "fields": [ { "id": "DH" diff --git a/src/app/calculators/pab/pab.config.json b/src/app/calculators/pab/pab.config.json index 1e7ae82cd..2028b9a19 100644 --- a/src/app/calculators/pab/pab.config.json +++ b/src/app/calculators/pab/pab.config.json @@ -3,7 +3,6 @@ "id": "fs_param_hydro", "type": "fieldset", "calcType": "Pab", - "option": "cal", "fields": [ { "id": "Q" @@ -12,8 +11,7 @@ "id": "Z1" }, { - "id": "Z2", - "option": "var" + "id": "Z2" } ] }, diff --git a/src/app/calculators/parallel-structures/parallel-structures.config.json b/src/app/calculators/parallel-structures/parallel-structures.config.json index a1ea704a2..1fb0a205e 100644 --- a/src/app/calculators/parallel-structures/parallel-structures.config.json +++ b/src/app/calculators/parallel-structures/parallel-structures.config.json @@ -3,7 +3,6 @@ "id": "fs_param_hydro", "type": "fieldset", "calcType": "ParallelStructure", - "option": "cal", "fields": [ { "id": "Q" @@ -23,7 +22,6 @@ "defaultNodeType": "StructureRectangle", "defaultStructType": "VanneRectangulaire", "defaultLoiDebit": "GateCem88v", - "option": "cal", "fields": [ { "id": "select_ouvrage", diff --git a/src/app/calculators/regime-uniforme/regime-uniforme.config.json b/src/app/calculators/regime-uniforme/regime-uniforme.config.json index e976dfaf1..393a1f3a6 100644 --- a/src/app/calculators/regime-uniforme/regime-uniforme.config.json +++ b/src/app/calculators/regime-uniforme/regime-uniforme.config.json @@ -2,7 +2,6 @@ { "id": "fs_section", "type": "fieldset", - "option": "cal", "fields": [ { "id": "select_section", @@ -29,7 +28,6 @@ { "id": "fs_bief", "type": "fieldset", - "option": "cal", "fields": [ { "id": "Ks" @@ -45,7 +43,6 @@ { "id": "fs_hydraulique", "type": "fieldset", - "option": "cal", "fields": [ { "id": "Q" diff --git a/src/app/calculators/remous/remous.config.json b/src/app/calculators/remous/remous.config.json index 99163d72f..a87ad77e0 100644 --- a/src/app/calculators/remous/remous.config.json +++ b/src/app/calculators/remous/remous.config.json @@ -2,7 +2,6 @@ { "id": "fs_section", "type": "fieldset", - "option": "fix", "fields": [ { "id": "select_section", @@ -29,7 +28,6 @@ { "id": "fs_bief", "type": "fieldset", - "option": "fix", "fields": [ { "id": "Ks" @@ -48,7 +46,6 @@ { "id": "fs_condlim", "type": "fieldset", - "option": "fix", "fields": [ { "id": "Q" @@ -64,7 +61,6 @@ { "id": "fs_param_calc", "type": "fieldset", - "option": "fix", "fields": [ { "id": "Dx" diff --git a/src/app/calculators/section-param/section-param.config.json b/src/app/calculators/section-param/section-param.config.json index 41a03556a..b92c51876 100644 --- a/src/app/calculators/section-param/section-param.config.json +++ b/src/app/calculators/section-param/section-param.config.json @@ -2,7 +2,6 @@ { "id": "fs_section", "type": "fieldset", - "option": "var", "fields": [ { "id": "select_section", @@ -29,7 +28,6 @@ { "id": "fs_bief", "type": "fieldset", - "option": "var", "fields": [ { "id": "Ks" @@ -45,7 +43,6 @@ { "id": "fs_hydraulique", "type": "fieldset", - "option": "var", "fields": [ { "id": "Q" diff --git a/src/app/formulaire/fieldset.ts b/src/app/formulaire/fieldset.ts index e888256e4..01b95f337 100644 --- a/src/app/formulaire/fieldset.ts +++ b/src/app/formulaire/fieldset.ts @@ -114,14 +114,14 @@ export class FieldSet extends FormulaireElement implements Observer { * @param node_type_filter filtre sur le type de noeud (input créé si undefined ou égal) * @param default_radio_config config du radio fixé/à varier/à calculer */ - private parse_input(json: {}, default_radio_config: string): NgParameter { + private parse_input(json: {}): NgParameter { const input_id: string = json["id"]; let res: NgParameter; let nubParam: ParamDefinition; try { nubParam = this.getNubParamFromSymbol(input_id); res = new NgParameter(nubParam, this); - res.parseConfig(json, { "radioConfig": default_radio_config }); + res.parseConfig(json); } catch (e) { // parameter does not exist in Nub, it's normal, simply do not show it (silent fail) // console.error(`FieldSet::parse_input : cannot find param from symbol ${input_id}`); @@ -138,10 +138,10 @@ export class FieldSet extends FormulaireElement implements Observer { switch (type) { case "input": - const default_radio_config = this._jsonConfig["option"]; - param = this.parse_input(field, default_radio_config); - // tslint:disable-next-line:max-line-length - if (param) { // potentiellement undefined car certaines définitions de FieldSet comportent des paramètres qui ne sont pas tous affichés en même temps (cf. ouvrages //) + param = this.parse_input(field); + // potentiellement undefined car certaines définitions de FieldSet comportent des paramètres + // qui ne sont pas tous affichés en même temps (cf. ouvrages //) + if (param) { this.addField(param); } break; diff --git a/src/app/formulaire/ngparam.ts b/src/app/formulaire/ngparam.ts index 46d010e42..c10a48d45 100644 --- a/src/app/formulaire/ngparam.ts +++ b/src/app/formulaire/ngparam.ts @@ -261,20 +261,19 @@ export class NgParameter extends InputField implements Observer { return this._paramDef.valuesIterator; } - private static getRadioConfig(s: string) { - if (s === "fix") { - return ParamRadioConfig.FIX; - } - - if (s === "var") { - return ParamRadioConfig.VAR; - } - - if (s === "cal") { - return ParamRadioConfig.CAL; + /** + * Reads radio config from parameter calculability + */ + private getRadioConfig() { + switch (this.paramDefinition.calculability) { + case ParamCalculability.FIXED: + return ParamRadioConfig.FIX; + case ParamCalculability.FREE: + return ParamRadioConfig.VAR; + case ParamCalculability.DICHO: + case ParamCalculability.EQUATION: + return ParamRadioConfig.CAL; } - - throw new Error("invalid parameter radio configuration " + s); } /** @@ -438,11 +437,10 @@ export class NgParameter extends InputField implements Observer { return this._paramDef.checkStep(step); } - public parseConfig(json: {}, data?: {}) { - const radioConfig: string = json["option"] || data["radioConfig"]; + public parseConfig(json: {}) { this._confId = json["id"]; this.unit = this.paramDefinition.unit; - this.radioConfig = NgParameter.getRadioConfig(radioConfig); + this.radioConfig = this.getRadioConfig(); } // interface Observer -- GitLab From db6dc1c6db9e2fd6d19731fbca5522d94f2168c6 Mon Sep 17 00:00:00 2001 From: "mathias.chouet" <mathias.chouet@irstea.fr> Date: Fri, 26 Jul 2019 11:39:57 +0200 Subject: [PATCH 10/13] Short input syntax in config files; added new Cd* inputs to Dever and Cloisons --- .../calculators/cloisons/cloisons.config.json | 55 +++++----------- .../cond_distri/cond_distri.config.json | 20 ++---- src/app/calculators/dever/dever.config.json | 43 ++++-------- .../lechapt-calmon/lechapt-calmon.config.json | 28 ++------ .../macrorugo/macrorugo.config.json | 44 ++++--------- .../pab-chute/pab-chute.config.json | 12 +--- .../pab-dimensions/pab-dimensions.config.json | 16 ++--- .../pab-nombre/pab-nombre.config.json | 12 +--- .../pab-puissance/pab-puissance.config.json | 16 ++--- src/app/calculators/pab/pab.config.json | 12 +--- .../parallel-structures.config.json | 65 +++++-------------- .../regime-uniforme.config.json | 40 +++--------- src/app/calculators/remous/remous.config.json | 56 ++++------------ .../section-param/section-param.config.json | 40 +++--------- src/app/formulaire/fieldset.ts | 15 +++-- 15 files changed, 131 insertions(+), 343 deletions(-) diff --git a/src/app/calculators/cloisons/cloisons.config.json b/src/app/calculators/cloisons/cloisons.config.json index fe39ea7f1..e8104fbd0 100644 --- a/src/app/calculators/cloisons/cloisons.config.json +++ b/src/app/calculators/cloisons/cloisons.config.json @@ -4,24 +4,12 @@ "type": "fieldset", "calcType": "Dever", "fields": [ - { - "id": "Q" - }, - { - "id": "Z1" - }, - { - "id": "LB" - }, - { - "id": "BB" - }, - { - "id": "PB" - }, - { - "id": "DH" - } + "Q", + "Z1", + "LB", + "BB", + "PB", + "DH" ] }, { @@ -42,27 +30,16 @@ "type": "select", "source": "device_loi_debit" }, - { - "id": "h1" - }, - { - "id": "L" - }, - { - "id": "Cd" - }, - { - "id": "S" - }, - { - "id": "alpha2" - }, - { - "id": "BT" - }, - { - "id": "ZT" - } + "h1", + "L", + "CdWSL", + "CdWR", + "CdGR", + "CdT", + "S", + "alpha2", + "BT", + "ZT" ] }, { diff --git a/src/app/calculators/cond_distri/cond_distri.config.json b/src/app/calculators/cond_distri/cond_distri.config.json index 27563717a..87dce58d1 100644 --- a/src/app/calculators/cond_distri/cond_distri.config.json +++ b/src/app/calculators/cond_distri/cond_distri.config.json @@ -3,21 +3,11 @@ "id": "fs_hydraulique", "type": "fieldset", "fields": [ - { - "id": "Q" - }, - { - "id": "D" - }, - { - "id": "J" - }, - { - "id": "Lg" - }, - { - "id": "Nu" - } + "Q", + "D", + "J", + "Lg", + "Nu" ] }, { diff --git a/src/app/calculators/dever/dever.config.json b/src/app/calculators/dever/dever.config.json index 501eb6e78..9b8b87dcd 100644 --- a/src/app/calculators/dever/dever.config.json +++ b/src/app/calculators/dever/dever.config.json @@ -4,18 +4,10 @@ "type": "fieldset", "calcType": "Dever", "fields": [ - { - "id": "Q" - }, - { - "id": "Z1" - }, - { - "id": "BR" - }, - { - "id": "ZR" - } + "Q", + "Z1", + "BR", + "ZR" ] }, { @@ -36,24 +28,15 @@ "type": "select", "source": "device_loi_debit" }, - { - "id": "ZDV" - }, - { - "id": "L" - }, - { - "id": "Cd" - }, - { - "id": "alpha2" - }, - { - "id": "BT" - }, - { - "id": "ZT" - } + "ZDV", + "L", + "CdWSL", + "CdWR", + "CdGR", + "CdT", + "alpha2", + "BT", + "ZT" ] }, { diff --git a/src/app/calculators/lechapt-calmon/lechapt-calmon.config.json b/src/app/calculators/lechapt-calmon/lechapt-calmon.config.json index dcb289eec..9d2e58903 100644 --- a/src/app/calculators/lechapt-calmon/lechapt-calmon.config.json +++ b/src/app/calculators/lechapt-calmon/lechapt-calmon.config.json @@ -8,33 +8,19 @@ "type": "select", "source": "lechapt_calmon_material" }, - { - "id": "L" - }, - { - "id": "M" - }, - { - "id": "N" - } + "L", + "M", + "N" ] }, { "id": "fs_hydraulique", "type": "fieldset", "fields": [ - { - "id": "Q" - }, - { - "id": "D" - }, - { - "id": "J" - }, - { - "id": "Lg" - } + "Q", + "D", + "J", + "Lg" ] }, { diff --git a/src/app/calculators/macrorugo/macrorugo.config.json b/src/app/calculators/macrorugo/macrorugo.config.json index 5c7dc9968..b7df1196a 100644 --- a/src/app/calculators/macrorugo/macrorugo.config.json +++ b/src/app/calculators/macrorugo/macrorugo.config.json @@ -3,51 +3,29 @@ "id": "fs_hydraulique_fix", "type": "fieldset", "fields": [ - { - "id": "ZF1" - }, - { - "id": "L" - }, - { - "id": "Ks" - } + "ZF1", + "L", + "Ks" ] }, { "id": "fs_hydraulique_cal", "type": "fieldset", "fields": [ - { - "id": "B" - }, - { - "id": "If" - }, - { - "id": "Q" - }, - { - "id": "Y" - }, - { - "id": "C" - } + "B", + "If", + "Q", + "Y", + "C" ] }, { "id": "fs_bloc", "type": "fieldset", "fields": [ - { - "id": "PBD" - }, - { - "id": "PBH" - }, - { - "id": "Cd0" - } + "PBD", + "PBH", + "Cd0" ] }, { diff --git a/src/app/calculators/pab-chute/pab-chute.config.json b/src/app/calculators/pab-chute/pab-chute.config.json index acdd425b7..6289d4184 100644 --- a/src/app/calculators/pab-chute/pab-chute.config.json +++ b/src/app/calculators/pab-chute/pab-chute.config.json @@ -3,15 +3,9 @@ "id": "fs_chute", "type": "fieldset", "fields": [ - { - "id": "Z1" - }, - { - "id": "Z2" - }, - { - "id": "DH" - } + "Z1", + "Z2", + "DH" ] }, { diff --git a/src/app/calculators/pab-dimensions/pab-dimensions.config.json b/src/app/calculators/pab-dimensions/pab-dimensions.config.json index 0dc5a6724..3f455962c 100644 --- a/src/app/calculators/pab-dimensions/pab-dimensions.config.json +++ b/src/app/calculators/pab-dimensions/pab-dimensions.config.json @@ -3,18 +3,10 @@ "id": "fs_dimensions", "type": "fieldset", "fields": [ - { - "id": "L" - }, - { - "id": "W" - }, - { - "id": "Y" - }, - { - "id": "V" - } + "L", + "W", + "Y", + "V" ] }, { diff --git a/src/app/calculators/pab-nombre/pab-nombre.config.json b/src/app/calculators/pab-nombre/pab-nombre.config.json index 152afc882..8a267c93d 100644 --- a/src/app/calculators/pab-nombre/pab-nombre.config.json +++ b/src/app/calculators/pab-nombre/pab-nombre.config.json @@ -3,15 +3,9 @@ "id": "fs_nombre", "type": "fieldset", "fields": [ - { - "id": "DHT" - }, - { - "id": "N" - }, - { - "id": "DH" - } + "DHT", + "N", + "DH" ] }, { diff --git a/src/app/calculators/pab-puissance/pab-puissance.config.json b/src/app/calculators/pab-puissance/pab-puissance.config.json index d7e9228a5..7432a9c63 100644 --- a/src/app/calculators/pab-puissance/pab-puissance.config.json +++ b/src/app/calculators/pab-puissance/pab-puissance.config.json @@ -3,18 +3,10 @@ "id": "fs_puissance", "type": "fieldset", "fields": [ - { - "id": "DH" - }, - { - "id": "Q" - }, - { - "id": "V" - }, - { - "id": "PV" - } + "DH", + "Q", + "V", + "PV" ] }, { diff --git a/src/app/calculators/pab/pab.config.json b/src/app/calculators/pab/pab.config.json index 2028b9a19..edca91704 100644 --- a/src/app/calculators/pab/pab.config.json +++ b/src/app/calculators/pab/pab.config.json @@ -4,15 +4,9 @@ "type": "fieldset", "calcType": "Pab", "fields": [ - { - "id": "Q" - }, - { - "id": "Z1" - }, - { - "id": "Z2" - } + "Q", + "Z1", + "Z2" ] }, { diff --git a/src/app/calculators/parallel-structures/parallel-structures.config.json b/src/app/calculators/parallel-structures/parallel-structures.config.json index 1fb0a205e..02cb7d17f 100644 --- a/src/app/calculators/parallel-structures/parallel-structures.config.json +++ b/src/app/calculators/parallel-structures/parallel-structures.config.json @@ -4,15 +4,9 @@ "type": "fieldset", "calcType": "ParallelStructure", "fields": [ - { - "id": "Q" - }, - { - "id": "Z1" - }, - { - "id": "Z2" - } + "Q", + "Z1", + "Z2" ] }, { @@ -33,45 +27,20 @@ "type": "select", "source": "device_loi_debit" }, - { - "id": "ZDV" - }, - { - "id": "L" - }, - { - "id": "W" - }, - { - "id": "CdWSL" - }, - { - "id": "CdWR" - }, - { - "id": "CdGR" - }, - { - "id": "CdT" - }, - { - "id": "alpha" - }, - { - "id": "beta" - }, - { - "id": "ZRAM" - }, - { - "id": "alpha2" - }, - { - "id": "BT" - }, - { - "id": "ZT" - } + "S", + "ZDV", + "L", + "W", + "CdWSL", + "CdWR", + "CdGR", + "CdT", + "alpha", + "beta", + "ZRAM", + "alpha2", + "BT", + "ZT" ] }, { diff --git a/src/app/calculators/regime-uniforme/regime-uniforme.config.json b/src/app/calculators/regime-uniforme/regime-uniforme.config.json index 393a1f3a6..3633e1aa7 100644 --- a/src/app/calculators/regime-uniforme/regime-uniforme.config.json +++ b/src/app/calculators/regime-uniforme/regime-uniforme.config.json @@ -8,48 +8,28 @@ "type": "select", "source": "acsection_section" }, - { - "id": "LargeurFond" - }, - { - "id": "Fruit" - }, - { - "id": "LargeurBerge" - }, - { - "id": "D" - }, - { - "id": "k" - } + "LargeurFond", + "Fruit", + "LargeurBerge", + "D", + "k" ] }, { "id": "fs_bief", "type": "fieldset", "fields": [ - { - "id": "Ks" - }, - { - "id": "If" - }, - { - "id": "YB" - } + "Ks", + "If", + "YB" ] }, { "id": "fs_hydraulique", "type": "fieldset", "fields": [ - { - "id": "Q" - }, - { - "id": "Y" - } + "Q", + "Y" ] }, { diff --git a/src/app/calculators/remous/remous.config.json b/src/app/calculators/remous/remous.config.json index a87ad77e0..a6110791b 100644 --- a/src/app/calculators/remous/remous.config.json +++ b/src/app/calculators/remous/remous.config.json @@ -8,66 +8,38 @@ "type": "select", "source": "acsection_section" }, - { - "id": "LargeurFond" - }, - { - "id": "Fruit" - }, - { - "id": "LargeurBerge" - }, - { - "id": "D" - }, - { - "id": "k" - } + "LargeurFond", + "Fruit", + "LargeurBerge", + "D", + "k" ] }, { "id": "fs_bief", "type": "fieldset", "fields": [ - { - "id": "Ks" - }, - { - "id": "Long" - }, - { - "id": "If" - }, - { - "id": "YB" - } + "Ks", + "Long", + "If", + "YB" ] }, { "id": "fs_condlim", "type": "fieldset", "fields": [ - { - "id": "Q" - }, - { - "id": "Yaval" - }, - { - "id": "Yamont" - } + "Q", + "Yaval", + "Yamont" ] }, { "id": "fs_param_calc", "type": "fieldset", "fields": [ - { - "id": "Dx" - }, - { - "id": "Pr" - }, + "Dx", + "Pr", { "id": "select_resolution", "type": "select", diff --git a/src/app/calculators/section-param/section-param.config.json b/src/app/calculators/section-param/section-param.config.json index b92c51876..fd31b8be3 100644 --- a/src/app/calculators/section-param/section-param.config.json +++ b/src/app/calculators/section-param/section-param.config.json @@ -8,48 +8,28 @@ "type": "select", "source": "acsection_section" }, - { - "id": "LargeurBerge" - }, - { - "id": "LargeurFond" - }, - { - "id": "Fruit" - }, - { - "id": "D" - }, - { - "id": "k" - } + "LargeurBerge", + "LargeurFond", + "Fruit", + "D", + "k" ] }, { "id": "fs_bief", "type": "fieldset", "fields": [ - { - "id": "Ks" - }, - { - "id": "If" - }, - { - "id": "YB" - } + "Ks", + "If", + "YB" ] }, { "id": "fs_hydraulique", "type": "fieldset", "fields": [ - { - "id": "Q" - }, - { - "id": "Y" - } + "Q", + "Y" ] }, { diff --git a/src/app/formulaire/fieldset.ts b/src/app/formulaire/fieldset.ts index 01b95f337..42df86e35 100644 --- a/src/app/formulaire/fieldset.ts +++ b/src/app/formulaire/fieldset.ts @@ -120,11 +120,12 @@ export class FieldSet extends FormulaireElement implements Observer { let nubParam: ParamDefinition; try { nubParam = this.getNubParamFromSymbol(input_id); - res = new NgParameter(nubParam, this); - res.parseConfig(json); + if (nubParam.visible) { + res = new NgParameter(nubParam, this); + res.parseConfig(json); + } } catch (e) { // parameter does not exist in Nub, it's normal, simply do not show it (silent fail) - // console.error(`FieldSet::parse_input : cannot find param from symbol ${input_id}`); } return res; } @@ -132,7 +133,13 @@ export class FieldSet extends FormulaireElement implements Observer { private parseFields() { const fields = this._jsonConfig["fields"]; for (const field_index in fields) { - const field = fields[field_index]; + let field = fields[field_index]; + // detect short input syntax + if (typeof field === "string") { + field = { + "id": field + }; + } const type = field["type"] || "input"; // "input" by default let param: Field; -- GitLab From 1057224b59e72bc0470d66294c95b471d9dd642a Mon Sep 17 00:00:00 2001 From: "mathias.chouet" <mathias.chouet@irstea.fr> Date: Fri, 26 Jul 2019 14:39:03 +0200 Subject: [PATCH 11/13] Properly rebased devices <select> on model --- src/app/formulaire/fieldset.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/app/formulaire/fieldset.ts b/src/app/formulaire/fieldset.ts index 42df86e35..061ea09f2 100644 --- a/src/app/formulaire/fieldset.ts +++ b/src/app/formulaire/fieldset.ts @@ -200,11 +200,11 @@ export class FieldSet extends FormulaireElement implements Observer { const st: StructureType = this.getPropValue("structureType"); switch (st) { case StructureType.SeuilRectangulaire: - this.setSelectValueFromProperty("select_loidebit1", "loiDebit"); + this.setSelectValueFromProperty("select_loidebit", "loiDebit"); break; case StructureType.VanneRectangulaire: - this.setSelectValueFromProperty("select_loidebit2", "loiDebit"); + this.setSelectValueFromProperty("select_loidebit", "loiDebit"); break; } break; @@ -233,6 +233,7 @@ export class FieldSet extends FormulaireElement implements Observer { const propVal: any = this.getPropValue(propertyKey); const selectElement = selectField.getSelectedEntryFromValue(propVal); try { + console.log("Setting select value", selectElement); selectField.setValue(selectElement); } catch (e) { console.error(`setSelectValueFromProperty: cannot set value ${propVal} on <select> ${selectId}`); -- GitLab From 8748258b3ee75f463c0633e625eb197eee8f75b2 Mon Sep 17 00:00:00 2001 From: "mathias.chouet" <mathias.chouet@irstea.fr> Date: Fri, 26 Jul 2019 14:58:19 +0200 Subject: [PATCH 12/13] Removed unused configuration --- .../section-param/section-param.en.json | 20 ------------------- .../section-param/section-param.fr.json | 20 ------------------- 2 files changed, 40 deletions(-) diff --git a/src/app/calculators/section-param/section-param.en.json b/src/app/calculators/section-param/section-param.en.json index d4675575f..765b14979 100644 --- a/src/app/calculators/section-param/section-param.en.json +++ b/src/app/calculators/section-param/section-param.en.json @@ -23,26 +23,6 @@ "Y": "Draft", "fs_param_calc": "Calculation parameters", "Pr": "Display accuracy", - "fs_computed_var": "Data to compute", - "select_target": "Choice of the data to compute", - "select_target_Hs": "Specific head (m)", - "select_target_Hsc": "Critical head (m)", - "select_target_B": "Surface width (m)", - "select_target_P": "Wetted perimeter (m)", - "select_target_S": "Wetted area (m2)", - "select_target_R": "Hydraulic radius (m)", - "select_target_V": "Average speed (m/s)", - "select_target_Fr": "Froude number", - "select_target_Yc": "Critical depth (m)", - "select_target_Yn": "Normal depth (m)", - "select_target_Yf": "Subcritical depth (m)", - "select_target_Yt": "Supercritical depth (m)", - "select_target_Yco": "Conjugate depth (m)", - "select_target_J": "Head loss (m)", - "select_target_I-J": "Linear variation of specific head (m/m)", - "select_target_Imp": "Impulse (N)", - "select_target_Tau0": "Tractive force (Pa)", - "Hs": "Charge spécifique", "Hsc": "Charge critique", "B": "Largeur au miroir", diff --git a/src/app/calculators/section-param/section-param.fr.json b/src/app/calculators/section-param/section-param.fr.json index 4ad30ced9..aa95a5452 100644 --- a/src/app/calculators/section-param/section-param.fr.json +++ b/src/app/calculators/section-param/section-param.fr.json @@ -22,26 +22,6 @@ "Y": "Tirant d'eau", "fs_param_calc": "Paramètres de calcul", "Pr": "Précision de calcul", - "fs_computed_var": "Donnée à calculer", - "select_target": "Choix de la donnée à calculer", - "select_target_Hs": "La charge spécifique (m)", - "select_target_Hsc": "La charge critique (m)", - "select_target_B": "La largeur au miroir (m)", - "select_target_P": "Le périmètre mouillé (m)", - "select_target_S": "La surface mouillée (m2)", - "select_target_R": "Le rayon hydraulique (m)", - "select_target_V": "La vitesse moyenne (m/s)", - "select_target_Fr": "Le Froude", - "select_target_Yc": "Le tirant d'eau critique (m)", - "select_target_Yn": "Le tirant d'eau normal (m)", - "select_target_Yf": "Le tirant d'eau fluvial (m)", - "select_target_Yt": "Le tirant d'eau torrentiel (m)", - "select_target_Yco": "Le tirant d'eau conjugué (m)", - "select_target_J": "La perte de charge (m)", - "select_target_I-J": "Variation linéaire de l'énergie spécifique (m/m)", - "select_target_Imp": "Impulsion (N)", - "select_target_Tau0": "La force tractrice (Pa)", - "Hs": "Charge spécifique", "Hsc": "Charge critique", "B": "Largeur au miroir", -- GitLab From a621a658a21abae05d07a4c4ae0d2e7cd67e5a29 Mon Sep 17 00:00:00 2001 From: "mathias.chouet" <mathias.chouet@irstea.fr> Date: Fri, 26 Jul 2019 15:32:38 +0200 Subject: [PATCH 13/13] Update protracto config and e2e tests --- e2e/cloisons.e2e-spec.ts | 2 +- e2e/link-parallel-devices.e2e-spec.ts | 6 +++--- e2e/load-linked-params.e2e-spec.ts | 4 ---- e2e/load-save-session.e2e-spec.ts | 4 ++-- protractor.conf.js | 11 ++++++++++- 5 files changed, 16 insertions(+), 11 deletions(-) diff --git a/e2e/cloisons.e2e-spec.ts b/e2e/cloisons.e2e-spec.ts index d3f0fc4f2..3bbdbd921 100644 --- a/e2e/cloisons.e2e-spec.ts +++ b/e2e/cloisons.e2e-spec.ts @@ -37,7 +37,7 @@ describe("ngHyd − cloisons", () => { await browser.sleep(300); // 4. change LoiDebit - await calcPage.changeSelectValue(calcPage.getSelectById("select_loidebit1"), 1); + await calcPage.changeSelectValue(calcPage.getSelectById("select_loidebit"), 1); await browser.sleep(300); // 5. check number of inputs in CALC mode diff --git a/e2e/link-parallel-devices.e2e-spec.ts b/e2e/link-parallel-devices.e2e-spec.ts index d12fb0f7b..2b6c3ae58 100644 --- a/e2e/link-parallel-devices.e2e-spec.ts +++ b/e2e/link-parallel-devices.e2e-spec.ts @@ -21,14 +21,14 @@ describe("ngHyd − parallel structures with multiple linked parameters − ", ( await listPage.clickMenuEntryForCalcType(8); await calcPage.getAddStructureButton().click(); const nb1 = await calcPage.getAllLinkButtons().count(); - expect(nb1).toBe(10); // link buttons on children but not on parent + expect(nb1).toBe(8); // link buttons on children but not on parent // 2. check Passe à bassin: Cloisons await startPage.navigateTo(); await listPage.clickMenuEntryForCalcType(10); await calcPage.getAddStructureButton().click(); const nb2 = await calcPage.getAllLinkButtons().count(); - expect(nb2).toBe(4); // link buttons on children but not on parent + expect(nb2).toBe(6); // link buttons on children but not on parent // 3. check Lois de déversoirs dénoyés @@ -36,7 +36,7 @@ describe("ngHyd − parallel structures with multiple linked parameters − ", ( await listPage.clickMenuEntryForCalcType(9); await calcPage.getAddStructureButton().click(); const nb3 = await calcPage.getAllLinkButtons().count(); - expect(nb3).toBe(4); // link buttons on children but not on parent + expect(nb3).toBe(6); // link buttons on children but not on parent }); }); diff --git a/e2e/load-linked-params.e2e-spec.ts b/e2e/load-linked-params.e2e-spec.ts index a26bb90c8..d86065525 100644 --- a/e2e/load-linked-params.e2e-spec.ts +++ b/e2e/load-linked-params.e2e-spec.ts @@ -79,10 +79,6 @@ describe("ngHyd − load session with multiple linked parameters − ", () => { const lo_wv = await calcPage.getSelectValueText(lo_w); expect(lo_wv).toContain("Ouverture de vanne (Ouvrages, ouvrage 2)"); - const lo_cd = calcPage.getSelectById("2_linked_Cd"); - const lo_cdv = await calcPage.getSelectValueText(lo_cd); - expect(lo_cdv).toContain("Coefficient de débit (Ouvrages, ouvrage 1)"); - // 4. check Régime uniforme await navbar.clickCalculatorTab(3); await browser.sleep(500); diff --git a/e2e/load-save-session.e2e-spec.ts b/e2e/load-save-session.e2e-spec.ts index 4badbd456..54e736808 100644 --- a/e2e/load-save-session.e2e-spec.ts +++ b/e2e/load-save-session.e2e-spec.ts @@ -59,7 +59,7 @@ describe("ngHyd − save and load sessions", () => { await listPage.clickMenuEntryForCalcType(2); // Section paramétrée await browser.sleep(500); - await calcPage.changeSelectValue(calcPage.getSelectById("select_section"), 2); // mode "circulaire" + await calcPage.changeSelectValue(calcPage.getSelectById("select_section"), 2); // mode "trapezoidal" await calcPage.getInputById("Ks").clear(); // coefficient de Strickler await browser.sleep(1000); @@ -83,7 +83,7 @@ describe("ngHyd − save and load sessions", () => { const fileContent = fs.readFileSync(filename, { encoding: "utf8" }); // tslint:disable-next-line:quotemark - expect(fileContent).toContain('"nodeType":3'); + expect(fileContent).toContain('"nodeType":1'); // tslint:disable-next-line:quotemark expect(fileContent).toContain('{"symbol":"Ks","mode":"SINGLE","value":42}'); }); diff --git a/protractor.conf.js b/protractor.conf.js index 1ef2cb870..6c546c716 100644 --- a/protractor.conf.js +++ b/protractor.conf.js @@ -3,6 +3,11 @@ const { SpecReporter } = require('jasmine-spec-reporter'); +const path = require("path"); +const os = require("os"); + +const downloadsPath = path.resolve(os.homedir(), "Téléchargements"); + exports.config = { allScriptsTimeout: 11000, specs: [ @@ -16,7 +21,7 @@ exports.config = { download: { prompt_for_download: false, directory_upgrade: true, - default_directory: '/tmp/e2e-downloads' + // default_directory: '/tmp/e2e-downloads' }, }, }, @@ -35,5 +40,9 @@ exports.config = { }); jasmine.getEnv().addReporter(new SpecReporter({ spec: { displayStacktrace: true } })); browser.manage().window().setSize(1600, 1000); + browser.driver.sendChromiumCommand('Page.setDownloadBehavior', { + behavior: 'allow', + downloadPath: downloadsPath + }); } }; -- GitLab