Skip to content
Snippets Groups Projects
Commit 07a36106 authored by François Grand's avatar François Grand
Browse files

refactor: FieldSet: remove inSection parameter from setSelectValueFromProperty(), getPropValue()

refs #596
parent a7d8b1cf
No related branches found
No related tags found
2 merge requests!225Release v4.17.0,!200Resolve "Conduites en charge : ajouter loi de Strickler"
......@@ -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);
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment