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

refactor: FieldSet: only update own select fields, not all form select fields

parent d74e9a8c
No related branches found
No related tags found
1 merge request!224Resolve "Utiliser des identifiants symboliques plutôt que numériques dans les fichiers"
......@@ -16,6 +16,7 @@ import { FieldsetContainer } from "./fieldset-container";
import { SelectFieldFactory } from "./select/select-field-factory";
import { FormulaireFixedVar } from "../definition/form-fixedvar";
import { SelectEntry } from "./select/select-entry";
import { DeepSelectFieldIterator } from "../form-iterator/deep-selectfield-iterator";
export class FieldSet extends FormulaireElement implements IProperties {
......@@ -223,11 +224,9 @@ export class FieldSet extends FormulaireElement implements IProperties {
// for all select fields known by the form, set selected value
// from associated property
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);
}
for (const sel of this.allSelectFields) {
if (sel.hasAssociatedNubProperty) { // ie. if select is a standard select
this.setSelectValueFromProperty(sel.id);
}
}
}
......@@ -276,16 +275,14 @@ export class FieldSet extends FormulaireElement implements IProperties {
// for all select fields known by the form, apply default value
// to associated property, usually from associated enum
if (this.parentForm instanceof FormulaireFixedVar) {
for (const sel of this.parentForm.allSelectFields) {
if (sel.hasAssociatedNubProperty) { // ie. if select is a standard select
const prop = sel.associatedProperty;
const defaultValue = sel.configDefaultValue;
// Sets Nub default property, unless this property is already set
const currentValue = this.getPropValue(prop);
if (defaultValue !== undefined && currentValue === undefined) {
this.setPropValue(prop, enumValueFromString(prop, defaultValue));
}
for (const sel of this.allSelectFields) {
if (sel.hasAssociatedNubProperty) { // ie. if select is a standard select
const prop = sel.associatedProperty;
const defaultValue = sel.configDefaultValue;
// Sets Nub default property, unless this property is already set
const currentValue = this.getPropValue(prop);
if (defaultValue !== undefined && currentValue === undefined) {
this.setPropValue(prop, enumValueFromString(prop, defaultValue));
}
}
}
......@@ -312,6 +309,13 @@ export class FieldSet extends FormulaireElement implements IProperties {
}
}
/**
* itère sur tous les SelectField
*/
public get allSelectFields(): IterableIterator<SelectField> {
return new DeepSelectFieldIterator(this);
}
// interface Observer
update(sender: any, data: any) {
......
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