Skip to content
Snippets Groups Projects
Commit 1522b18c authored by AUBRY JEAN-PASCAL's avatar AUBRY JEAN-PASCAL
Browse files

fix: display solver field labels and empty error messages

Refs #                 668
parent 0c2247bf
No related branches found
No related tags found
2 merge requests!275Release v4.19.0,!265Resolve "Solveur: Les select d'une session chargée ne s'initialise pas"
Pipeline #206060 passed
This commit is part of merge request !265. Comments created here will be created in the context of that merge request.
......@@ -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);
}
}
......
......@@ -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);
}
}
......@@ -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
......
......@@ -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);
}
}
......@@ -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;
}
}
}
}
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