From 3134d3e3f4b07cd585264b497e8f452a8467c640 Mon Sep 17 00:00:00 2001 From: "mathias.chouet" <mathias.chouet@irstea.fr> Date: Mon, 15 Apr 2019 14:01:31 +0200 Subject: [PATCH] Fix #175 --- .../param-link/param-link.component.html | 14 ++++++- .../param-link/param-link.component.scss | 18 ++++++-- .../param-link/param-link.component.ts | 42 +++++++++++++++++++ src/locale/messages.en.json | 3 ++ src/locale/messages.fr.json | 3 ++ 5 files changed, 76 insertions(+), 4 deletions(-) diff --git a/src/app/components/param-link/param-link.component.html b/src/app/components/param-link/param-link.component.html index 9f8fce8bf..d24d7c0ed 100644 --- a/src/app/components/param-link/param-link.component.html +++ b/src/app/components/param-link/param-link.component.html @@ -7,7 +7,19 @@ </mat-select> </mat-form-field> -<mat-icon #tooltip="matTooltip" [matTooltip]="tooltipText" matTooltipClass="linked-param-tooltip" +<div class="status-icons-container"> + <mat-icon [title]="uitextVariated" class="status-info" *ngIf="isVariable"> + show_chart + </mat-icon> + <mat-icon [title]="uitextCalculated" class="status-info" *ngIf="isCalculated && ! isAwaitingCalculation"> + check_circle + </mat-icon> + <mat-icon [title]="uitextAwaitingCalculation" class="status-info" *ngIf="isAwaitingCalculation"> + timelapse + </mat-icon> +</div> + +<mat-icon id="info-tooltip" #tooltip="matTooltip" [matTooltip]="tooltipText" matTooltipClass="linked-param-tooltip" (click)="tooltip.toggle()" (mouseenter)="$event.stopImmediatePropagation()" (mouseleave)="$event.stopImmediatePropagation()"> info_outline diff --git a/src/app/components/param-link/param-link.component.scss b/src/app/components/param-link/param-link.component.scss index 13d6d32f0..fc6224f86 100644 --- a/src/app/components/param-link/param-link.component.scss +++ b/src/app/components/param-link/param-link.component.scss @@ -32,11 +32,23 @@ } } - mat-icon { + .status-icons-container { position: absolute; - top: 7px; + top: -8px; + right: 8px; + + > mat-icon { + transform: scale(0.7); + color: grey; + cursor: default; + } + } + + mat-icon#info-tooltip { + position: absolute; + top: 12px; right: 8px; - transform: scale(0.9); cursor: pointer; + transform: scale(0.9); } } diff --git a/src/app/components/param-link/param-link.component.ts b/src/app/components/param-link/param-link.component.ts index 7c3e8887e..53e88589e 100644 --- a/src/app/components/param-link/param-link.component.ts +++ b/src/app/components/param-link/param-link.component.ts @@ -46,6 +46,36 @@ export class ParamLinkComponent implements OnChanges, Observer, OnDestroy { return "linked_" + this.param.symbol; } + public get isVariable(): boolean { + return this.param.paramDefinition.hasMultipleValues; + } + + /** + * Returns true if current target needs to be calculated, + * whether the result is already available or not + */ + public get isCalculated(): boolean { + const refValue = this.param.paramDefinition.referencedValue; + return (refValue.isResult() || refValue.isExtraResult()); + } + + /** + * Returns true if current target needs to be calculated, + * but result is not yet available + */ + public get isAwaitingCalculation(): boolean { + if (this.isCalculated) { + const refValue = this.param.paramDefinition.referencedValue; + try { + refValue.getParamValues(); + return false; + } catch (e) { + return true; + } + } + return false; + } + constructor( private intlService: I18nService ) { @@ -100,6 +130,18 @@ export class ParamLinkComponent implements OnChanges, Observer, OnDestroy { return this._currentIndex !== -1 && this.param.isValid; } + public get uitextVariated() { + return this.intlService.localizeText("INFO_PARAMFIELD_VARIATED"); + } + + public get uitextCalculated() { + return this.intlService.localizeText("INFO_PARAMFIELD_CALCULATED"); + } + + public get uitextAwaitingCalculation() { + return this.intlService.localizeText("INFO_PARAMFIELD_AWAITING_CALCULATION"); + } + /** * Label d'une entrée du select des paramètres liés */ diff --git a/src/locale/messages.en.json b/src/locale/messages.en.json index 76628a095..d8d592240 100644 --- a/src/locale/messages.en.json +++ b/src/locale/messages.en.json @@ -166,6 +166,8 @@ "INFO_PABPUISSANCE_TITRE_COURT": "FL: diss. power", "INFO_PARALLELSTRUCTURE_TITRE": "Parallel structures", "INFO_PARALLELSTRUCTURE_TITRE_COURT": "// structures", + "INFO_PARAMFIELD_AWAITING_CALCULATION": "Awaiting calculation", + "INFO_PARAMFIELD_CALCULATED": "Calculated", "INFO_PARAMFIELD_GRAPH_TYPE": "Graph type", "INFO_PARAMFIELD_GRAPH_TYPE_HISTOGRAM": "Histogram", "INFO_PARAMFIELD_GRAPH_SELECT_X_AXIS": "Variable for X axis", @@ -191,6 +193,7 @@ "INFO_PARAMFIELD_PARAMVARIER_VALUES_FORMAT_ERROR": "Incorrect format; accepted separator: %s", "INFO_PARAMFIELD_VALEURMAXI": "To maximum value", "INFO_PARAMFIELD_VALEURMINI": "From minimum value", + "INFO_PARAMFIELD_VARIATED": "Variated", "INFO_PARAMMODE_MINMAX": "Min/max", "INFO_PARAMMODE_LIST": "Values list", "INFO_REGIMEUNIFORME_TITRE": "Uniform flow calculation", diff --git a/src/locale/messages.fr.json b/src/locale/messages.fr.json index 4a03ee164..d269ba5f0 100644 --- a/src/locale/messages.fr.json +++ b/src/locale/messages.fr.json @@ -166,6 +166,8 @@ "INFO_PABPUISSANCE_TITRE_COURT": "PAB : puissance", "INFO_PARALLELSTRUCTURE_TITRE": "Lois d'ouvrages", "INFO_PARALLELSTRUCTURE_TITRE_COURT": "Ouvrages", + "INFO_PARAMFIELD_AWAITING_CALCULATION": "En attente de calcul", + "INFO_PARAMFIELD_CALCULATED": "Calculé", "INFO_PARAMFIELD_GRAPH_TYPE": "Type de graphe", "INFO_PARAMFIELD_GRAPH_TYPE_HISTOGRAM": "Histogramme", "INFO_PARAMFIELD_GRAPH_SELECT_X_AXIS": "Variable en abscisse", @@ -191,6 +193,7 @@ "INFO_PARAMFIELD_PARAMVARIER_VALUES_FORMAT_ERROR": "Format incorrect; séparateurs acceptés: %s", "INFO_PARAMFIELD_VALEURMAXI": "À la valeur maximum", "INFO_PARAMFIELD_VALEURMINI": "De la valeur minimum", + "INFO_PARAMFIELD_VARIATED": "Varié", "INFO_PARAMMODE_MINMAX": "Min/max", "INFO_PARAMMODE_LIST": "Liste de valeurs", "INFO_REGIMEUNIFORME_TITRE": "Régime uniforme", -- GitLab