diff --git a/projects/admin/src/app/circulation/patron/ill-request/ill-request-item/ill-request-item.component.ts b/projects/admin/src/app/circulation/patron/ill-request/ill-request-item/ill-request-item.component.ts index 1905e734e..effe50a4f 100644 --- a/projects/admin/src/app/circulation/patron/ill-request/ill-request-item/ill-request-item.component.ts +++ b/projects/admin/src/app/circulation/patron/ill-request/ill-request-item/ill-request-item.component.ts @@ -15,8 +15,8 @@ * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see . */ -import { Component, inject, Input } from '@angular/core'; -import { IllRequestsService } from '@app/admin/service/ill-requests.service'; +import { Component, Input } from '@angular/core'; +import { getTagSeverityFromStatus } from '@app/admin/utils/utils'; @Component({ selector: 'admin-ill-request-item', @@ -25,8 +25,6 @@ import { IllRequestsService } from '@app/admin/service/ill-requests.service'; }) export class IllRequestItemComponent { - private illRequestService: IllRequestsService = inject(IllRequestsService); - // COMPONENT ATTRIBUTES ===================================================== /** ILL record. */ @Input() record: any; @@ -36,6 +34,6 @@ export class IllRequestItemComponent { // COMPONENT FUNCTIONS ====================================================== /** get the bootstrap color to apply on the request status badge */ badgeColor(status: string): string { - return this.illRequestService.badgeColor(status); + return getTagSeverityFromStatus(status) ; } } diff --git a/projects/admin/src/app/record/brief-view/ill-requests-brief-view/ill-requests-brief-view.component.html b/projects/admin/src/app/record/brief-view/ill-requests-brief-view/ill-requests-brief-view.component.html index 0ea1c72ed..96e1d5dd5 100644 --- a/projects/admin/src/app/record/brief-view/ill-requests-brief-view/ill-requests-brief-view.component.html +++ b/projects/admin/src/app/record/brief-view/ill-requests-brief-view/ill-requests-brief-view.component.html @@ -16,18 +16,18 @@ along with this program. If not, see . --> @if (record && requester) { - {{ record.metadata.status }} -
+
{{ record.metadata.document.title }} +
@if (record.metadata.document.authors) { -
{{ record.metadata.document.authors }}
+
{{ record.metadata.document.authors }}
} -
-
Requested by
-
+ } diff --git a/projects/admin/src/app/record/brief-view/ill-requests-brief-view/ill-requests-brief-view.component.ts b/projects/admin/src/app/record/brief-view/ill-requests-brief-view/ill-requests-brief-view.component.ts index 5c16f0fa9..2ab22292e 100644 --- a/projects/admin/src/app/record/brief-view/ill-requests-brief-view/ill-requests-brief-view.component.ts +++ b/projects/admin/src/app/record/brief-view/ill-requests-brief-view/ill-requests-brief-view.component.ts @@ -16,8 +16,8 @@ * along with this program. If not, see . */ import { Component, inject, Input, OnInit } from '@angular/core'; +import { getTagSeverityFromStatus } from '@app/admin/utils/utils'; import { RecordService, ResultItem } from '@rero/ng-core'; -import { ILLRequestStatus } from '../../../classes/ill-request'; @Component({ selector: 'admin-ill-requests-brief-view', @@ -38,19 +38,7 @@ export class IllRequestsBriefViewComponent implements ResultItem, OnInit { /** the requester of the ILL request */ requester = null; - // GETTER FUNCTIONS ========================================================== - /** get the bootstrap color to apply on the request status badge */ - get badgeColor(): string { - if (this.record) { - switch (this.record.metadata.status) { - case ILLRequestStatus.PENDING: return 'warning'; - case ILLRequestStatus.VALIDATED: return 'success'; - case ILLRequestStatus.DENIED: return 'danger'; - default: return 'secondary'; - } - } - return 'secondary'; - } + tagSeverity: string; /** Init hook */ ngOnInit() { @@ -58,7 +46,7 @@ export class IllRequestsBriefViewComponent implements ResultItem, OnInit { this.recordService.getRecord('patrons', this.record.metadata.patron.pid).subscribe( (patron) => this.requester = patron.metadata ); + this.tagSeverity = getTagSeverityFromStatus(this.record.metadata.status); } } - } diff --git a/projects/admin/src/app/record/detail-view/ill-request-detail-view/ill-request-detail-view.component.html b/projects/admin/src/app/record/detail-view/ill-request-detail-view/ill-request-detail-view.component.html index a894f0eb7..9db69769d 100644 --- a/projects/admin/src/app/record/detail-view/ill-request-detail-view/ill-request-detail-view.component.html +++ b/projects/admin/src/app/record/detail-view/ill-request-detail-view/ill-request-detail-view.component.html @@ -16,22 +16,24 @@ --> @if (record) {

{{ 'ILL request' | translate }} #{{ record.metadata.pid }}

-
-
- - {{ 'Document information' | translate }} -
+
-
+ + +
+   + {{ 'Document information' | translate }} +
+

{{ record.metadata.document.title }}

-
+ -
-
+ -
-
- - {{ 'Request additional informations' | translate }} -
-
-
- @if (record.metadata.found_in; as source) { -
Found in
-
- {{ source.source }} — {{ source.url }} -
- } -
Requester
-
- @if (requester && requester.patron && requester.patron.barcode[0]) { - - {{ requester.last_name }} - @if (requester.first_name; as firstName) { - , {{ firstName }} - } - - } -
-
Request date
-
{{ record.created | dateTranslate : 'medium' }}
-
Request status
-
- - {{ record.metadata.status }} - -
-
Loan status
-
- - {{ record.metadata.loan_status || 'None' | translate }} - -
-
Pickup location
-
- @if (record.metadata.pickup_location.pid | getRecord:'locations':'field':'ill_pickup_name' | async; as location_name) { - {{ location_name }} - } + + +
+   + {{ 'Request additional informations' | translate }} +
+
+ -
- - @if (record.metadata.notes) { -
- - {{ 'Notes' | translate }} -
-
-
+
+ @if (record.metadata.copy) { +
Pages
+
{{ record.metadata.pages }}
+ } +
+ + + + @if (record.metadata.notes) { + + +
+   + {{ 'Notes' | translate }} +
+
+ - - } +
+ } } diff --git a/projects/admin/src/app/record/detail-view/ill-request-detail-view/ill-request-detail-view.component.ts b/projects/admin/src/app/record/detail-view/ill-request-detail-view/ill-request-detail-view.component.ts index b4aef024b..3ed19d847 100644 --- a/projects/admin/src/app/record/detail-view/ill-request-detail-view/ill-request-detail-view.component.ts +++ b/projects/admin/src/app/record/detail-view/ill-request-detail-view/ill-request-detail-view.component.ts @@ -15,10 +15,10 @@ * along with this program. If not, see . */ import { Component, inject, OnInit } from '@angular/core'; +import { getTagSeverityFromStatus } from '@app/admin/utils/utils'; import { RecordService } from '@rero/ng-core'; import { DetailRecord } from '@rero/ng-core/lib/record/detail/view/detail-record'; import { Observable } from 'rxjs'; -import { IllRequestsService } from '../../../service/ill-requests.service'; @Component({ selector: 'admin-ill-request-detail-view', @@ -27,7 +27,6 @@ import { IllRequestsService } from '../../../service/ill-requests.service'; export class IllRequestDetailViewComponent implements DetailRecord, OnInit { private recordService: RecordService = inject(RecordService); - private illRequestService: IllRequestsService = inject(IllRequestsService); // COMPONENT ATTRIBUTES ======================================================= /** The observable resolving record data */ @@ -40,20 +39,18 @@ export class IllRequestDetailViewComponent implements DetailRecord, OnInit { /** the requester of the ILL request */ requester = null; + tagSeverity: string; + loanTagSeverity: string; + /** OnInit hook */ ngOnInit(): void { this.record$.subscribe((record) => { this.record = record; + this.tagSeverity = getTagSeverityFromStatus(record.metadata.status); + this.loanTagSeverity = getTagSeverityFromStatus(record.metadata.loan_status); this.recordService.getRecord('patrons', this.record.metadata.patron.pid).subscribe( (patron) => this.requester = patron.metadata ); }); } - - // FUNCTIONS ================================================================= - /** get the bootstrap color to apply on the request status badge */ - badgeColor(status: string): string { - return this.illRequestService.badgeColor(status); - } - } diff --git a/projects/admin/src/app/service/ill-requests.service.spec.ts b/projects/admin/src/app/service/ill-requests.service.spec.ts deleted file mode 100644 index d41340a1f..000000000 --- a/projects/admin/src/app/service/ill-requests.service.spec.ts +++ /dev/null @@ -1,28 +0,0 @@ -/* - * RERO ILS UI - * Copyright (C) 2020 RERO - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published by - * the Free Software Foundation, version 3 of the License. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ -import { TestBed } from '@angular/core/testing'; - -import { IllRequestsService } from './ill-requests.service'; - -describe('IllRequestsService', () => { - beforeEach(() => TestBed.configureTestingModule({})); - - it('should be created', () => { - const service: IllRequestsService = TestBed.inject(IllRequestsService); - expect(service).toBeTruthy(); - }); -}); diff --git a/projects/admin/src/app/service/ill-requests.service.ts b/projects/admin/src/app/service/ill-requests.service.ts deleted file mode 100644 index 72f4a8bbf..000000000 --- a/projects/admin/src/app/service/ill-requests.service.ts +++ /dev/null @@ -1,51 +0,0 @@ -/* - * RERO ILS UI - * Copyright (C) 2020 RERO - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published by - * the Free Software Foundation, version 3 of the License. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ -import { Injectable } from '@angular/core'; -import { ILLRequestStatus } from '../classes/ill-request'; -import { LoanState } from '../classes/loans'; - -@Injectable({ - providedIn: 'root' -}) -export class IllRequestsService { - - /** - * Get the bootstrap color to apply on the request status badge - * @param status: the status to check - * @return the bootstrap color to use for this request (badge, alert, ...). - */ - badgeColor(status: any): string { - if (status) { - switch (status) { - case ILLRequestStatus.PENDING: - case LoanState.PENDING: - return 'warning'; - case ILLRequestStatus.VALIDATED: - case LoanState.ITEM_AT_DESK: - return 'success'; - case ILLRequestStatus.DENIED: - return 'danger'; - case LoanState.ITEM_ON_LOAN: - case LoanState.ITEM_RETURNED: - return 'info'; - default: - return 'secondary'; - } - } - return 'secondary'; - } -} diff --git a/projects/admin/src/app/utils/utils.ts b/projects/admin/src/app/utils/utils.ts index b7d6d182a..f3942a47d 100644 --- a/projects/admin/src/app/utils/utils.ts +++ b/projects/admin/src/app/utils/utils.ts @@ -16,6 +16,9 @@ * along with this program. If not, see . */ +import { ILLRequestStatus } from "../classes/ill-request"; +import { LoanState } from "../classes/loans"; + /** Convert a level string to boostrap level * @param level - string: the level string to convert * @return the severity of message (info by default) @@ -32,3 +35,21 @@ export function getSeverity(level: string) { return 'info'; } } + +export function getTagSeverityFromStatus(status: string): string { + switch (status) { + case ILLRequestStatus.PENDING: + case LoanState.PENDING: + return 'warning'; + case ILLRequestStatus.VALIDATED: + case LoanState.ITEM_AT_DESK: + return 'success'; + case ILLRequestStatus.DENIED: + return 'danger'; + case LoanState.ITEM_ON_LOAN: + case LoanState.ITEM_RETURNED: + return 'info'; + default: + return 'secondary'; + } +}