diff --git a/src/app/components/single-result/single-result.component.html b/src/app/components/single-result/single-result.component.html index 503c0754ebaa2465c761b56f9d0f14ac717b3f99..f0611067b17cefd03d6e279a3668bae59a64b1a8 100644 --- a/src/app/components/single-result/single-result.component.html +++ b/src/app/components/single-result/single-result.component.html @@ -1,10 +1,16 @@ -<!-- 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 diff --git a/src/app/components/single-result/single-result.component.ts b/src/app/components/single-result/single-result.component.ts index 306eee53e069baf4e9d85d63da6f4946e9b65825..125706a2634dc4935d2a5d26029032d4abb8ade3 100644 --- a/src/app/components/single-result/single-result.component.ts +++ b/src/app/components/single-result/single-result.component.ts @@ -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; } }