diff --git a/src/app/calculators/section-param/section-param.config.json b/src/app/calculators/section-param/section-param.config.json index eaf075531f98fb1c951aa0cf7301cea462ee4081..9ed84e745dfee2acba94fa0222a12010ec2c80e5 100644 --- a/src/app/calculators/section-param/section-param.config.json +++ b/src/app/calculators/section-param/section-param.config.json @@ -2,6 +2,8 @@ { "id": "fs_section", "type": "fieldset", + "defaultNodeType": "SectionTrapeze", + "option": "var", "fields": [ { "id": "select_section", @@ -24,100 +26,85 @@ "enum": "ComputeNodeType.SectionPuissance" } ] - } - ] - }, - { - "id": "fs_section_trapez", - "type": "fieldset", - "option": "var", - "dep_exist": [ - { - "refid": "select_section", - "refvalue": "select_section_trapez" - } - ], - "fields": [ + }, { "type": "input", "id": "LargeurFond", + "unit": "m", "nodeType": "SectionTrapeze", - "unit": "m" + "dep_exist": [ + { + "refid": "select_section", + "refvalue": "select_section_trapez" + } + ] }, { "type": "input", "id": "Fruit", "nodeType": "SectionTrapeze", - "unit": "m/m" - } - ] - }, - { - "id": "fs_section_rect", - "type": "fieldset", - "option": "var", - "dep_exist": [ - { - "refid": "select_section", - "refvalue": "select_section_rect" - } - ], - "fields": [ + "unit": "m/m", + "dep_exist": [ + { + "refid": "select_section", + "refvalue": "select_section_trapez" + } + ] + }, { "type": "input", "id": "LargeurBerge", + "unit": "m", "nodeType": "SectionRectangle", - "unit": "m" - } - ] - }, - { - "id": "fs_section_circ", - "type": "fieldset", - "option": "var", - "dep_exist": [ - { - "refid": "select_section", - "refvalue": "select_section_circ" - } - ], - "fields": [ + "dep_exist": [ + { + "refid": "select_section", + "refvalue": "select_section_rect" + } + ] + }, { "type": "input", "id": "D", + "unit": "m", "nodeType": "SectionCercle", - "unit": "m" - } - ] - }, - { - "id": "fs_section_puissance", - "type": "fieldset", - "option": "var", - "dep_exist": [ - { - "refid": "select_section", - "refvalue": "select_section_puiss" - } - ], - "fields": [ + "dep_exist": [ + { + "refid": "select_section", + "refvalue": "select_section_circ" + } + ] + }, { "type": "input", "id": "k", + "unit": "", "nodeType": "SectionPuissance", - "unit": "" + "dep_exist": [ + { + "refid": "select_section", + "refvalue": "select_section_puiss" + } + ] }, { "type": "input", "id": "LargeurBerge", + "unit": "m", "nodeType": "SectionPuissance", - "unit": "m" + "dep_exist": [ + { + "refid": "select_section", + "refvalue": "select_section_puiss" + } + ] } ] }, { "id": "fs_bief", "type": "fieldset", + "defaultNodeType": "SectionTrapeze", "option": "var", "fields": [ { @@ -140,6 +127,7 @@ { "id": "fs_hydraulique", "type": "fieldset", + "defaultNodeType": "SectionTrapeze", "option": "var", "fields": [ { @@ -157,6 +145,7 @@ { "id": "fs_param_calc", "type": "fieldset", + "defaultNodeType": "SectionTrapeze", "option": "fix", "fields": [ { @@ -168,6 +157,7 @@ { "id": "fs_computed_var", "type": "fieldset", + "defaultNodeType": "SectionTrapeze", "dep_exist": [ { "refid": "LargeurFond", diff --git a/src/app/formulaire/fieldset.ts b/src/app/formulaire/fieldset.ts index 9e7f18af53c3ba5e7d7ed7f7cd28586892763946..5edca538bc0f6f4773702f5847f56d233bf07376 100644 --- a/src/app/formulaire/fieldset.ts +++ b/src/app/formulaire/fieldset.ts @@ -194,9 +194,15 @@ export class FieldSet extends FormulaireElement implements Observer { const nt: string = json["nodeType"]; let nodeType: ComputeNodeType = nt == undefined ? this.getPropValue("nodeType") : ComputeNodeType[nt]; - const nubParam: ParamDefinition = this.getNubParamFromSymbol(input_id); - if (nubParam) - res = new NgParameter(nubParam, this); + if (nodeType === this.getPropValue("nodeType")) { // si le nodeType du paramètre est le même que celui du fieldset + try { + var nubParam: ParamDefinition = this.getNubParamFromSymbol(input_id); + } + catch (e) { + } + if (nubParam) + res = new NgParameter(nubParam, this); + } } if (res) @@ -290,6 +296,13 @@ export class FieldSet extends FormulaireElement implements Observer { break; } } + else if (this._confId === "fs_section") { + const sf: SelectField = this.getFormulaireNodeById("select_section") as SelectField; + const nt: ComputeNodeType = this.getPropValue("nodeType"); + const se = sf.getSelectedEntryFromValue(nt); + sf.setValue(se); + } + // fin MAJ selects @@ -398,15 +411,16 @@ export class FieldSet extends FormulaireElement implements Observer { update(sender: any, data: any) { if (data.action && data.action === "select") { let update = false; - if (data.value.id.indexOf("select_ouvrage") != -1) + if (data.value.id.indexOf("select_section_") != -1) // sections paramétrées + update = update || this.setPropValue("nodeType", data.value.value); + if (data.value.id.indexOf("select_ouvrage") != -1) // ouvrages parallèles update = update || this.setPropValue("structureType", data.value.value); - else if (data.value.id.indexOf("select_loidebit1") != -1) + else if (data.value.id.indexOf("select_loidebit1") != -1) // ouvrages parallèles update = update || this.setPropValue("loiDebit", data.value.value); - else if (data.value.id.indexOf("select_loidebit2") != -1) + else if (data.value.id.indexOf("select_loidebit2") != -1) // ouvrages parallèles update = update || this.setPropValue("loiDebit", data.value.value); if (update) { - console.log("--select"); this.updateFields(); this._parentForm.reset(); }