From 02af2612f4e6c80906b45b31654ee9ceed8d401d Mon Sep 17 00:00:00 2001 From: "francois.grand" <francois.grand@irstea.fr> Date: Thu, 19 Apr 2018 15:14:09 +0200 Subject: [PATCH] #77 FieldSet.setPropValue() : utilisation de la classe de la lib StructureProperties --- src/app/formulaire/fieldset.ts | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/app/formulaire/fieldset.ts b/src/app/formulaire/fieldset.ts index 3b098f78a..3a78e8802 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; } -- GitLab