Commit 1f5b7cb6 authored by Mathias Chouet's avatar Mathias Chouet :spaghetti:
Browse files

Fix #459 - empty fields: preserve default calculated param

Showing with 9 additions and 1 deletion
+9 -1
......@@ -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();
}
/**
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment