diff --git a/src/app/formulaire/definition/form-pressureloss.ts b/src/app/formulaire/definition/form-pressureloss.ts index 60c98da99b692a86de8de20bc0025ff96d6327c6..4b1e7ceb4188e1d4cb2d4f4caf03b4da1f827b80 100644 --- a/src/app/formulaire/definition/form-pressureloss.ts +++ b/src/app/formulaire/definition/form-pressureloss.ts @@ -1,4 +1,4 @@ -import { PressureLoss, Props, PressureLossType } from "jalhyd"; +import { PressureLoss, Props, PressureLossType, Session, PressureLossLaw, CalculatorType } from "jalhyd"; import { FormulaireFixedVar } from "./form-fixedvar"; /** @@ -17,8 +17,19 @@ export class FormulairePressureLoss extends FormulaireFixedVar { if (props === undefined) { props = new Props(); } + + // create pressure loss parent nub + const pll = this.defaultProperties["pressureLossType"]; props.setPropValue("calcType", this.calculatorType); - props.setPropValue("pressureLossType", this.defaultProperties["pressureLossType"]); + props.setPropValue("pressureLossType", pll); super.initNub(props); + + // create pressure loss law child nub + const propsLaw: Props = new Props(); + const pressureLossCalc: CalculatorType = PressureLossLaw.calcTypeFromPressureLossLaw[pll]; + propsLaw.setPropValue("calcType", pressureLossCalc); + const law = Session.getInstance().createNub(propsLaw) as PressureLossLaw; + const pl: PressureLoss = this.currentNub as PressureLoss; + pl.setLaw(law); } }