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