From ffe22f1bb029936aeedc907b7016abc53c80f3ed Mon Sep 17 00:00:00 2001 From: David Dorchies <david.dorchies@irstea.fr> Date: Wed, 18 Jul 2018 17:22:19 +0200 Subject: [PATCH] jalhyd#51 (Ajout d'un message d'erreur) + Ajout d'un message d'erreur pour les textes non traduits --- package-lock.json | 4 ++-- src/app/formulaire/ngparam.ts | 19 +++++++++++++------ src/app/results/calculator-results.ts | 14 +++++++++----- .../internationalisation.service.ts | 4 +++- src/locale/messages.fr.json | 1 + 5 files changed, 28 insertions(+), 14 deletions(-) diff --git a/package-lock.json b/package-lock.json index 61a6e504a..43f4146de 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,5 +1,5 @@ { - "name": "ngHyd", + "name": "nghyd", "version": "1.1.0", "lockfileVersion": 1, "requires": true, @@ -4624,7 +4624,7 @@ }, "jalhyd": { "version": "file:../jalhyd/jalhyd-1.0.0.tgz", - "integrity": "sha1-eY+WHbK7wwKVGMcre9MxL7BuqCQ=" + "integrity": "sha1-mc8VVFiB+OWUy8RNmswEUzFqIY0=" }, "jasmine": { "version": "2.8.0", diff --git a/src/app/formulaire/ngparam.ts b/src/app/formulaire/ngparam.ts index 0aaed387b..7faa80945 100644 --- a/src/app/formulaire/ngparam.ts +++ b/src/app/formulaire/ngparam.ts @@ -60,8 +60,9 @@ export class NgParameter extends InputField implements Observer { } public set confId(id: string) { - if (this._confId != undefined) + if (this._confId != undefined) { throw new Error(`NgParameter : l'identifiant de configuration est déjà défini (${this._confId})`); + } this._confId = id; } @@ -122,8 +123,9 @@ export class NgParameter extends InputField implements Observer { let o = asObservable(this._paramDef.referencedObject); if (this.valueMode === ParamValueMode.LINK) { this._paramDef.undefineReference(); - if (o !== undefined) + if (o !== undefined) { o.removeObserver(this); + } } } @@ -131,18 +133,22 @@ export class NgParameter extends InputField implements Observer { * crée le lien avec un paramètre */ public linkToParameter(n: Nub, ref: string) { - const changed: boolean = this._paramDef.valueMode !== ParamValueMode.LINK || this._paramDef.referencedNub !== n || this._paramDef.referenceDefinition !== ref; + const changed: boolean = + this._paramDef.valueMode !== ParamValueMode.LINK || this._paramDef.referencedNub !== n || + this._paramDef.referenceDefinition !== ref; if (changed) { let o = asObservable(this._paramDef.referencedObject); - if (o !== undefined) + if (o !== undefined) { o.removeObserver(this); + } this.valueMode = ParamValueMode.LINK; this._paramDef.defineReference(n, ref); o = asObservable(this._paramDef.referencedObject); - if (o !== undefined) + if (o !== undefined) { o.addObserver(this); // pour être prévenu des changements de valeur de l'object référencé + } this.notifyObservers({ "action": "valueLinkChange", @@ -160,8 +166,9 @@ export class NgParameter extends InputField implements Observer { } public checkList(l: number[]) { - for (let e of l) + for (let e of l) { this.checkValue(e); + } } public get valueMode() { diff --git a/src/app/results/calculator-results.ts b/src/app/results/calculator-results.ts index 21bca03f0..be987f974 100644 --- a/src/app/results/calculator-results.ts +++ b/src/app/results/calculator-results.ts @@ -3,16 +3,20 @@ import { NgParameter } from "../formulaire/ngparam"; export abstract class CalculatorResults { public static paramLabel(p: NgParameter, displaySymbol: boolean): string { let res = ""; - if (displaySymbol) + if (displaySymbol) { res += p.symbol; - if (p.label != undefined && p.label != "") - if (p.symbol != p.label || !displaySymbol) { - if (res.length > 0) + } + if (p.label !== undefined && p.label !== "") { + if (p.symbol !== p.label || !displaySymbol) { + if (res.length > 0) { res += " : "; + } res += p.label; } - if (p.unit != undefined && p.unit != "") + } + if (p.unit !== undefined && p.unit !== "") { res += " (" + p.unit + ")"; + } return res; } diff --git a/src/app/services/internationalisation/internationalisation.service.ts b/src/app/services/internationalisation/internationalisation.service.ts index c3a168c48..346d18504 100644 --- a/src/app/services/internationalisation/internationalisation.service.ts +++ b/src/app/services/internationalisation/internationalisation.service.ts @@ -135,7 +135,9 @@ export class InternationalisationService extends Observable { } private getMessageFromCode(c: MessageCode): string { - const sCode: string = MessageCode[c]; + if (this._Messages[MessageCode[c]] === undefined) { + return `*** Message ${MessageCode[c]} non traduit ***`; + } return this._Messages[MessageCode[c]]; } diff --git a/src/locale/messages.fr.json b/src/locale/messages.fr.json index 6c493332b..d8ef7ba4a 100644 --- a/src/locale/messages.fr.json +++ b/src/locale/messages.fr.json @@ -28,6 +28,7 @@ "ERROR_SECTION_NON_CONVERGENCE_NEWTON_HNORMALE": "Non convergence du calcul de la hauteur normale (Méthode de Newton)", "ERROR_SECTION_NON_CONVERGENCE_NEWTON_HTOR": "Non convergence du calcul de la hauteur correspondante (Méthode de Newton) pour le calcul de la hauteur torrentielle", "ERROR_SECTION_PENTE_NEG_NULLE_HNORMALE_INF": "La pente est négative ou nulle, la hauteur normale est infinie", + "ERROR_STRUCTURE_Q_TROP_ELEVE": "Le débit passant par les autres ouvrages est trop élevé: le paramètre demandé n'est pas calculable.", "INFO_CALCULATOR_CALCULER": "Calculer", "INFO_CALCULATOR_PARAMFIXES": "Paramètres fixés", "INFO_CALCULATOR_VALEURS": "Valeurs", -- GitLab