Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

primeng: admin ill requests #1226

Merged
merged 1 commit into from
Dec 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
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',
Expand All @@ -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;
Expand All @@ -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) ;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,18 +16,18 @@
along with this program. If not, see <http://www.gnu.org/licenses/>.
-->
@if (record && requester) {
<span class="badge badge-{{ badgeColor }} float-right px-2 py-1" translate>{{ record.metadata.status }}</span>
<h5 class="mb-0">
<h5>
<a [routerLink]="[detailUrl.link]">
{{ record.metadata.document.title }}
</a>
<p-tag [severity]="tagSeverity" [value]="record.metadata.status | translate" />
</h5>
@if (record.metadata.document.authors) {
<div class="small">{{ record.metadata.document.authors }}</div>
<div class="mb-2">{{ record.metadata.document.authors }}</div>
}
<dl class="mt-2 row">
<dt class="col-sm-6 col-md-3 label-title" translate>Requested by</dt>
<dd class="col-sm-6 col-md-9 mb-0">
<dl class="metadata">
<dt translate>Requested by</dt>
<dd>
@if (requester && requester.patron && requester.patron.barcode[0]) {
<a [routerLink]="['/circulation', 'patron', requester.patron.barcode[0]]">
<span id="patron-last-name">{{ requester.last_name }}</span>
Expand All @@ -37,7 +37,7 @@ <h5 class="mb-0">
</a>
}
</dd>
<dt class="col-sm-6 col-md-3 label-title" translate>Request date</dt>
<dd class="col-sm-6 col-md-9 mb-0">{{ record.created | dateTranslate:'medium' }}</dd>
<dt translate>Request date</dt>
<dd>{{ record.created | dateTranslate:'medium' }}</dd>
</dl>
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
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',
Expand All @@ -38,27 +38,15 @@ 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() {
if (this.record) {
this.recordService.getRecord('patrons', this.record.metadata.patron.pid).subscribe(
(patron) => this.requester = patron.metadata
);
this.tagSeverity = getTagSeverityFromStatus(this.record.metadata.status);
}
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -16,22 +16,24 @@
-->
@if (record) {
<h1>{{ 'ILL request' | translate }} #{{ record.metadata.pid }}</h1>
<div class="card mt-5">
<h6 class="card-header">
<i class="fa fa-book pr-2"></i>
{{ 'Document information' | translate }}
</h6>
<div class="flex flex-column gap-2">
<!-- DOCUMENT INFORMATION'S -->
<div class="card-body">
<p-panel>
<ng-template pTemplate="header">
<h6>
<i class="fa fa-book"></i>&nbsp;
{{ 'Document information' | translate }}
</h6>
</ng-template>
<h3>{{ record.metadata.document.title }}</h3>
<dl class="mt-2 row">
<dl class="metadata">
@if (record.metadata.document.authors; as authors) {
<dt class="col-sm-5 col-md-3 col-lg-3 label-title" translate>Authors</dt>
<dd class="col-sm-6 col-md-8 col-lg-8 mb-1">{{ authors }}</dd>
<dt translate>Authors</dt>
<dd>{{ authors }}</dd>
}
@if (record.metadata.document.publisher || record.metadata.document.year) {
<dt class="col-sm-5 col-md-3 col-lg-3 label-title" translate>Edition</dt>
<dd class="col-sm-6 col-md-8 col-lg-8 mb-1">
<dt translate>Edition</dt>
<dd>
@if (record.metadata.document.publisher; as publisher) {
{{ publisher }}
}
Expand All @@ -41,12 +43,12 @@ <h3>{{ record.metadata.document.title }}</h3>
</dd>
}
@if (record.metadata.document.identifier; as identifier) {
<dt class="col-sm-5 col-md-3 col-lg-3 label-title" translate>Identifiers</dt>
<dd class="col-sm-6 col-md-8 col-lg-8 mb-1">{{ identifier }}</dd>
<dt translate>Identifiers</dt>
<dd>{{ identifier }}</dd>
}
@if (record.metadata.document.source; as source) {
<dt class="col-sm-5 col-md-3 col-lg-3 offset-1 label-title" translate>Published in</dt>
<dd class="col-sm-6 col-md-8 col-lg-8 mb-1">
<dt translate>Published in</dt>
<dd>
{{ source.journal_title }}
@if (source.volume || source.number) {
&nbsp;(@if (source.volume) { Vol.{{ source.volume }} }
Expand All @@ -56,82 +58,87 @@ <h3>{{ record.metadata.document.title }}</h3>
</dd>
}
</dl>
</div>
</div>
</p-panel>

<!-- REQUEST ADDITIONAL DETAILS -->
<div class="card mt-3">
<h6 class="card-header">
<i class="fa fa-info-circle pr-2"></i>
{{ 'Request additional informations' | translate }}
</h6>
<div class="card-body">
<dl class="mt-2 row">
@if (record.metadata.found_in; as source) {
<dt class="col-sm-5 col-md-3 col-lg-3 label-title" translate>Found in</dt>
<dd class="col-sm-6 col-md-8 col-lg-8 mb-1">
{{ source.source }} &mdash; <a class="rero-ils-external-link" href="{{ source.url }}">{{ source.url }}</a>
</dd>
}
<dt class="col-sm-5 col-md-3 col-lg-3 label-title" translate>Requester</dt>
<dd class="col-sm-6 col-md-8 col-lg-8 mb-1">
@if (requester && requester.patron && requester.patron.barcode[0]) {
<a [routerLink]="['/circulation', 'patron', requester.patron.barcode[0]]">
<span id="patron-last-name">{{ requester.last_name }}</span>
@if (requester.first_name; as firstName) {
<span id="patron-first-name">, {{ firstName }}</span>
}
</a>
}
</dd>
<dt class="col-sm-5 col-md-3 col-lg-3 label-title" translate>Request date</dt>
<dd class="col-sm-6 col-md-8 col-lg-8 mb-1">{{ record.created | dateTranslate : 'medium' }}</dd>
<dt class="col-sm-5 col-md-3 col-lg-3 label-title" translate>Request status</dt>
<dd class="col-sm-6 col-md-8 col-lg-8 mb-1">
<span class="badge badge-{{ badgeColor(record.metadata.status) }} px-2 py-1" translate>
{{ record.metadata.status }}
</span>
</dd>
<dt class="col-sm-5 col-md-3 col-lg-3 label-title" translate>Loan status</dt>
<dd class="col-sm-6 col-md-8 col-lg-8 mb-1">
<span class="badge badge-{{ badgeColor(record.metadata.loan_status) }} px-2 py-1" translate>
{{ record.metadata.loan_status || 'None' | translate }}
</span>
</dd>
<dt class="col-sm-5 col-md-3 col-lg-3 label-title" translate>Pickup location</dt>
<dd class="col-sm-6 col-md-8 col-lg-8 mb-1">
@if (record.metadata.pickup_location.pid | getRecord:'locations':'field':'ill_pickup_name' | async; as location_name) {
{{ location_name }}
}
<p-panel>
<ng-template pTemplate="header">
<h6 class=>
<i class="fa fa-info-circle"></i>&nbsp;
{{ 'Request additional informations' | translate }}
</h6>
</ng-template>
<dl class="metadata">
@if (record.metadata.found_in; as source) {
<dt translate>Found in</dt>
<dd>
{{ source.source }} &mdash; <a class="rero-ils-external-link" href="{{ source.url }}">{{ source.url }}</a>
</dd>
<dt class="col-sm-5 col-md-3 col-lg-3 label-title" translate>Scope</dt>
<dd class="col-sm-6 col-md-8 col-lg-8 mb-1">
@if (record.metadata.copy) {
<span translate>Copy</span>
} @else {
<span translate>Loan</span>
}
}
<dt translate>Requester</dt>
<dd>
@if (requester && requester.patron && requester.patron.barcode[0]) {
<a [routerLink]="['/circulation', 'patron', requester.patron.barcode[0]]">
<span id="patron-last-name">{{ requester.last_name }}</span>
@if (requester.first_name; as firstName) {
<span id="patron-first-name">, {{ firstName }}</span>
}
</a>
}
</dd>
<dt translate>Request date</dt>
<dd>{{ record.created | dateTranslate : 'medium' }}</dd>
<dt translate>Request status</dt>
<dd>
<p-tag [severity]="tagSeverity">
{{ record.metadata.status | translate }}
</p-tag>
</dd>
@if (record.metadata.loan_status) {
<dt translate>Loan status</dt>
<dd>
<p-tag [severity]="loanTagSeverity">
{{ record.metadata.loan_status | translate}}
</p-tag>
</dd>
}
<dt translate>Pickup location</dt>
<dd>
@if (record.metadata.pickup_location.pid | getRecord:'locations':'field':'ill_pickup_name' | async; as location_name) {
{{ location_name }}
}
</dd>
<dt translate>Scope</dt>
<dd>
@if (record.metadata.copy) {
<dt class="col-sm-5 col-md-3 col-lg-3 label-title" translate>Pages</dt>
<dd class="col-sm-6 col-md-8 col-lg-8 mb-1">{{ record.metadata.pages }}</dd>
<span translate>Copy</span>
} @else {
<span translate>Loan</span>
}
</dl>
</div>
<!-- NOTES :: public/staff -->
@if (record.metadata.notes) {
<div class="card-header">
<i class="fa fa-sticky-note-o pr-2"></i>
{{ 'Notes' | translate }}
</div>
<div class="card-body container">
<dl class="row mt-2">
</dd>
@if (record.metadata.copy) {
<dt translate>Pages</dt>
<dd>{{ record.metadata.pages }}</dd>
}
</dl>
</p-panel>

<!-- NOTES :: public/staff -->
@if (record.metadata.notes) {
<p-panel>
<ng-template pTemplate="header">
<h6 class=>
<i class="fa fa-sticky-note-o"></i>&nbsp;
{{ 'Notes' | translate }}
</h6>
</ng-template>
<dl class="metadata">
@for (note of record.metadata.notes; track note) {
<dt class="col-sm-5 col-md-3 col-lg-3 label-title" translate>{{ note.type }}</dt>
<dd class="col-sm-6 col-md-8 col-lg-8 mb-1" [innerHTML]="note.content | nl2br"></dd>
<dt translate>{{ note.type }}</dt>
<dd [innerHTML]="note.content | nl2br"></dd>
}
</dl>
</div>
}
</p-panel>
}
</div>
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
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',
Expand All @@ -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 */
Expand All @@ -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);
}

}
28 changes: 0 additions & 28 deletions projects/admin/src/app/service/ill-requests.service.spec.ts

This file was deleted.

Loading
Loading