From 741755ae07e52d5d7eec31ca16941499b27ad537 Mon Sep 17 00:00:00 2001 From: "francois.grand" <francois.grand@irstea.fr> Date: Thu, 19 Apr 2018 15:22:00 +0200 Subject: [PATCH] =?UTF-8?q?=20#77=20r=C3=A9organisation=20de=20la=20calcul?= =?UTF-8?q?ette=20sections=20param=C3=A9tr=C3=A9es=20pour=20coller=20au=20?= =?UTF-8?q?mod=C3=A8le=20des=20ouvrages=20parall=C3=A8les,=20cad=20qu'il?= =?UTF-8?q?=20n'y=20a=20plus=20un=20fieldset=20avec=20un=20select=20seul?= =?UTF-8?q?=20(d=C3=A9plac=C3=A9=20dans=20le=20fieldset=20des=20param?= =?UTF-8?q?=C3=A8tres=20sp=C3=A9cifiques=20de=20la=20section)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../section-param/section-param.config.json | 114 ++++++++---------- src/app/formulaire/fieldset.ts | 28 +++-- 2 files changed, 73 insertions(+), 69 deletions(-) diff --git a/src/app/calculators/section-param/section-param.config.json b/src/app/calculators/section-param/section-param.config.json index eaf075531..9ed84e745 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 9e7f18af5..5edca538b 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(); } -- GitLab