Skip to content
Snippets Groups Projects
Commit e37dbbcb authored by francois.grand's avatar francois.grand
Browse files

#45 classe FieldSet : remplacement du membre _parentForm par un getter

parent 06c6e85f
No related branches found
No related tags found
1 merge request!20Resolve "Ouvrir / Enregistrer une session / une calculette"
......@@ -160,7 +160,7 @@ export abstract class FormulaireDefinition extends FormulaireNode implements Obs
private parse_fieldset(json: {}) {
const fs = this.createFieldset(this, json);
fs.parseConfig(json, { "parentForm": this });
fs.parseConfig(json);
this.afterParseFieldset(fs);
}
......
......@@ -46,7 +46,7 @@ export class FieldsetTemplate {
public instantiateTemplate(cont: FieldsetContainer, after: number): FieldSet {
const parentForm = cont.parent as FormulaireDefinition;
const res = parentForm.createFieldset(cont, this._jsonConfig, { "template": this, "after": after });
res.parseConfig(this._jsonConfig, { "parentForm": parentForm });
res.parseConfig(this._jsonConfig);
parentForm.afterParseFieldset(res);
return res;
}
......
......@@ -15,11 +15,6 @@ import { FieldsetContainer } from "./fieldset-container";
import { FormulaireNode } from "./formulaire-node";
export class FieldSet extends FormulaireElement implements Observer {
/**
* formulaire parent
*/
private _parentForm: FormulaireDefinition;
/**
* SessionNub associé
*/
......@@ -45,6 +40,16 @@ export class FieldSet extends FormulaireElement implements Observer {
this._props = new Props();
}
/**
* formulaire parent
*/
private get parentForm(): FormulaireDefinition {
let res = this.parent;
while (!(res instanceof FormulaireDefinition))
res = res.parent;
return res as FormulaireDefinition;
}
public get sessionNub(): SessionNub {
return this._sessionNub;
}
......@@ -279,17 +284,16 @@ export class FieldSet extends FormulaireElement implements Observer {
// fin MAJ selects
this.applyDependencies(this._parentForm);
this.applyDependencies(this.parentForm);
}
public parseConfig(json: {}, data?: {}) {
this._jsonConfig = json;
this._parentForm = data["parentForm"];
this._confId = json["id"];
const ct: string = json["calcType"];
const calc_type: CalculatorType = ct == undefined ? this._parentForm.calculatorType : CalculatorType[ct];
const calc_type: CalculatorType = ct == undefined ? this.parentForm.calculatorType : CalculatorType[ct];
this.setPropValue("calcType", calc_type);
const nt: string = json["nodeType"];
......
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