From 3b748aecd2e838c3df34a792cbe3583da6c684c4 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Fran=C3=A7ois=20Grand?= <francois.grand@inrae.fr>
Date: Fri, 27 Jan 2023 14:35:23 +0100
Subject: [PATCH] refactor: remove FormulaireSection._defaultSectionType
 member, use defaultProperties instead

refs #592
---
 src/app/formulaire/definition/form-section.ts | 10 ++++------
 1 file changed, 4 insertions(+), 6 deletions(-)

diff --git a/src/app/formulaire/definition/form-section.ts b/src/app/formulaire/definition/form-section.ts
index 8f8be0af9..bf06c16b2 100644
--- a/src/app/formulaire/definition/form-section.ts
+++ b/src/app/formulaire/definition/form-section.ts
@@ -7,16 +7,14 @@ import { SectionType } from "jalhyd";
 
 export class FormulaireSection extends FormulaireFixedVar {
 
-    /** for SectionNubs only */
-    protected _defaultSectionType;
-
     /**
      * determine default section type from select configuration
      */
     private parseDefaultSectionType() {
-        if (this._defaultSectionType === undefined) {
+        if (this.defaultProperties["nodeType"] === undefined) // still use "nodeType" for consistency, should be named "sectionType"
+        {
             const def = this.parseSelectDefaultValue(this._jsonConfig, "select_section");
-            this._defaultSectionType = SectionType[def];
+            this.defaultProperties["nodeType"] = SectionType[def];
         }
     }
 
@@ -31,7 +29,7 @@ export class FormulaireSection extends FormulaireFixedVar {
             // add new Section as first child, from given nodeType
             const propsSection = new Props();
             propsSection.setPropValue("calcType", CalculatorType.Section);
-            propsSection.setPropValue("nodeType", this._defaultSectionType);
+            propsSection.setPropValue("nodeType", this.defaultProperties["nodeType"]);
             propsSection.setPropValue(Prop_NullParameters, ServiceFactory.applicationSetupService.enableEmptyFieldsOnFormInit);
             const section = Session.getInstance().createNub(propsSection);
             this.currentNub.setSection(section as acSection);
-- 
GitLab