Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
circulation: add ill requests tab
Browse files Browse the repository at this point in the history
* Adds a new tab to display pending ILL requests.
* Fixes the problem on separator parameter in JournalVolume pipe.
* Fixes the typing of the journal parameter to the JournalVolume pipe.
* Closes rero/rero-ils#2165.

Co-Authored-by: Bertrand Zuchuat <bertrand.zuchuat@rero.ch>
Garfield-fr committed Apr 27, 2023

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
1 parent 8e136bb commit ec8e249
Showing 16 changed files with 452 additions and 36 deletions.
125 changes: 125 additions & 0 deletions projects/admin/src/app/api/ill-request-api.service.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,125 @@
/*
* RERO ILS UI
* Copyright (C) 2023 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 <http://www.gnu.org/licenses/>.
*/
import { TestBed } from '@angular/core/testing';

import { HttpClientTestingModule } from '@angular/common/http/testing';
import { TranslateModule } from '@ngx-translate/core';
import { RecordModule, RecordService } from '@rero/ng-core';
import { of } from 'rxjs';
import { IllRequestApiService } from './ill-request-api.service';

describe('IllRequestApiService', () => {
let service: IllRequestApiService;

const response = {
"aggregations": {
},
"hits": {
"hits": [
{
"created": "2023-04-25T06:40:01.498787+00:00",
"id": "1",
"links": {
"self": "https://localhost:5000/api/ill_requests/1"
},
"metadata": {
"$schema": "https://bib.rero.ch/schemas/ill_requests/ill_request-v0.0.1.json",
"copy": false,
"document": {
"authors": "Aly Badr, Cairo University",
"identifier": "9780123456789",
"publisher": "Cairo University Press",
"source": {
"journal_title": "Mon titre de revue",
"number": "1",
"volume": "12"
},
"title": "Histoire d'Égypte",
"year": "1920"
},
"found_in": {
"source": "BGE",
"url": "http://data.rero.ch/01-R007878671/html?view=GE_V1"
},
"library": {
"pid": "1"
},
"notes": [
{
"content": "Une note prof",
"type": "staff_note"
},
{
"content": "Une note publique",
"type": "public_note"
}
],
"organisation": {
"pid": "1"
},
"patron": {
"name": "Premand, Alain",
"pid": "9",
"type": "ptrn"
},
"pickup_location": {
"name": "ILL AOSTE CANT1: Espaces publics",
"pid": "1",
"type": "loc"
},
"pid": "1",
"status": "pending"
},
"updated": "2023-04-27T06:25:11.821222+00:00"
}
],
"total": {
"relation": "eq",
"value": 1
}
},
"links": {}
};

const recordServiceSpy = jasmine.createSpyObj('RecordService', ['getRecords', 'totalHits']);
recordServiceSpy.getRecords.and.returnValue(of(response));
recordServiceSpy.totalHits.and.returnValue(1);

beforeEach(() => {
TestBed.configureTestingModule({
imports: [
HttpClientTestingModule,
RecordModule,
TranslateModule.forRoot()
],
providers: [
{ provide: RecordService, useValue: recordServiceSpy },
]
});
service = TestBed.inject(IllRequestApiService);
});

it('should be created', () => {
expect(service).toBeTruthy();
});

it('should turn the records around', () => {
service.getByPatronPid('9').subscribe((result: any) => {
expect(result).toEqual(response.hits.hits);
});
});
});
48 changes: 48 additions & 0 deletions projects/admin/src/app/api/ill-request-api.service.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
/*
* RERO ILS UI
* Copyright (C) 2023 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 <http://www.gnu.org/licenses/>.
*/
import { Injectable } from '@angular/core';
import { Record, RecordService } from '@rero/ng-core';
import { Observable } from 'rxjs';
import { map } from 'rxjs/operators';
import { ILLRequestStatus } from '../classes/ill-request';
import { BaseApi } from '@rero/shared';

@Injectable({
providedIn: 'root'
})
export class IllRequestApiService extends BaseApi {

/** Resource name */
readonly RESOURCE_NAME = 'ill_requests';

/**
* Constructor
* @param _recordService - RecordService
*/
constructor(private _recordService: RecordService) {
super();
}

getByPatronPid(patronPid: string): Observable<Record | Error> {
const query = `patron.pid:${patronPid} AND status:${ILLRequestStatus.PENDING}`;
return this._recordService
.getRecords(
this.RESOURCE_NAME, query , 1, RecordService.MAX_REST_RESULTS_SIZE,
undefined, undefined, BaseApi.reroJsonheaders, 'created'
).pipe(map((result: Record) => result.hits.hits));
}
}
Original file line number Diff line number Diff line change
@@ -28,6 +28,7 @@ import { ProfileComponent } from './patron/profile/profile.component';
import { PendingComponent } from './patron/pending/pending.component';
import { PERMISSIONS, PermissionsService } from '@rero/shared';
import { PermissionGuard } from '../guard/permission.guard';
import { IllRequestComponent } from './patron/ill-request/ill-request.component';

