From 07a3610666b40845b94e827c47d275ed3f3378fe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois=20Grand?= <francois.grand@inrae.fr> Date: Mon, 6 Feb 2023 16:48:25 +0100 Subject: [PATCH] refactor: FieldSet: remove inSection parameter from setSelectValueFromProperty(), getPropValue() refs #596 --- src/app/formulaire/elements/fieldset.ts | 19 +++++-------------- 1 file changed, 5 insertions(+), 14 deletions(-) diff --git a/src/app/formulaire/elements/fieldset.ts b/src/app/formulaire/elements/fieldset.ts index 3637d892d..fb871cb36 100644 --- a/src/app/formulaire/elements/fieldset.ts +++ b/src/app/formulaire/elements/fieldset.ts @@ -205,7 +205,7 @@ export class FieldSet extends FormulaireElement implements IProperties { if (this.parentForm instanceof FormulaireFixedVar) { for (const sel of this.parentForm.allSelectFields) { if (sel.hasAssociatedNubProperty) { // ie. if select is a standard select - this.setSelectValueFromProperty(sel.id, (this._confId === "fs_section")); + this.setSelectValueFromProperty(sel.id); } } } @@ -213,12 +213,11 @@ export class FieldSet extends FormulaireElement implements IProperties { /** * Reflects a property value in the interface, through the value of a <select> field, if this select exists - * @param inSection if true, will look for the required property in the Nub's section (children[0]) */ - private setSelectValueFromProperty(selectId: string, inSection: boolean = false) { + private setSelectValueFromProperty(selectId: string) { const selectField: SelectField = this.getFormulaireNodeById(selectId) as SelectField; if (selectField) { - let propVal: any = this.getPropValue(selectField.associatedProperty, inSection); + let propVal: any = this.getPropValue(selectField.associatedProperty); if (propVal === undefined) { propVal = ""; // clodo bullet-proof loading } @@ -327,7 +326,7 @@ export class FieldSet extends FormulaireElement implements IProperties { if (senderId === "select_section") { // sections paramétrées, courbes de remous, régimes uniformes // "nodeType" is a property of the section child, not of the parent - const oldNodeType = this.nub.getChildren()[0].getPropValue("nodeType"); + const oldNodeType = this.getPropValue("nodeType"); if (oldNodeType !== data.value.value) { // avoid infinite loops // manually notify parent so that it replaces the child Nub @WARNING clodo trick this.parentForm.update(this, { @@ -379,16 +378,8 @@ export class FieldSet extends FormulaireElement implements IProperties { /** * get associated nub property value * @param key property name - * @param inSection if true, will look for the required property in the Nub's section (children[0]) */ - public getPropValue(key: string, inSection: boolean = false): any { - if (inSection) { - const section = this.nub.getChildren()[0]; - if (section) { - return section.getPropValue(key); - } - return undefined; - } + public getPropValue(key: string): any { return this.nub.getPropValue(key); } -- GitLab