Skip to content
Snippets Groups Projects
Commit d0d3582d authored by francois.grand's avatar francois.grand
Browse files

classe ErrorMessage renommée en Message, ErrorCode en MessageCode

parent c89a3241
No related branches found
No related tags found
No related merge requests found
import { ComputeNodeType, ParamDefinition, ParamDomainValue, ErrorMessage } from 'jalhyd';
import { ComputeNodeType, ParamDefinition, ParamDomainValue } from 'jalhyd';
import { InputField, Dependency, DependencyConditionType, ValueDependencyCondition } from './formulaire';
import { StringMap } from '../../stringmap';
......
......@@ -3,7 +3,7 @@
import { Component, Input, forwardRef, OnInit, DoCheck, ChangeDetectorRef } from '@angular/core';
import { ControlValueAccessor, NG_VALUE_ACCESSOR, NG_VALIDATORS, FormControl } from '@angular/forms';
import { ComputeNodeType, ParamDefinition, NumericalString, ErrorMessage } from 'jalhyd';
import { ComputeNodeType, ParamDefinition, NumericalString, Message } from 'jalhyd';
import { ParamService } from '../../services/param/param.service';
import { InternationalisationService, LanguageCode } from '../../services/internationalisation/internationalisation.service';
......@@ -152,8 +152,8 @@ export class ParamInputComponent implements ControlValueAccessor, OnInit, DoChec
this._paramDef.checkValue(v.numericalValue);
}
catch (e) {
if (e instanceof ErrorMessage)
this._message = this.intlService.localizeErrorMessage(e);
if (e instanceof Message)
this._message = this.intlService.localizeMessage(e);
else
this._message = "invalid value";
}
......
import { Component } from '@angular/core';
import { ErrorMessage } from 'jalhyd';
import { Message } from 'jalhyd';
import { InternationalisationService } from '../../services/internationalisation/internationalisation.service';
......@@ -174,8 +174,8 @@ export class RemousResultsComponent {
this._results.push({ "abs": x, "flu": f, "tor": t });
}
public addLogEntry(m: ErrorMessage, nDigits: number) {
this._logEntries.push(this.intlService.localizeErrorMessage(m, nDigits));
public addLogEntry(m: Message, nDigits: number) {
this._logEntries.push(this.intlService.localizeMessage(m, nDigits));
}
public setPenteFond(v: number) {
......
import { Injectable } from '@angular/core';
import { Response } from '@angular/http';
import { ErrorMessage, ErrorCode } from "jalhyd";
import { Message, MessageCode } from "jalhyd";
import { HttpService } from "../http/http.service";
import { Observable } from "../observer";
......@@ -47,7 +47,7 @@ export class Language {
export class InternationalisationService extends Observable {
private _currLang: Language;
private _sLang: string;
private _errorMessages: StringMap;
private _Messages: StringMap;
private _languages: Language[];
......@@ -71,7 +71,7 @@ export class InternationalisationService extends Observable {
if (l.code == lc)
return l;
}
throw new ErrorMessage(ErrorCode.ERROR_LANG_UNSUPPORTED);
throw new Message(MessageCode.ERROR_LANG_UNSUPPORTED);
}
private getLanguageFromTag(tag: string) {
......@@ -79,7 +79,7 @@ export class InternationalisationService extends Observable {
if (l.tag === tag)
return l;
}
let e = new ErrorMessage(ErrorCode.ERROR_LANG_UNSUPPORTED);
let e = new Message(MessageCode.ERROR_LANG_UNSUPPORTED);
e.extraVar["locale"] = tag;
throw e;
}
......@@ -96,17 +96,17 @@ export class InternationalisationService extends Observable {
this._currLang = this.getLanguageFromCode(lng);
}
let prom = this.httpGetErrorMessages();
let prom = this.httpGetMessages();
prom.then((res) => {
this.notifyObservers(undefined);
})
}
private httpGetErrorMessages(): Promise<Response> {
private httpGetMessages(): Promise<Response> {
let is: InternationalisationService = this;
let processData = function (s: string) {
// fermeture nécessaire pour capturer la valeur de this (undefined sinon)
is._errorMessages = JSON.parse(s);
is._Messages = JSON.parse(s);
}
let l;
......@@ -123,9 +123,9 @@ export class InternationalisationService extends Observable {
return this.httpService.httpGetRequest(undefined, undefined, undefined, "locale/" + f, processData);
}
private getErrorMessageFromCode(c: ErrorCode): string {
let sCode: string = ErrorCode[c];
return this._errorMessages[ErrorCode[c]];
private getMessageFromCode(c: MessageCode): string {
let sCode: string = MessageCode[c];
return this._Messages[MessageCode[c]];
}
private replaceAll(str: string, find: string, replace: string) {
......@@ -137,9 +137,9 @@ export class InternationalisationService extends Observable {
* @param r message
* @param nDigits nombre de chiffres à utiliser pour l'arrondi dans le cas de données numériques
*/
public localizeErrorMessage(r: ErrorMessage, nDigits: number = 3): string {
let sCode: string = ErrorCode[r.code];
let m: string = this.getErrorMessageFromCode(r.code);
public localizeMessage(r: Message, nDigits: number = 3): string {
let sCode: string = MessageCode[r.code];
let m: string = this.getMessageFromCode(r.code);
for (let k in r.extraVar) {
let v: any = r.extraVar[k];
......
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