diff --git a/src/app/components/generic-calculator/calculator.component.html b/src/app/components/generic-calculator/calculator.component.html index 7770790c0f6d0e5ec52c58c2d1084cba141e3b39..2cde586a44cc4a875fc0082e6391d2052535b419 100644 --- a/src/app/components/generic-calculator/calculator.component.html +++ b/src/app/components/generic-calculator/calculator.component.html @@ -25,6 +25,15 @@ <!-- on utilise [innerHTML] pour que les codes HTML comme soient interprétés correctement --> <mat-card-title> <h1 [innerHTML]="uitextTitre"></h1> + <div id="calculator-used-by" *ngIf="calculatorsUsingThisOne.length > 0"> + {{ uitextUsedBy }} + <span *ngFor="let c of calculatorsUsingThisOne; let i = index" > + <a class="used-by-item" (click)="toCalc(c.uid)"> + {{ c.label }} + </a> + <span *ngIf="i < calculatorsUsingThisOne.length - 1">, </span> + </span> + </div> </mat-card-title> </mat-card-header> diff --git a/src/app/components/generic-calculator/calculator.component.scss b/src/app/components/generic-calculator/calculator.component.scss index e10f322335ea2b461e719939b14e1d4507918859..b520db9c9a1cc298d0e0bbd4aebbe2514c1fbfba 100644 --- a/src/app/components/generic-calculator/calculator.component.scss +++ b/src/app/components/generic-calculator/calculator.component.scss @@ -77,6 +77,16 @@ mat-card { mat-card-title { font-size: 16px; margin-bottom: 8px; + + #calculator-used-by { + font-weight: normal; + margin-top: -8px; + font-size: .9em; + + a.used-by-item { + cursor: pointer; + } + } } } diff --git a/src/app/components/generic-calculator/calculator.component.ts b/src/app/components/generic-calculator/calculator.component.ts index 1d28af12b823567325dd9291e1d2d1f1b99e0bfe..4bdf8c67512ca356aedb8942187b45b1b4c90567 100644 --- a/src/app/components/generic-calculator/calculator.component.ts +++ b/src/app/components/generic-calculator/calculator.component.ts @@ -211,6 +211,10 @@ export class GenericCalculatorComponent implements OnInit, DoCheck, AfterViewChe return this.intlService.localizeText("INFO_CALCULATOR_CLOSE"); } + public get uitextUsedBy() { + return this.intlService.localizeText("INFO_CALCULATOR_USED_BY"); + } + public get quicknavItems() { const elts = [ "input", "results" ]; if (this.isWide && this.hasResults) { @@ -294,6 +298,22 @@ export class GenericCalculatorComponent implements OnInit, DoCheck, AfterViewChe } } + /** open calculator identified by given UID */ + public toCalc(id: string) { + this.appComponent.toCalc(id); + } + + /** list of calculators having a link pointing to the current calculator */ + public get calculatorsUsingThisOne(): any { + const sources = Session.getInstance().getDependingNubs(this._formulaire.currentNub.uid, undefined, true); + return sources.map((s) => { + return { + label: this.formulaireService.getFormulaireFromNubId(s.uid).calculatorName, + uid: s.uid + }; + }); + } + /** * Moves the view to the start of the "Results" section */ diff --git a/src/locale/messages.en.json b/src/locale/messages.en.json index 9dc8aff162ced5cf2ceec2e812fa4ca4d2b44f5f..2a5fbddb0e16299c6106f23b7b2ff84bc7587587 100644 --- a/src/locale/messages.en.json +++ b/src/locale/messages.en.json @@ -59,6 +59,7 @@ "INFO_CALCULATOR_RESULTS_GENERATE_PAB": "Generate a fish ladder", "INFO_CALCULATOR_RESULTS_TITLE": "Results", "INFO_CALCULATOR_SAVE": "Save", + "INFO_CALCULATOR_USED_BY": "Used by", "INFO_CALCULATOR_VALEURS": "Values", "INFO_CLOISONS_TITRE_COURT": "Cross walls", "INFO_CLOISONS_TITRE": "Fish ladder: Cross walls", diff --git a/src/locale/messages.fr.json b/src/locale/messages.fr.json index d4ed07a7069511039d44a0fae405c2a2ecb121a2..a9211fb769762dd8787d122ba13f406f78b32fc1 100644 --- a/src/locale/messages.fr.json +++ b/src/locale/messages.fr.json @@ -59,6 +59,7 @@ "INFO_CALCULATOR_RESULTS_GENERATE_PAB": "Générer une passe à bassins", "INFO_CALCULATOR_RESULTS_TITLE": "Résultats", "INFO_CALCULATOR_SAVE": "Enregistrer", + "INFO_CALCULATOR_USED_BY": "Utilisé par", "INFO_CALCULATOR_VALEURS": "Valeurs", "INFO_CLOISONS_TITRE_COURT": "Cloisons", "INFO_CLOISONS_TITRE": "Passe à bassins : Cloisons",