diff --git a/src/app/calculators/cloisons/cloisons.config.json b/src/app/calculators/cloisons/cloisons.config.json index 43f69863cfc0b1c878ca22522c07dfa0f97a9219..fe39ea7f1c41674858603b82757384d872a8c422 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 d4ebc675d9953f3535162f4b51a51b13b85b41e8..27563717a6f8b82f65399c1acbf7946dfe80d010 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 c49fe100c08550d6d97747427505857df38ab4d6..501eb6e78b3192dc7312027a728767c18ef2fa94 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 3505e8fa8587876de2a6a3a8a5555777a7095c1a..dcb289eec0ebfaef5dddbfe3b7472450e5cdb68a 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 0f5f9b00a4567d5cceaea451fd003f99bf7b484a..5c7dc996841663f05fe2c0ca14506340e97fda3b 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 f45e9317b576d3f98c97a49eaacf24825d1ef709..acdd425b74c8bcaaae37d43a4685a7869bb046ab 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 88837dddf08f536125694f8aa0dd2941c9894f04..0dc5a67245688b1e6e25f9f664300d4e13debc48 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 983a87bbff63d6411a2bc2d61aaf96f90e1591fe..152afc882b3e60c2ba3877e90981b274197aacc0 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 3cf2766c712db19ba6bfc0636d6c0b75282e8808..d7e9228a521131ac352abc26c262ac96d8b1b2e0 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 1e7ae82cd9dd0933eb65fd91f531a6172e576efa..2028b9a1988d0efabf455dfc321d90fe709bd598 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 a1ea704a2289e17d0f05f2928de144894af7e896..1fb0a205eb9e6d366eb680037e25f32641dc2858 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 e976dfaf1ebe34f225451294e0e000b340ef37ae..393a1f3a6934e1e1b8fd1e1872587a251e46e8a6 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 99163d72f33f32e906492292e079a8b3945ba15a..a87ad77e0371434ed810f979edf108e8591ab227 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 41a03556a87f154fd62deed7da6018fe52adee1e..b92c518768d0d9c1aa34f66256edc0e6a210dd85 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 e888256e41c6597e1b0066241301cd28d35d19a0..01b95f3373c7f1379643770d6a65861db445ce7b 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 46d010e42c66e1f5f94537db5404bb9e4e33519f..c10a48d45996f9e5fb0155b417e6fd312e5a8580 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