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

#64 : SingleResultComponent : ajout d'une icône rouge en cas d'erreur de la valeur

parent a18ba41d
No related branches found
No related tags found
1 merge request!11Resolve "Faire les modifs nécessaires pour prendre en compte cassiopee/jalhyd#36"
<!-- template pour le popup *ngIf="hasLog" -->
<!-- template pour le popup -->
<ng-template #popTemplate>
<div [innerHtml]="htmlLog"></div>
<div [innerHtml]="htmlTooltip"></div>
</ng-template>
<div class="row" [mdbTooltip]="popTemplate" [isDisabled]="tooltipDisabled">
<div class="col-12">
{{value}}
<!-- icône en cas d'erreur -->
<i *ngIf="hasError" class="fa fa-exclamation-triangle" style="color:red" aria-hidden="true"></i>
<!-- valeur -->
<span *ngIf="!hasError">
{{value}}
</span>
</div>
</div>
\ No newline at end of file
......@@ -14,29 +14,48 @@ export class SingleResultComponent implements OnChanges {
@Input("result")
private _result: ResultElement;
private _htmlLog: string;
/**
* valeur à afficher
*/
private _value: string;
private _logEmpty: boolean = false;
/**
* true si la valeur est en erreur
*/
private _hasError: boolean;
/**
* code HTML du tooltip
*/
private _htmlTooltip: string;
/**
* true si pas de texte à afficher dans le tooltip
*/
private _emptyTooltip: boolean = false;
constructor(
private appSetupService: ApplicationSetupService,
private intlService: InternationalisationService
) {
}
) { }
private get hasValue(): boolean {
return this._result != undefined && this._result.ok;
/**
* appelé quand les @Input changent
*/
ngOnChanges() {
this.updateTooltip();
}
private get value(): string {
private updateTooltip() {
// valeur à afficher
const nDigits = this.appSetupService.displayDigits;
const r: ResultElement = this._result;
if (r == undefined || r.vCalc == undefined)
return undefined;
return r.vCalc.toFixed(nDigits);
}
this._hasError = r == undefined || r.vCalc == undefined;
this._value = this._hasError ? " " : this._value = r.vCalc.toFixed(nDigits);
// texte du tooltip
private updateTooltip() {
let res = "";
if (this._result != undefined)
......@@ -46,19 +65,23 @@ export class SingleResultComponent implements OnChanges {
res += this.intlService.localizeMessage(m);
}
this._htmlLog = res;
this._logEmpty = this._htmlLog.length == 0;
this._htmlTooltip = res;
this._emptyTooltip = this._htmlTooltip.length == 0;
}
ngOnChanges() {
this.updateTooltip();
private get value(): string {
return this._value;
}
private get hasError() {
return this._hasError;
}
private get htmlLog(): string {
return this._htmlLog;
private get htmlTooltip(): string {
return this._htmlTooltip;
}
private get tooltipDisabled(): boolean {
return this._logEmpty;
return this._emptyTooltip;
}
}
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