const routes: Routes = [
{
@@ -58,6 +59,10 @@ const routes: Routes = [
path: 'pending',
component: PendingComponent,
canActivate: [ PermissionGuard ], data: { permissions: [ PERMISSIONS.CIRC_ADMIN ] }
},{
path: 'ill',
component: IllRequestComponent,
canActivate: [ PermissionGuard ], data: { permissions: [ PERMISSIONS.CIRC_ADMIN ] }
},
{
path: 'profile',
9 changes: 7 additions & 2 deletions projects/admin/src/app/circulation/circulation.module.ts
Original file line number Diff line number Diff line change
@@ -25,6 +25,7 @@ import { SharedModule } from '@rero/shared';
import { CollapseModule } from 'ngx-bootstrap/collapse';
import { BsDatepickerModule } from 'ngx-bootstrap/datepicker';
import { BsDropdownModule } from 'ngx-bootstrap/dropdown';
import { JournalVolumePipe } from 'projects/public-search/src/app/pipe/journal-volume.pipe';
import { CheckinActionComponent } from './checkin/checkin-action/checkin-action.component';
import { CheckinComponent } from './checkin/checkin.component';
import { CirculationRoutingModule } from './circulation-routing.module';
@@ -39,6 +40,8 @@ import { ChangePasswordFormComponent } from './patron/change-password-form/chang
import { HistoryLogLibraryComponent } from './patron/history/history-log-library/history-log-library.component';
import { HistoryLogComponent } from './patron/history/history-log/history-log.component';
import { HistoryComponent } from './patron/history/history.component';
import { IllRequestItemComponent } from './patron/ill-request/ill-request-item/ill-request-item.component';
import { IllRequestComponent } from './patron/ill-request/ill-request.component';
import { FixedDateFormComponent } from './patron/loan/fixed-date-form/fixed-date-form.component';
import { LoanComponent } from './patron/loan/loan.component';
import { MainComponent } from './patron/main/main.component';
@@ -63,7 +66,6 @@ import { PickupComponent } from './patron/pickup/pickup.component';
import { ProfileComponent } from './patron/profile/profile.component';
import { GetLoanCipoPipe } from './pipe/get-loan-cipo.pipe';


@NgModule({
declarations: [
MainComponent,
@@ -97,7 +99,10 @@ import { GetLoanCipoPipe } from './pipe/get-loan-cipo.pipe';
GetLoanCipoPipe,
CheckinActionComponent,
PatronFeeComponent,
CancelRequestButtonComponent
CancelRequestButtonComponent,
IllRequestComponent,
IllRequestItemComponent,
JournalVolumePipe
],
imports: [
BsDropdownModule.forRoot(),
45 changes: 45 additions & 0 deletions projects/admin/src/app/circulation/circulation.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
/*
* RERO ILS UI
* Copyright (C) 2023 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 <http://www.gnu.org/licenses/>.
*/

@import 'bootstrap/scss/functions';
@import 'bootstrap/scss/variables';

.btn-hover {
color: $black;
background-color: $warning;
// could be better to use ``@extend .btn:hover`` but it doesn't work for hover property
}

.item {
margin-bottom: 0.25rem !important;
padding: 0.25rem !important;
border: $border-width solid $border-color;
border-radius: $border-radius;
position: relative;

&:hover{
background-color: $light;
}

div.actions {
position: absolute;
top: 0.25rem;
right: 15px;
}
}


2 changes: 1 addition & 1 deletion projects/admin/src/app/circulation/item/item.component.ts
Original file line number Diff line number Diff line change
@@ -30,7 +30,7 @@ import { PatronTransactionService } from '@app/admin/circulation/services/patron
@Component({
selector: 'admin-item',
templateUrl: './item.component.html',
styleUrls: ['./item.component.scss']
styleUrls: ['../circulation.scss']
})
export class ItemComponent implements OnInit {

Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
<!--
RERO ILS UI
Copyright (C) 2023 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 <http://www.gnu.org/licenses/>.
-->
<div class="row item">
<div class="col-sm-6" translate>
<button type="button" class="btn-show-more"
[ngClass]="{'btn-expanded': !isCollapsed, 'btn-collapsed': isCollapsed}"
(click)="isCollapsed = !isCollapsed"
[attr.aria-expanded]="!isCollapsed" aria-controls="collapse">
</button>
{{ record.metadata.document.title }}
</div>
<div class="col-sm-5" translate>{{ record.metadata.document.authors }}</div>
<div class="col-sm-1 text-right" translate>
<a
class="btn btn-sm btn-link btn-outline-primary"
[routerLink]="['/', 'records', 'ill_requests', 'detail', record.metadata.pid]"
>
<i class="fa fa-eye" aria-hidden="true"></i>
</a>
</div>
<div name="collapsed-details" class="col-12 mt-2" *ngIf="!isCollapsed">
<dl class="row">
<!-- PUBLISHER -->
<ng-container *ngIf="record.metadata.document.publisher">
<dt class="offset-1 col-sm-3 col-md-2 col-lg-1 label-title" translate>Publisher</dt>
<dd class="col-sm-8 col-md-9 col-lg-10 mb-0">{{ record.metadata.document.publisher }}</dd>
</ng-container>

<!-- YEAR -->
<ng-container *ngIf="record.metadata.document.year">
<dt class="offset-1 col-sm-3 col-md-2 col-lg-1 label-title" translate>Year</dt>
<dd class="col-sm-8 col-md-9 col-lg-10 mb-0">{{ record.metadata.document.year }}</dd>
</ng-container>

<!-- IDENTIFIER -->
<ng-container *ngIf="record.metadata.document.identifier">
<dt class="offset-1 col-sm-3 col-md-2 col-lg-1 label-title" translate>Identifier</dt>
<dd class="col-sm-8 col-md-9 col-lg-10 mb-0">{{ record.metadata.document.identifier }}</dd>
</ng-container>

<!-- SOURCE -->
<ng-container *ngIf="record.metadata.document.source">
<dt class="offset-1 col-sm-3 col-md-2 col-lg-1 label-title" translate>Source</dt>
<dd class="col-sm-8 col-md-9 col-lg-10 mb-0">
<ng-container *ngIf="record.metadata.document.source.volume || record.metadata.document.source.number">
{{ record.metadata.document.source | journalVolume }}
</ng-container>
</dd>
</ng-container>

<!-- PICKUP LOCATION -->
<dt class="offset-1 col-sm-3 col-md-2 col-lg-1 label-title" translate>Pickup location</dt>
<dd class="col-sm-8 col-md-9 col-lg-10 mb-0">{{ record.metadata.pickup_location.name }}</dd>

<!-- SCOPE -->
<dt class="offset-1 col-sm-3 col-md-2 col-lg-1 label-title" translate>Scope</dt>
<dd class="col-sm-8 col-md-9 col-lg-10 mb-0">
<ng-container *ngIf="record.metadata.copy; else scopeLoan">{{ 'Copy' | translate }}</ng-container>
<ng-template #scopeLoan>{{ 'Loan' | translate }}</ng-template>
</dd>

<!-- PAGES -->
<ng-container *ngIf="record.metadata.copy && record.metadata.pages">
<dt class="offset-1 col-sm-3 col-md-2 col-lg-1 label-title" translate>Pages</dt>
<dd class="col-sm-8 col-md-9 col-lg-10 mb-0">{{ record.metadata.pages }}</dd>
</ng-container>

<!-- FOUND IN -->
<ng-container *ngIf="record.metadata.found_in">
<dt class="offset-1 col-sm-3 col-md-2 col-lg-1 label-title" translate>Found in</dt>
<dd class="col-sm-8 col-md-9 col-lg-10 mb-0">
<a href="{{ record.metadata.found_in.url }}">{{ record.metadata.found_in.url }}</a>
<span class="badge badge-light px-2 py-1 ml-2">{{ record.metadata.found_in.source }}</span>
</dd>
</ng-container>

<!-- NOTES -->
<ng-container *ngIf="record.metadata.notes && record.metadata.notes.length > 0">
<dt class="offset-1 col-sm-3 col-md-2 col-lg-1 label-title" translate>Note</dt>
<dd class="col-sm-8 col-md-9 col-lg-10 mb-0">
<blockquote>
<ul class="list-unstyled">
<li *ngFor="let note of record.metadata.notes"
[innerHTML]="note.content | nl2br">
</li>
</ul>
</blockquote>
</dd>
</ng-container>
</dl>
</div>
</div>
Loading

0 comments on commit ec8e249

Please sign in to comment.