Skip to content
Snippets Groups Projects
Commit 14d764e7 authored by David Dorchies's avatar David Dorchies
Browse files

#44 Gestion propre des ENUM dans les extraResults

parent e76567f4
No related branches found
No related tags found
1 merge request!24Resolve "Ajout de la calculette "passe à enrochement""
master
22-ajout-de-la-calculette-passe-a-enrochement-simple
......@@ -4624,7 +4624,7 @@
},
"jalhyd": {
"version": "file:../jalhyd/jalhyd-1.0.0.tgz",
"integrity": "sha1-mc8VVFiB+OWUy8RNmswEUzFqIY0="
"integrity": "sha1-9m5xV+HX20MPMf8mY8ZfQLa1oUA="
},
"jasmine": {
"version": "2.8.0",
......
......@@ -33,12 +33,14 @@ export class HorizontalResultElementComponent extends ResultElementBaseComponent
super.ngOnChanges();
this.vcRef.clear();
if (this._headerKeys && this._resultElement)
if (this._headerKeys && this._resultElement) {
for (const h of this._headerKeys) {
let v = this._resultElement.extraResults[h];
if (typeof (v) === "number")
if (typeof (v) === "number") {
v = this.intlService.formatResult(h, v);
}
this.vcRef.createEmbeddedView(this.tdTemplate, { extraResultValue: v });
}
}
}
}
......@@ -49,7 +49,7 @@ export class ResultElementBaseComponent implements OnChanges {
/**
* true si pas de texte à afficher dans le tooltip
*/
protected _emptyTooltip: boolean = false;
protected _emptyTooltip = false;
protected appSetupService: ApplicationSetupService;
......@@ -73,23 +73,24 @@ export class ResultElementBaseComponent implements OnChanges {
const nDigits = this.appSetupService.displayDigits;
const r: ResultElement = this._resultElement;
this._hasValue = r != undefined && r.vCalc != undefined;
this._hasError = r == undefined || (r.vCalc == undefined && r.extraResults.length > 0);
this._hasValue = r !== undefined && r.vCalc !== undefined;
this._hasError = r === undefined || (r.vCalc === undefined && r.extraResults.length > 0);
this._value = this._hasValue ? this._value = r.vCalc.toFixed(nDigits) : " ";
// texte du tooltip
let res = "";
if (this._resultElement != undefined)
for (let m of this._resultElement.log.messages) {
if (res.length > 0)
if (this._resultElement !== undefined) {
for (const m of this._resultElement.log.messages) {
if (res.length > 0) {
res += "<br/>";
}
res += this.intlService.localizeMessage(m);
}
}
this._htmlTooltip = res;
this._emptyTooltip = this._htmlTooltip.length == 0;
this._emptyTooltip = this._htmlTooltip.length === 0;
}
private get hasValue() {
......
......@@ -212,19 +212,15 @@ export class InternationalisationService extends Observable {
}
/**
* met en forme ou traduit un résultat en fonction du libellé qui l'accompagne
* @todo Il manque un formalisme clair permettant de différencier les valeurs numériques des ENUM
* Met en forme un extraResult en fonction du libellé qui l'accompagne
* Les extraResult avec le terme "ENUM_" sont traduit avec le message INFO_EXTRARES_ENUM_[Nom de la variable après ENUM_]
*/
public formatResult(label: string, value: number): string {
const match = this.parseLabel(label);
if (match) {
if (match[3] !== "Q") { // Le débit est une valeur numérique, tous les autres sont des ENUM ???
// Label du type ouvrage[n].XXX => message INFO_EXTRARES_ENUM_OUVRAGE_XXX_value
return this.localizeText(`INFO_EXTRARES_ENUM_${match[1].toUpperCase()}_${match[3].toUpperCase()}_${value}`);
}
const match = label.indexOf("ENUM_");
if (match > -1) {
return this.localizeText(`INFO_EXTRARES_${label.substring(match).toUpperCase()}_${value}`);
}
const appSetupService = ServiceFactory.instance.applicationSetupService;
const nDigits = appSetupService.displayDigits;
const nDigits = ServiceFactory.instance.applicationSetupService.displayDigits;
return value.toFixed(nDigits);
}
......
......@@ -38,18 +38,21 @@
"INFO_CONDUITEDISTRIBUTRICE_TITRE": "Conduite distributrice",
"INFO_COURBEREMOUS_TITRE": "Courbes de remous",
"INFO_DEVER_TITRE": "Lois de déversoirs dénoyés",
"INFO_EXTRARES_ENUM_OUVRAGE_Q_MODE_0": "Surface libre",
"INFO_EXTRARES_ENUM_OUVRAGE_Q_MODE_1": "En charge",
"INFO_EXTRARES_ENUM_OUVRAGE_Q_MODE_2": "Débit nul",
"INFO_EXTRARES_ENUM_OUVRAGE_Q_REGIME_0": "Dénoyé",
"INFO_EXTRARES_ENUM_OUVRAGE_Q_REGIME_1": "Partiellement noyé",
"INFO_EXTRARES_ENUM_OUVRAGE_Q_REGIME_2": "Noyé",
"INFO_EXTRARES_ENUM_OUVRAGE_Q_REGIME_3": "Débit nul",
"INFO_EXTRARES_ENUM_MACRORUGOFLOWTYPE_0": "Emergent",
"INFO_EXTRARES_ENUM_MACRORUGOFLOWTYPE_1": "Quasi-émergent",
"INFO_EXTRARES_ENUM_MACRORUGOFLOWTYPE_2": "Immergé",
"INFO_EXTRARES_ENUM_STRUCTUREFLOWMODE_0": "Surface libre",
"INFO_EXTRARES_ENUM_STRUCTUREFLOWMODE_1": "En charge",
"INFO_EXTRARES_ENUM_STRUCTUREFLOWMODE_2": "Débit nul",
"INFO_EXTRARES_ENUM_STRUCTUREFLOWREGIME_0": "Dénoyé",
"INFO_EXTRARES_ENUM_STRUCTUREFLOWREGIME_1": "Partiellement noyé",
"INFO_EXTRARES_ENUM_STRUCTUREFLOWREGIME_2": "Noyé",
"INFO_EXTRARES_ENUM_STRUCTUREFLOWREGIME_3": "Débit nul",
"INFO_EXTRARES_LIB_B": "Largeur au miroir (m)",
"INFO_EXTRARES_LIB_CV": "Cv: Coefficient de vitesse d'approche",
"INFO_EXTRARES_LIB_CVQT": "CV.QT: Débit corrigé (m³/s)",
"INFO_EXTRARES_LIB_EC": "EC: Énergie cinétique (m)",
"INFO_EXTRARES_LIB_FLOWTYPE": "Type d'écoulement",
"INFO_EXTRARES_LIB_ENUM_MACRORUGOFLOWTYPE": "Type d'écoulement",
"INFO_EXTRARES_LIB_FLU": "Ligne d'eau fluviale",
"INFO_EXTRARES_LIB_FR": "Froude",
"INFO_EXTRARES_LIB_HS": "Charge spécifique (m)",
......@@ -58,8 +61,8 @@
"INFO_EXTRARES_LIB_IMP": "Impulsion (N)",
"INFO_EXTRARES_LIB_J": "Perte de charge (m)",
"INFO_EXTRARES_LIB_OUVRAGE_Q": "Débit (m³/s)",
"INFO_EXTRARES_LIB_OUVRAGE_Q_MODE": "Type d'écoulement",
"INFO_EXTRARES_LIB_OUVRAGE_Q_REGIME": "Régime",
"INFO_EXTRARES_LIB_OUVRAGE_Q_ENUM_STRUCTUREFLOWMODE": "Type d'écoulement",
"INFO_EXTRARES_LIB_OUVRAGE_Q_ENUM_STRUCTUREFLOWREGIME": "Régime",
"INFO_EXTRARES_LIB_P": "Périmètre mouillé (m)",
"INFO_EXTRARES_LIB_PV": "Puissance volumique dissipée (W/m³)",
"INFO_EXTRARES_LIB_Q": "Débit (m³/s)",
......
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