Skip to content

Commit

Permalink
ui: fix translation issues
Browse files Browse the repository at this point in the history
* Translates labels in patron circulation > fees tab.
* Closes rero/rero-ils#1371.

Co-Authored-by: Alicia Zangger <alicia.zangger@rero.ch>
  • Loading branch information
Alicia Zangger committed Nov 10, 2020
1 parent 2d270d2 commit b87358f
Show file tree
Hide file tree
Showing 6 changed files with 43 additions and 24 deletions.
20 changes: 1 addition & 19 deletions projects/admin/src/app/circulation/patron-transaction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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<PatronTransactionEvent>
*/
Expand Down Expand Up @@ -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();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
</div>
<div class="col-lg-9 event-content">
<div class="row" [ngClass]="{'event-highlight': event.type === patronTransactionEventType.DISPUTE}">
<div class="col-lg-9 d-inline-block text-truncate label">{{ event.label }}</div>
<div class="col-lg-9 d-inline-block text-truncate label">{{ label }}</div>
<div class="col-lg-2 text-lg-right">
<span class="badge"
*ngIf="event.type !== patronTransactionEventType.DISPUTE"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { Component, Input } from '@angular/core';
import { TranslateService } from '@ngx-translate/core';
import { OrganisationService } from '../../../../service/organisation.service';
import { PatronTransactionEvent, PatronTransactionEventType } from '../../../patron-transaction';

Expand All @@ -17,7 +18,15 @@ export class PatronTransactionEventComponent {
/** store a reference to enum to use in html template */
patronTransactionEventType = PatronTransactionEventType;

constructor(private _organisationService: OrganisationService) { }
/**
*
* @param _organisationService - OrganisationService
* @param _translateService - TranslateService
*/
constructor(
private _organisationService: OrganisationService,
private _translateService: TranslateService
) { }

/** Get current organisation
* @return: current organisation
Expand All @@ -26,4 +35,13 @@ export class PatronTransactionEventComponent {
return this._organisationService.organisation;
}

/**
* Get the best possible label of the transaction event
* @return label to display as string
*/
get label(): string {
return (this.event.subtype)
? `${this._translateService.instant(this.event.type.toString())} [${this._translateService.instant(this.event.subtype)}]`
: this._translateService.instant(this.event.type.toString());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
</button>
{{ transaction.creation_date | dateTranslate :'shortDate' }}
</div>
<div class="col-lg-7 d-inline-block text-truncate">{{ transaction.label }}</div>
<div class="col-lg-7 d-inline-block text-truncate">{{ label }}</div>
<div class="col-lg-3 text-lg-right">{{ transactionAmount | currency: organisation.default_currency }}</div>
</div>
<div *ngIf="!isCollapsed" class="mt-2">
Expand Down
Original file line number Diff line number Diff line change
@@ -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';
Expand All @@ -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() {
Expand Down Expand Up @@ -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
*/
Expand Down
2 changes: 1 addition & 1 deletion projects/admin/src/app/class/documents-typeahead.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit b87358f

Please sign in to comment.