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

refactor: SelectFieldNubProperty: move configuration parsing out of constructor

refs #483
parent 8d20a544
No related branches found
No related tags found
No related merge requests found
......@@ -111,6 +111,7 @@ export class FieldSet extends FormulaireElement implements Observer {
private parse_select(json: {}): SelectField {
const res: SelectField = SelectFieldFactory.newSelectField(json, this);
res.parseConfig(json);
res.afterParseConfig();
res.addObserver(this);
return res;
}
......
......@@ -57,10 +57,10 @@ export class SelectFieldFactory {
case "select_section":
case "select_sppoperation":
case "select_unit":
return new SelectFieldNubProperty(parent, json);
return new SelectFieldNubProperty(parent);
default:
throw new Error("unknown select id ${id}");
}
}
}
\ No newline at end of file
}
......@@ -15,8 +15,12 @@ import { SelectField } from "./select-field";
// nub property values taken from an enum
// "standard" select that normally does not require customisation
export class SelectFieldNubProperty extends SelectField {
constructor(parent: FormulaireNode, json: {}) {
constructor(parent: FormulaireNode) {
super(parent);
}
public parseConfig(json: {}, data?: {}) {
super.parseConfig(json, data);
this._associatedProperty = json["property"];
this._configDefaultValue = json["default"];
}
......@@ -35,4 +39,4 @@ export class SelectFieldNubProperty extends SelectField {
protected initSelectedValue() {
this.findAndSetDefaultValue();
}
}
\ No newline at end of file
}
......@@ -143,7 +143,7 @@ export abstract class SelectField extends Field {
this._confId = field["id"];
this._entriesBaseId = this._confId + "_";
this._helpLink = field["help"];
this.afterParseConfig();
//this.afterParseConfig(); // done in FieldSet.parse_select()
}
/**
......@@ -151,7 +151,7 @@ export abstract class SelectField extends Field {
* (needs config for this._entriesBaseId to be set).
* Triggered at the end of parseConfig()
*/
protected afterParseConfig() {
public afterParseConfig() {
this.populate();
this.initSelectedValue();
}
......
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