From b87358f9c3be647f5e90be1627dae637198c1ed4 Mon Sep 17 00:00:00 2001 From: Alicia Zangger Date: Mon, 9 Nov 2020 15:07:01 +0100 Subject: [PATCH] ui: fix translation issues * Translates labels in patron circulation > fees tab. * Closes rero/rero-ils#1371. Co-Authored-by: Alicia Zangger --- .../src/app/circulation/patron-transaction.ts | 20 +----------------- .../patron-transaction-event.component.html | 2 +- .../patron-transaction-event.component.ts | 20 +++++++++++++++++- .../patron-transaction.component.html | 2 +- .../patron-transaction.component.ts | 21 ++++++++++++++++++- .../src/app/class/documents-typeahead.ts | 2 +- 6 files changed, 43 insertions(+), 24 deletions(-) diff --git a/projects/admin/src/app/circulation/patron-transaction.ts b/projects/admin/src/app/circulation/patron-transaction.ts index 6e2d2a083..e03ed1e88 100644 --- a/projects/admin/src/app/circulation/patron-transaction.ts +++ b/projects/admin/src/app/circulation/patron-transaction.ts @@ -18,8 +18,8 @@ /* tslint:disable */ // required as json properties is not lowerCamelCase -import * as moment from 'moment'; import { marker } from '@biesbjerg/ngx-translate-extract-marker'; +import * as moment from 'moment'; export function _(str) { return marker(str); @@ -53,14 +53,6 @@ export class PatronTransaction { Object.assign(this, obj); } - /** - * Get the label of the transaction depending of transaction.type - * @return label/title of the transaction as string - */ - get label(): string { - return (this.type === 'other') ? this.note : this.type; - } - /** Get events linked to the transaction sorted by creation date * @return Array */ @@ -89,14 +81,4 @@ export class PatronTransactionEvent { constructor(obj?: any){ Object.assign(this, obj); } - - /** - * Get the best possible label of the transaction event - * @return label to display as string - */ - get label(): string { - return (this.subtype) - ? `${this.type.toString()} [${this.subtype}]` - : this.type.toString(); - } } diff --git a/projects/admin/src/app/circulation/patron/patron-transactions/patron-transaction-event/patron-transaction-event.component.html b/projects/admin/src/app/circulation/patron/patron-transactions/patron-transaction-event/patron-transaction-event.component.html index e95eccd9a..4bc9eed7d 100644 --- a/projects/admin/src/app/circulation/patron/patron-transactions/patron-transaction-event/patron-transaction-event.component.html +++ b/projects/admin/src/app/circulation/patron/patron-transactions/patron-transaction-event/patron-transaction-event.component.html @@ -5,7 +5,7 @@
-
{{ event.label }}
+
{{ label }}
{{ transaction.creation_date | dateTranslate :'shortDate' }}
-
{{ transaction.label }}
+
{{ label }}
{{ transactionAmount | currency: organisation.default_currency }}
diff --git a/projects/admin/src/app/circulation/patron/patron-transactions/patron-transaction/patron-transaction.component.ts b/projects/admin/src/app/circulation/patron/patron-transactions/patron-transaction/patron-transaction.component.ts index 795b3d0a0..d72fe82b2 100644 --- a/projects/admin/src/app/circulation/patron/patron-transactions/patron-transaction/patron-transaction.component.ts +++ b/projects/admin/src/app/circulation/patron/patron-transactions/patron-transaction/patron-transaction.component.ts @@ -1,4 +1,5 @@ import { Component, Input, OnInit } from '@angular/core'; +import { TranslateService } from '@ngx-translate/core'; import { BsModalService } from 'ngx-bootstrap/modal'; import { OrganisationService } from '../../../../service/organisation.service'; import { PatronTransaction, PatronTransactionEventType, PatronTransactionStatus } from '../../../patron-transaction'; @@ -23,10 +24,18 @@ export class PatronTransactionComponent implements OnInit { /** reference to PatronTransactionStatus -- used in HTML template */ public patronTransactionStatus = PatronTransactionStatus; + /** + * + * @param _organisationService - OrganisationService + * @param _patronTransactionService - PatronTransactionService + * @param _modalService - BsModalService + * @param _translateService - TranslateService + */ constructor( private _organisationService: OrganisationService, private _patronTransactionService: PatronTransactionService, - private _modalService: BsModalService + private _modalService: BsModalService, + private _translateService: TranslateService ) {} ngOnInit() { @@ -63,6 +72,16 @@ export class PatronTransactionComponent implements OnInit { return this._organisationService.organisation; } + /** + * Get the label of the transaction depending of transaction.type + * @return label/title of the transaction as string + */ + get label(): string { + return (this.transaction.type === 'other') + ? this._translateService.instant(this.transaction.note) + : this._translateService.instant(this.transaction.type); + } + /** Check if the transaction contains a 'dispute' linked event * @return: True if transaction is still open and contains a 'dispute' event; False otherwise */ diff --git a/projects/admin/src/app/class/documents-typeahead.ts b/projects/admin/src/app/class/documents-typeahead.ts index 918ba0aef..30631d130 100644 --- a/projects/admin/src/app/class/documents-typeahead.ts +++ b/projects/admin/src/app/class/documents-typeahead.ts @@ -39,7 +39,7 @@ export class DocumentsTypeahead { * Constructor * @param _apiService - ApiService * @param _recordService - RecordService - * @param _translateService - TranslateService + * @param _mainTitlePipe - MainTitlePipe */ constructor( @Inject(ApiService) private _apiService: ApiService,