diff --git a/src/app/formulaire/formulaire-definition.ts b/src/app/formulaire/formulaire-definition.ts index 82771cde8dd5a788e7a4823fd796cc74587af03e..0b0177788f685f712dc01b53d8bb181413009e95 100644 --- a/src/app/formulaire/formulaire-definition.ts +++ b/src/app/formulaire/formulaire-definition.ts @@ -2,7 +2,6 @@ import { ComputeNodeType, ParamsEquation, Nub, acSection, RegimeUniforme, Method import { ParamsSectionRectang, cSnRectang, ParamsSectionCirc, cSnCirc, ParamsSectionPuiss, cSnPuiss, Result } from "jalhyd"; import { ConduiteDistrib, ConduiteDistribParams, LechaptCalmon, LechaptCalmonParams, ParamsSectionTrapez, cSnTrapez } from "jalhyd"; - import { ParamService } from "../services/param/param.service"; import { InternationalisationService } from "../services/internationalisation/internationalisation.service"; import { Field } from "./field"; @@ -21,6 +20,7 @@ import { ExistenceDependency } from "./existence-dependency"; import { FixedVarResults } from "../results/fixed-var-results"; import { SectionResults } from "../results/section-results"; import { RemousResults } from "../results/remous-results"; +import { StringMap } from "../stringmap"; export enum CalculatorType { @@ -1089,4 +1089,17 @@ export class FormulaireDefinition { public hasRemousResults(): boolean { return this._remousResults.hasResults(); } + + public updateLocalisation(localisation: StringMap) { + for (let loc_id in localisation) { + for (let fs of this._fieldSets) { + if (fs.id == loc_id) + fs.updateLocalisation(localisation); + + for (let p of fs.fields) + if (p.id === loc_id) + p.updateLocalisation(localisation); + } + } + } } diff --git a/src/app/formulaire/formulaire-element.ts b/src/app/formulaire/formulaire-element.ts index 69df8ebbb221b0f8c80367ffd2295111348a0fd0..bc1ee5f95a0723463cc520f1a60b6a1c47c30c44 100644 --- a/src/app/formulaire/formulaire-element.ts +++ b/src/app/formulaire/formulaire-element.ts @@ -10,7 +10,7 @@ export abstract class FormulaireElement { private _id: string; private _formId: number; public isDisplayed: boolean; - public label: string; + private _label: string; constructor(nodeType: ComputeNodeType, id: string, formId: number) { this._nodeType = nodeType; @@ -31,6 +31,10 @@ export abstract class FormulaireElement { return this._formId; } + get label(): string { + return this._label; + } + protected abstract verifyDependency(d: Dependency): boolean; public verifiesDependency(d: Dependency): boolean { @@ -41,7 +45,7 @@ export abstract class FormulaireElement { } public updateLocalisation(loc: StringMap) { - this.label = loc[this.id]; + this._label = loc[this.id]; } public toString() { diff --git a/src/app/services/formulaire/formulaire.service.ts b/src/app/services/formulaire/formulaire.service.ts index 1b833bc14e79d4960f03fa567103a79d792b4e15..8933a6066823dedddbea0eeb0239b4ab86212d42 100644 --- a/src/app/services/formulaire/formulaire.service.ts +++ b/src/app/services/formulaire/formulaire.service.ts @@ -50,11 +50,11 @@ export class FormulaireService extends Observable { * @param localisation ensemble id-message traduit */ private updateFormulaireLocalisation(formId: number, localisation: StringMap) { - for (let loc_id in localisation) { - let fe = this.getFormulaireElementById(formId, loc_id); - if (fe != undefined) - fe.updateLocalisation(localisation); - } + for (let f of this._formulaires) + if (f.uid == formId) { + f.updateLocalisation(localisation); + break; + } } /**