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.birth_date | dateTranslate:'mediumDate' }} +
+
+ -
- {{ patron.city}} +
+
-
-
- {{ patronType }} +
+
+
{{ patron.birth_date | dateTranslate:'mediumDate' }}
+
{{ patron.city }}
-
- - {{ 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..9a74a2ce6 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; + @Input() circulationMessages = false; @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', '
')) - }; - }); + + getBootstrapColor(level: string): string { + return getBootstrapLevel(level); } } 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..eac760617 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() { @@ -158,7 +154,7 @@ export class LoanComponent implements OnInit, OnDestroy { } else { if (newItem.pending_loans && newItem.pending_loans[0].patron_pid !== this.patron.pid) { this._toastService.error( - this._translate.instant('Checkout impossible: the item is pending by another patron'), + this._translate.instant('Checkout impossible: the item is requested by another patron'), this._translate.instant('Checkout') ); this.searchText = ''; @@ -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,24 @@ 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') - ); + let message = errorMessage || this._translate.instant('Checkout is not allowed by circulation policy'); + let title = this._translate.instant('Circulation'); + if (message.includes(': ')) { + const splittedData = message.split(': ', 2); + title = splittedData[0].trim(); + message = splittedData[1].trim(); + message = message.charAt(0).toUpperCase() + message.slice(1); } + this._toastService.error( + message, + title, + {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..90211bd8b 100644 --- a/projects/admin/src/app/circulation/patron/main/main.component.html +++ b/projects/admin/src/app/circulation/patron/main/main.component.html @@ -17,18 +17,11 @@
-
- -
-
- -
- +
@@ -39,10 +32,12 @@ class="nav-link" routerLinkActive="active" [routerLinkActiveOptions]="{exact: true}" - [routerLink]="['/circulation', 'patron', patron.patron.barcode, 'loan']" - translate - >Checkin/Checkout + [routerLink]="['/circulation', 'patron', patron.patron.barcode, 'loan']"> + {{ 'Checkin/Checkout' | translate }} + + {{ getCirculationStatistics('loans') }} + +