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

fix: standard select defaut value from calculator configuration not honored

refs #483
parent d816e82b
No related branches found
No related tags found
2 merge requests!225Release v4.17.0,!176Resolve "Fusionner les "select" avec "source" et les "select_custom""
......@@ -4,7 +4,7 @@ import {
Props,
Observer,
Nub,
Session,
enumValueFromString
} from "jalhyd";
import { FormulaireElement } from "./formulaire-element";
......@@ -295,13 +295,7 @@ export class FieldSet extends FormulaireElement implements Observer {
// Sets Nub default property, unless this property is already set
const currentValue = this.properties.getPropValue(prop);
if (defaultValue !== undefined && currentValue === undefined) {
let formalValue = defaultValue;
// !! property names must be unique throughout JaLHyd !!
const enumClass = Session.enumFromProperty[prop];
if (enumClass) {
formalValue = enumClass[defaultValue];
}
this.setNubPropValue(prop, formalValue);
this.setNubPropValue(prop, enumValueFromString(prop, defaultValue));
}
}
}
......
......@@ -4,7 +4,7 @@ import { arraysAreEqual } from "../../../util";
import { FormulaireNode } from "../formulaire-node";
import { ServiceFactory } from "app/services/service-factory";
import { FormulaireDefinition } from "../../definition/form-definition";
import { Nub } from "jalhyd";
import { enumValueFromString, Nub } from "jalhyd";
export abstract class SelectField extends Field {
......@@ -128,10 +128,16 @@ export abstract class SelectField extends Field {
protected findAndSetDefaultValue() {
// default to first available entry if any
if (this._entries.length > 0) {
let val;
if (this._configDefaultValue === undefined) {
val = this._entries[0];
} else {
val = this.getEntryFromValue(enumValueFromString(this._associatedProperty, this._configDefaultValue));
}
if (this._multiple) {
this.setValue([this._entries[0]]);
this.setValue([val]);
} else {
this.setValue(this._entries[0]);
this.setValue(val);
}
} else {
// notify observers that no value is selected anymore
......
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