diff --git a/src/app/formulaire/definition/concrete/form-parallel-structures.ts b/src/app/formulaire/definition/concrete/form-parallel-structures.ts index 32bf51d115ce7cb60a4e231471dee9cf52e635fd..dae370e9809092225402365a3afe1ffb32514958 100644 --- a/src/app/formulaire/definition/concrete/form-parallel-structures.ts +++ b/src/app/formulaire/definition/concrete/form-parallel-structures.ts @@ -40,11 +40,17 @@ export class FormulaireParallelStructure extends FormulaireDefinition { } private createStructNub(templ: FieldsetTemplate): SessionNub { - // valeurs par défaut de CalculatorType, ComputeNodeType, StructureType, LoiDebit - // !!! attention !!! pour l'instant, il doit y avoir cohérence entre ces valeurs et celles du fichier de conf + // !!! attention !!! + // Il doit y avoir cohérence dans le fichier de conf entre les valeurs defaultXXX et les valeurs possibles pour les select // cad valeur par défaut du 1er select (type d'ouvrage), du 2ème (loi de débit). // A terme, il faudrait analyser le fichier de conf (dépendances d'existence) pour déterminer automatiquement ces valeurs - const params = FieldSet.makeDefaultProps(templ.calcTypeFromConfig, templ.defaultNodeTypeFromConfig); + + const params = {}; + params["calcType"] = templ.calcTypeFromConfig; + params["nodeType"] = templ.defaultNodeTypeFromConfig; + params["structureType"] = templ.defaultStructTypeFromConfig; + params["loiDebit"] = templ.defaultLoiDebitFromConfig; + return this.createSessionNub(params); } diff --git a/src/app/formulaire/fieldset-template.ts b/src/app/formulaire/fieldset-template.ts index ce3fcf353158e5e5afb82accafa73bfeda2b1d08..8ba2da3baa568038c0bc654eb78ff2e84c8eb318 100644 --- a/src/app/formulaire/fieldset-template.ts +++ b/src/app/formulaire/fieldset-template.ts @@ -1,5 +1,5 @@ import { FieldSet } from "./fieldset"; -import { CalculatorType, ComputeNodeType } from "jalhyd"; +import { CalculatorType, ComputeNodeType, StructureType, LoiDebit } from "jalhyd"; import { FormulaireDefinition } from "./definition/form-definition"; import { FieldsetContainer } from "./fieldset-container"; @@ -15,27 +15,23 @@ export class FieldsetTemplate { } public get calcTypeFromConfig(): CalculatorType { - for (const k in this._jsonConfig) { - if (k === "calcType") { - const ct: string = this._jsonConfig[k]; - var calcType: CalculatorType = CalculatorType[ct]; - break; - } - } - - return calcType; + const ct: string = this._jsonConfig["calcType"]; + return CalculatorType[ct]; } public get defaultNodeTypeFromConfig(): ComputeNodeType { - for (const k in this._jsonConfig) { - if (k === "defaultNodeType") { - const nt: string = this._jsonConfig[k]; - var nodeType: ComputeNodeType = ComputeNodeType[nt]; - break; - } - } - - return nodeType; + const nt: string = this._jsonConfig["defaultNodeType"]; + return ComputeNodeType[nt]; + } + + public get defaultStructTypeFromConfig(): StructureType { + const st: string = this._jsonConfig["defaultStructType"]; + return StructureType[st]; + } + + public get defaultLoiDebitFromConfig(): LoiDebit { + const ld: string = this._jsonConfig["defaultLoiDebit"]; + return LoiDebit[ld]; } /** diff --git a/src/app/formulaire/fieldset.ts b/src/app/formulaire/fieldset.ts index fefcb06c40b79cb44a24b99752aab5f3e4cf97a7..af553da83b6dd95dc4862dada03a2ecbeffe0d84 100644 --- a/src/app/formulaire/fieldset.ts +++ b/src/app/formulaire/fieldset.ts @@ -121,39 +121,6 @@ export class FieldSet extends FormulaireElement implements Observer { return this._props.setPropValue(key, val, this); } - /** - * valeurs par défaut pour StructureType, LoiDebit en fonction d'un ComputeNodeType - */ - private static defaultProps(nodeType: ComputeNodeType): [StructureType, LoiDebit] { - let structType: StructureType; - let loiDebit: LoiDebit - switch (nodeType) { - case ComputeNodeType.StructureRectangle: - structType = StructureType.VanneRectangulaire; - loiDebit = LoiDebit.Cem88v; - break; - } - return [structType, loiDebit]; - } - - /** - * crée un objet Props servant de filtre pour sélectionner un Nub - * @param calcType - * @param nodeType - */ - public static makeDefaultProps(calcType: CalculatorType, nodeType: ComputeNodeType): Props { - const res: Props = new Props(); - - res.setPropValue("calcType", calcType); - res.setPropValue("nodeType", nodeType); - - const p: [StructureType, LoiDebit] = FieldSet.defaultProps(nodeType); - res.setPropValue("structureType", p[0]); - res.setPropValue("loiDebit", p[1]); - - return res; - } - private getNubParamFromSymbol(symbol: string): ParamDefinition { return this._sessionNub.nub.getParameter(symbol); }