diff --git a/src/app/formulaire/fieldset.ts b/src/app/formulaire/fieldset.ts index 3b098f78ae160580bb30bf1f0655b253570bd64e..3a78e880289ab5522361634d093818ffa94fbb10 100644 --- a/src/app/formulaire/fieldset.ts +++ b/src/app/formulaire/fieldset.ts @@ -1,4 +1,4 @@ -import { CalculatorType, ComputeNodeType, ParamDefinition, LoiDebit, StructureType, Props, loiAdmissibles, SessionNub } from "jalhyd"; +import { CalculatorType, ComputeNodeType, ParamDefinition, LoiDebit, StructureType, Props, SessionNub, StructureProperties } from "jalhyd"; import { FormulaireElement } from "./formulaire-element"; import { Dependency } from "./dependency/dependency"; @@ -122,12 +122,13 @@ export class FieldSet extends FormulaireElement implements Observer { // si prop=type d'ouvrage, on prend une loi de débit compatible avec (spécifique aux ouvrages //) comme valeur par défaut if (key === "structureType") { - { - const sst: string = StructureType[val]; - const ld: LoiDebit = loiAdmissibles[sst][0]; - this.setPropValue("loiDebit", ld); - } + if (!StructureProperties.isCompatibleValues(val, this.getPropValue("loiDebit"))) + this.setPropValue("loiDebit", StructureProperties.findCompatibleLoiDebit(val)); } + // si prop=loi débit, on prend un type d'ouvrage compatible + else if (key === "loiDebit") + if (!StructureProperties.isCompatibleValues(this.getPropValue("structureType"), val)) + this.setPropValue("structureType", StructureProperties.findCompatibleStructure(val)); } return changed; }