From 832055795578a403a6c9cb3d62c22847aa07be9d Mon Sep 17 00:00:00 2001
From: Mathias Chouet <mathias.chouet@irstea.fr>
Date: Wed, 15 Apr 2020 11:25:27 +0200
Subject: [PATCH] Fix #388 - empty fields when changing section type, too

---
 src/app/formulaire/definition/form-section.ts | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/src/app/formulaire/definition/form-section.ts b/src/app/formulaire/definition/form-section.ts
index bd1685b44..db63b5a1d 100644
--- a/src/app/formulaire/definition/form-section.ts
+++ b/src/app/formulaire/definition/form-section.ts
@@ -1,5 +1,6 @@
 import { FormulaireFixedVar } from "./form-fixedvar";
 import { FieldSet } from "../elements/fieldset";
+import { ServiceFactory } from "../../services/service-factory";
 
 import { IObservable, Session, SectionNub } from "jalhyd";
 
@@ -17,6 +18,11 @@ export class FormulaireSection extends FormulaireFixedVar {
                 // show / hide dependent fields
                 fs.updateFields();
             }
+            // empty fields ? only those belonging to the specific section type
+            if (ServiceFactory.instance.applicationSetupService.enableEmptyFieldsOnFormInit) {
+                // "LargeurBerge" is hackily used as LargeurFond in Rectangular and Trapez sections, omit it here
+                this.emptyFields([ "Ks", "Q", "If", "YB", "iPrec", "Y" ]);
+            }
             this.reset();
         }
     }
-- 
GitLab