diff --git a/src/app/formulaire/elements/formulaire-element.ts b/src/app/formulaire/elements/formulaire-element.ts index 25b5943fa846c1790b151d0aa5d01cfec1aae4da..6005f2baaedc721d0f481e66bec570ea59ac024e 100644 --- a/src/app/formulaire/elements/formulaire-element.ts +++ b/src/app/formulaire/elements/formulaire-element.ts @@ -71,13 +71,12 @@ export abstract class FormulaireElement extends FormulaireNode { /** * Updates localisation for this element: first the label then all the element's children - * @param loc calculator-specific localised messages map - * @param key Element label key + * @param fromConfig if false avoid call of selectField.updateLocalisation() */ - public updateLocalisation() { + public updateLocalisation(fromConfig: boolean = true) { this._label = this.formulaireService.localizeText(this._confId, this.parentForm.currentNub.calcType); for (const f of this.getKids()) { - f.updateLocalisation(); + f.updateLocalisation(fromConfig); } } diff --git a/src/app/formulaire/elements/select/select-field-searched-param.ts b/src/app/formulaire/elements/select/select-field-searched-param.ts index 978cdebc98f7047fe5151c851d57d22523b16727..c4b2c779d113a9680b2b10270baec543c4aa62e3 100644 --- a/src/app/formulaire/elements/select/select-field-searched-param.ts +++ b/src/app/formulaire/elements/select/select-field-searched-param.ts @@ -3,6 +3,8 @@ import { decodeHtml } from "app/util/util"; import { acSection, Nub, Solveur } from "jalhyd"; import { SelectEntry } from "./select-entry"; import { SelectField } from "./select-field"; +import { FormulaireNode } from "../formulaire-node"; +import { FormulaireElement } from "../formulaire-element"; /* "id": "select_searched_param", @@ -12,6 +14,11 @@ import { SelectField } from "./select-field"; // Solveur, paramètre recherché (à faire varier) export class SelectFieldSearchedParam extends SelectField { + constructor(parent: FormulaireNode) { + super(parent); + this._messageWhenEmpty = "INFO_VERIF_SOLVER_SEARCHED_PARAM"; + } + protected populate() { const fs = ServiceFactory.formulaireService; @@ -28,7 +35,7 @@ export class SelectFieldSearchedParam extends SelectField { if (p.visible) { let calcTitle; // if form already exist - if(fs.getFormulaireFromId(p.originNub.uid)) { + if (fs.getFormulaireFromId(p.originNub.uid)) { calcTitle = fs.getFormulaireFromId(p.originNub.uid).calculatorName; } // prevent issue #369 (loading session) @@ -58,7 +65,7 @@ export class SelectFieldSearchedParam extends SelectField { } public updateLocalisation() { - // do not override localisation done in populate() - // ie. avoid what is done by SelectField.updateLocalisation() + // call grand parent updateLocalisation() + super.updateLocalisation(false); } } diff --git a/src/app/formulaire/elements/select/select-field-solver-targeted-result.ts b/src/app/formulaire/elements/select/select-field-solver-targeted-result.ts index 36094a8dddfc808aea5ce6c8031de91bed17c1c9..fd1537b40eec35e2729b6d756151ff95acbf746c 100644 --- a/src/app/formulaire/elements/select/select-field-solver-targeted-result.ts +++ b/src/app/formulaire/elements/select/select-field-solver-targeted-result.ts @@ -40,7 +40,8 @@ export class SelectFieldSolverTargetedResult extends SelectField { } public updateLocalisation() { - FormulaireElement.prototype.updateLocalisation.call(this); + // call grand parent updateLocalisation() + super.updateLocalisation(false); for (const e of this._entries) { // @WARNING clodo hack for Solveur // 1. calculated param diff --git a/src/app/formulaire/elements/select/select-field-solveur-target.ts b/src/app/formulaire/elements/select/select-field-solveur-target.ts index 3d752aa4368a5c45c5b0c4a4d36375ff8cb0d8b2..fb3eba4c3a47ace9cd237c5fd79bb472c50ac468 100644 --- a/src/app/formulaire/elements/select/select-field-solveur-target.ts +++ b/src/app/formulaire/elements/select/select-field-solveur-target.ts @@ -9,9 +9,17 @@ import { decodeHtml } from "../../../util/util"; import { Session, Solveur } from "jalhyd"; import { SelectEntry } from "./select-entry"; import { SelectField } from "./select-field"; +import { FormulaireElement } from "../formulaire-element"; +import { FormulaireNode } from "../formulaire-node"; // Solveur, module cible (à calculer) export class SelectFieldSolverTarget extends SelectField { + + constructor(parent: FormulaireNode) { + super(parent); + this._messageWhenEmpty = "INFO_VERIF_CREATE_ATLEAST_ONE_TARGETNUB"; + } + protected populate() { const fs = ServiceFactory.formulaireService; @@ -48,7 +56,7 @@ export class SelectFieldSolverTarget extends SelectField { } public updateLocalisation() { - // do not override localisation done in populate() - // ie. avoid what is done by SelectField.updateLocalisation() + // call grand parent updateLocalisation() + super.updateLocalisation(false); } } diff --git a/src/app/formulaire/elements/select/select-field.ts b/src/app/formulaire/elements/select/select-field.ts index d4d1cf2c3358104365681c6e0f01cb814f5a8500..425cfd192ab562a6ce707ed97caa97dbe3247846 100644 --- a/src/app/formulaire/elements/select/select-field.ts +++ b/src/app/formulaire/elements/select/select-field.ts @@ -4,7 +4,7 @@ import { arraysAreEqual } from "../../../util/util"; import { FormulaireNode } from "../formulaire-node"; import { ServiceFactory } from "app/services/service-factory"; import { FormulaireDefinition } from "../../definition/form-definition"; -import { enumValueFromString, Message, Nub } from "jalhyd"; +import { enumValueFromString, Message, Nub, PabChute, SectionNub } from "jalhyd"; export abstract class SelectField extends Field { @@ -296,7 +296,7 @@ export abstract class SelectField extends Field { public isEmptySelectField() { return this._selectedEntry !== undefined && Object.keys(this._selectedEntry).length === 0; } - + public get messageWhenEmpty(): string { let msg: string; @@ -314,15 +314,17 @@ export abstract class SelectField extends Field { return this._multiple; } - public updateLocalisation() { + public updateLocalisation(fromConfig: boolean = true) { super.updateLocalisation(); - for (const e of this._entries) { - const aId = e.id.split("_"); - const trad = ServiceFactory.formulaireService.localizeText( - `${aId[1].toUpperCase()}_${aId[2]}`, - this.parentForm.currentNub.calcType - ); - e.label = trad; + if (fromConfig) { + for (const e of this._entries) { + const aId = e.id.split("_"); + const trad = ServiceFactory.formulaireService.localizeText( + `${aId[1].toUpperCase()}_${aId[2]}`, + this.parentForm.currentNub.calcType + ); + e.label = trad; + } } } }