diff --git a/projects/admin/src/app/circulation/checkin/checkin.component.html b/projects/admin/src/app/circulation/checkin/checkin.component.html index b79c96043..4432d2438 100644 --- a/projects/admin/src/app/circulation/checkin/checkin.component.html +++ b/projects/admin/src/app/circulation/checkin/checkin.component.html @@ -31,12 +31,6 @@ -
-
- -
-
-
{{ patron.last_name }} - , {{ patron.first_name }} + , {{ patron.first_name }}
@@ -38,32 +38,36 @@

-
- {{ patron.birth_date | dateTranslate:'mediumDate' }} -
-
- {{ patron.city}} -
+
{{ patron.birth_date | dateTranslate:'mediumDate' }}
+
{{ patron.city }}
-
- {{ patronType }} -
-
- - {{ patron.patron.barcode }} - +
+ {{ patronTypeName }}
+
{{ patron.patron.barcode }}
- - + + + + + + + + + + diff --git a/projects/admin/src/app/circulation/patron/card/card.component.ts b/projects/admin/src/app/circulation/patron/card/card.component.ts index 4c0e6df70..653e2609a 100644 --- a/projects/admin/src/app/circulation/patron/card/card.component.ts +++ b/projects/admin/src/app/circulation/patron/card/card.component.ts @@ -15,56 +15,28 @@ * along with this program. If not, see . */ -import { Component, EventEmitter, Input, OnInit, Output } from '@angular/core'; -import { DomSanitizer, SafeHtml } from '@angular/platform-browser'; -import { RecordService } from '@rero/ng-core'; -import { map } from 'rxjs/operators'; +import { Component, EventEmitter, Input, Output } from '@angular/core'; import { User } from '../../../class/user'; +import { getBootstrapLevel } from '../../../utils/utils'; + @Component({ selector: 'admin-circulation-patron-detailed', templateUrl: './card.component.html', styleUrls: ['./card.component.scss'] }) -export class CardComponent implements OnInit { +export class CardComponent { @Input() patron: User; @Output() clearPatron = new EventEmitter(); - patronType$: any; - - constructor( - private recordService: RecordService, - private _sanitizer: DomSanitizer - ) { } - - ngOnInit() { - if (this.patron) { - this.patronType$ = this.recordService.getRecord('patron_types', this.patron.patron.type.pid).pipe( - map(patronType => patronType.metadata.name) - ); - } - } clear() { if (this.patron) { this.clearPatron.emit(this.patron); } } - /** - * Get the patron notes. - * - * It replace a new line to the corresponding html code. - * Allows to render html. - */ - get notes(): Array<{ type: string, content: SafeHtml }> { - if (!this.patron || !this.patron.notes || this.patron.notes.length < 1) { - return null; - } - return this.patron.notes.map((note: any) => { - return { - type: note.type, - content: this._sanitizer.bypassSecurityTrustHtml( - note.content.replace('\n', '
')) - }; - }); + + getBoootstrapColor(level: string): string { + return getBootstrapLevel(level); + return 'info'; } } diff --git a/projects/admin/src/app/circulation/patron/loan/loan.component.ts b/projects/admin/src/app/circulation/patron/loan/loan.component.ts index 43c74c135..6959a92e3 100644 --- a/projects/admin/src/app/circulation/patron/loan/loan.component.ts +++ b/projects/admin/src/app/circulation/patron/loan/loan.component.ts @@ -21,15 +21,13 @@ import { ToastrService } from 'ngx-toastr'; import { forkJoin, Subscription } from 'rxjs'; import { Item, ItemAction, ItemNoteType, ItemStatus } from '../../../class/items'; import { User } from '../../../class/user'; -import { PatronBlockedMessagePipe } from '../../../pipe/patron-blocked-message.pipe'; import { ItemsService } from '../../../service/items.service'; import { PatronService } from '../../../service/patron.service'; import { UserService } from '../../../service/user.service'; @Component({ selector: 'admin-loan', - templateUrl: './loan.component.html', - providers: [PatronBlockedMessagePipe] + templateUrl: './loan.component.html' }) export class LoanComponent implements OnInit, OnDestroy { public placeholder: string = this._translate.instant( @@ -65,15 +63,13 @@ export class LoanComponent implements OnInit, OnDestroy { * @param _toastService: Toastr Service * @param _patronService: Patron Service * @param _userService: UserService - * @param _patronBlockedMessagePipe: PatronBlockingPipe */ constructor( private _itemsService: ItemsService, private _translate: TranslateService, private _toastService: ToastrService, private _patronService: PatronService, - private _userService: UserService, - private _patronBlockedMessagePipe: PatronBlockedMessagePipe + private _userService: UserService ) {} ngOnInit() { @@ -212,12 +208,14 @@ export class LoanComponent implements OnInit, OnDestroy { this._translate.instant('Checkin') ); } + this.patron.decrementCirculationStatistic('loans'); break; } case ItemAction.checkout: { this._displayCirculationNote(newItem, ItemNoteType.CHECKOUT); this.checkedOutItems.unshift(newItem); this.checkedInItems = this.checkedInItems.filter(currItem => currItem.pid !== newItem.pid); + this.patron.incrementCirculationStatistic('loans'); break; } case ItemAction.extend_loan: { @@ -236,23 +234,17 @@ export class LoanComponent implements OnInit, OnDestroy { errorMessage = err.error.message; } if (err.error.status === 403) { - // Specific case when user is blocked (for better user comprehension) - if (errorMessage !== '' && errorMessage.startsWith('BLOCKED USER')) { - const blockedMessage = this._patronBlockedMessagePipe.transform(this.patron); - this._toastService.error( - `${this._translate.instant('Checkout not possible.')} ${blockedMessage}`, - this._translate.instant('Circulation') - ); - } else { - this._toastService.error( - this._translate.instant('Checkout is not allowed by circulation policy'), - this._translate.instant('Checkout') - ); - } + const message = errorMessage || this._translate.instant('Checkout is not allowed by circulation policy'); + this._toastService.error( + message, + this._translate.instant('Circulation'), + {disableTimeOut: true, closeButton: true, enableHtml: true} + ); } else { this._toastService.error( this._translate.instant('An error occurred on the server: ') + errorMessage, - this._translate.instant('Circulation') + this._translate.instant('Circulation'), + {disableTimeOut: true, closeButton: true, enableHtml: true} ); } this.searchText = ''; diff --git a/projects/admin/src/app/circulation/patron/main/main.component.html b/projects/admin/src/app/circulation/patron/main/main.component.html index 68fa54e87..bd9030b79 100644 --- a/projects/admin/src/app/circulation/patron/main/main.component.html +++ b/projects/admin/src/app/circulation/patron/main/main.component.html @@ -25,12 +25,6 @@ -
- -
-