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

refactor: SelectFieldNubProperty: move configuration parsing out of constructor

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