Skip to content

Commit

Permalink
admin: circulation
Browse files Browse the repository at this point in the history
Co-Authored-by: Bertrand Zuchuat <[email protected]>
  • Loading branch information
Garfield-fr committed Jan 7, 2025
1 parent 3c4b132 commit 0465b4c
Show file tree
Hide file tree
Showing 41 changed files with 949 additions and 924 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,22 +14,22 @@
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 (window:keypress)="checkinItemOnEnterKey($event)">
<div class="font-weight-bold" translate>
<div class="font-bold mb-3" translate>
One item and one patron were found.
</div>
</div>
<div>
<div class="flex gap-2" (window:keypress)="checkinItemOnEnterKey($event)">
<p-button
id="action-patron"
icon="fa fa-user"
styleClass="outline-none"
[label]="'Patron account'|translate"
outlined
(onClick)="setAction('patron')"
/>
<p-button
id="action-item"
icon="fa fa-file-o"
styleClass="outline-none"
[label]="'Checkin the item'|translate"
outlined
(onClick)="setAction('item')"
Expand Down
18 changes: 15 additions & 3 deletions projects/admin/src/app/circulation/checkin/checkin.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -155,14 +155,22 @@ export class CheckinComponent implements OnInit {
item.notes = [];
}
item.notes.push({
content: error.error.status.replace(/^error:/, '').trim(),
content: this.processErrorMessage(error.error.status),
type: ItemNoteType.API
});
this.items.unshift(item);
// If no action could be done by the '/item/checkin' api, an error will be raised.
// catch this error to display it as a Toast message.
this._checkinErrorManagement(error, item);
});
} else if (error.error) {
this.messageService.add({
severity: 'warn',
summary: this.translate.instant('Checkin'),
detail: this.processErrorMessage(error.error.status),
life: CONFIG.MESSAGE_LIFE
});
this._resetSearchInput();
}
}
});
Expand Down Expand Up @@ -227,7 +235,7 @@ export class CheckinComponent implements OnInit {
if (patron.total.value === 1 && item.total.value === 1) {
const ref: DynamicDialogRef = this.dialogService.open(CheckinActionComponent, {
header: this.translate.instant('Circulation action'),
width: '50vw',
width: '25vw',
})
ref.onClose.subscribe((action: string) => {
if (action) {
Expand Down Expand Up @@ -316,7 +324,7 @@ export class CheckinComponent implements OnInit {
private _checkinErrorManagement(error: any, item: Item) {
// get the error message from the raised error. This will be the Toast message core.
let message = (error.hasOwnProperty('error') && error.error.hasOwnProperty('status'))
? error.error.status.replace(/^error:/, '').trim()
? this.processErrorMessage(error.error.status)
: error.message;
message = this.translate.instant(message);
message += `<br/>${this.translate.instant('Status')}: ${this.translate.instant(item.status.toString())}`;
Expand Down Expand Up @@ -372,6 +380,10 @@ export class CheckinComponent implements OnInit {
}
}

private processErrorMessage(message: string): string {
return message.replace(/^error:/, '').trim();
}

/** Reset search input */
private _resetSearchInput(): void {
setTimeout(() => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
/*
* RERO ILS UI
* Copyright (C) 2022 RERO
* Copyright (C) 2022 UCLouvain
* Copyright (C) 2024 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
Expand All @@ -15,11 +14,24 @@
* 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 } from '@angular/core';

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

.btn-show-more {
background-color: transparent !important;
color: $white;
@Component({
selector: 'admin-circulation-main',
template: `
<router-outlet></router-outlet>
<p-toast>
<ng-template let-message pTemplate="message">
<div class="flex flex-column align-items-start" style="flex: 1">
<div class="font-medium text-lg text-900">
{{ message.summary }}
</div>
<p [innerHtml]="message.detail"></p>
</div>
</ng-template>
</p-toast>
<p-confirmDialog />
`
})
export class CirculationMainComponent {
}
100 changes: 54 additions & 46 deletions projects/admin/src/app/circulation/circulation-routing.module.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* RERO ILS UI
* Copyright (C) 2019-2023 RERO
* Copyright (C) 2019-2024 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
Expand All @@ -14,7 +14,6 @@
* 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 { NgModule } from '@angular/core';
import { RouterModule, Routes } from '@angular/router';
import { PERMISSIONS } from '@rero/shared';
Expand All @@ -30,67 +29,76 @@ import { PendingComponent } from './patron/pending/pending.component';
import { PickupComponent } from './patron/pickup/pickup.component';
import { ProfileComponent } from './patron/profile/profile.component';
import { keepHistoryGuard } from './guard/keep-history.guard';
import { CirculationMainComponent } from './circulation-main.component';

const routes: Routes = [
{
path: '',
redirectTo: 'checkout',
pathMatch: 'full'
},
{
path: 'patron/:barcode',
component: MainComponent,
component: CirculationMainComponent,
children: [
{
path: '',
redirectTo: 'loan',
pathMatch: 'full'
},
{
path: 'loan',
component: LoanComponent,
canActivate: [ PermissionGuard ], data: { permissions: [ PERMISSIONS.CIRC_ADMIN ] }
redirectTo: 'checkout',
pathMatch: 'full',
},
{
path: 'pickup',
component: PickupComponent,
path: 'checkout',
component: CheckinComponent,
canActivate: [ PermissionGuard ], data: { permissions: [ PERMISSIONS.CIRC_ADMIN ] }
},
{
path: 'pending',
component: PendingComponent,
path: 'requests',
component: MainRequestComponent,
canActivate: [ PermissionGuard ], data: { permissions: [ PERMISSIONS.CIRC_ADMIN ] }
},
{
path: 'ill',
component: IllRequestComponent,
canActivate: [ PermissionGuard ], data: { permissions: [ PERMISSIONS.CIRC_ADMIN ] }
path: 'patron/:barcode',
component: MainComponent,
children: [
{
path: '',
redirectTo: 'loan',
pathMatch: 'full'
},
{
path: 'loan',
component: LoanComponent,
canActivate: [ PermissionGuard ], data: { permissions: [ PERMISSIONS.CIRC_ADMIN ] }
},
{
path: 'pickup',
component: PickupComponent,
canActivate: [ PermissionGuard ], data: { permissions: [ PERMISSIONS.CIRC_ADMIN ] }
},
{
path: 'pending',
component: PendingComponent,
canActivate: [ PermissionGuard ], data: { permissions: [ PERMISSIONS.CIRC_ADMIN ] }
},
{
path: 'ill',
component: IllRequestComponent,
canActivate: [ PermissionGuard ], data: { permissions: [ PERMISSIONS.CIRC_ADMIN ] }
},
{
path: 'profile',
component: ProfileComponent,
canActivate: [ PermissionGuard ], data: { permissions: [ PERMISSIONS.CIRC_ADMIN ] }
},
{
path: 'fees',
component: PatronTransactionsComponent,
canActivate: [ PermissionGuard ], data: { permissions: [ PERMISSIONS.CIRC_ADMIN ] }
},
{
path: 'history',
component: HistoryComponent,
canActivate: [ keepHistoryGuard, PermissionGuard ], data: { permissions: [ PERMISSIONS.CIRC_ADMIN ] }
}
]
},
{
path: 'profile',
component: ProfileComponent,
canActivate: [ PermissionGuard ], data: { permissions: [ PERMISSIONS.CIRC_ADMIN ] }
},
{
path: 'fees',
component: PatronTransactionsComponent,
canActivate: [ PermissionGuard ], data: { permissions: [ PERMISSIONS.CIRC_ADMIN ] }
},
{
path: 'history',
component: HistoryComponent,
canActivate: [ keepHistoryGuard, PermissionGuard ], data: { permissions: [ PERMISSIONS.CIRC_ADMIN ] }
}
]
}, {
path: 'checkout',
component: CheckinComponent,
canActivate: [ PermissionGuard ], data: { permissions: [ PERMISSIONS.CIRC_ADMIN ] }
}, {
path: 'requests',
component: MainRequestComponent,
canActivate: [ PermissionGuard ], data: { permissions: [ PERMISSIONS.CIRC_ADMIN ] }
}
},
];

@NgModule({
Expand Down
6 changes: 4 additions & 2 deletions projects/admin/src/app/circulation/circulation.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ import { TagModule } from 'primeng/tag';
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 { CirculationMainComponent } from './circulation-main.component';
import { CirculationRoutingModule } from './circulation-routing.module';
import { ItemComponent } from './item/item.component';
import { ItemsListComponent } from './items-list/items-list.component';
Expand Down Expand Up @@ -106,7 +107,8 @@ import { GetLoanCipoPipe } from './pipe/get-loan-cipo.pipe';
IllRequestComponent,
IllRequestItemComponent,
JournalVolumePipe,
CirculationSettingsComponent
CirculationSettingsComponent,
CirculationMainComponent
],
imports: [
CirculationRoutingModule,
Expand All @@ -125,7 +127,7 @@ import { GetLoanCipoPipe } from './pipe/get-loan-cipo.pipe';
MessagesModule,
InputSwitchModule,
SplitButtonModule
],
],
providers: [
CurrencyPipe
]
Expand Down
37 changes: 0 additions & 37 deletions projects/admin/src/app/circulation/circulation.scss

This file was deleted.

Loading

0 comments on commit 0465b4c

Please sign in to comment.