diff --git a/src/app/formulaire/elements/formulaire-node.ts b/src/app/formulaire/elements/formulaire-node.ts index 9a2e5e3c4624b45ceb1294cb9b07ff36da0bcff0..03b41d08dd0efcae2649a6fbed227f35f3a12aed 100644 --- a/src/app/formulaire/elements/formulaire-node.ts +++ b/src/app/formulaire/elements/formulaire-node.ts @@ -144,16 +144,24 @@ export abstract class FormulaireNode implements IObservable { * Set value of all single parameters to undefined, except for the given parameter ids */ public emptyFields(except: string[] = [ "Cd0", "CdWS", "CdGR", "CdGRS", "CdCunge", "CdWR", "CdO", "CdT", "CdWSL" ]) { - for (const p of this.allFormElements ) { + // save current calculated param, as setting value on a CALC param will + // change its mode and choose another calculated param by default + let calcP: NgParameter; + for (const p of this.allFormElements) { if (p instanceof NgParameter) { if ( [ ParamValueMode.SINGLE, ParamValueMode.CALCUL ].includes(p.valueMode) && ! except.includes(p.id) ) { + if (p.valueMode === ParamValueMode.CALCUL) { + calcP = p; + } p.setValue(this, undefined); } } } + // restore original calculated param + calcP.setCalculated(); } /**