Skip to content

Commit

Permalink
feat(circulation): add informations message
Browse files Browse the repository at this point in the history
During a check-in, if the item is in a collection and at a temporary
location, and if the item belongs to the current library,
this information is added to the message intended for the professional.

* Closes rero/rero-ils#1321.

Co-Authored-by: Bertrand Zuchuat <bertrand.zuchuat@rero.ch>
  • Loading branch information
Garfield-fr committed Mar 26, 2024
1 parent e0e0357 commit 8301e1b
Show file tree
Hide file tree
Showing 6 changed files with 107 additions and 13 deletions.
58 changes: 51 additions & 7 deletions projects/admin/src/app/circulation/checkin/checkin.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ export class CheckinComponent implements OnInit {
);
break;
case ItemAction.checkin:
this._displayCirculationNote(item, ItemNoteType.CHECKIN);
this.displayCirculationInformation(ItemAction.checkin, item, ItemNoteType.CHECKIN);
if (item.action_applied && item.action_applied.checkin) {
this.getPatronInfo(item.action_applied.checkin.patron.barcode);
}
Expand All @@ -140,7 +140,7 @@ export class CheckinComponent implements OnInit {
break;
case ItemAction.receive:
if (item.library.pid === this.userService.user.currentLibrary) {
this._displayCirculationNote(item, ItemNoteType.CHECKIN);
this.displayCirculationInformation(ItemAction.receive, item, ItemNoteType.CHECKIN);
}
break;
}
Expand Down Expand Up @@ -266,17 +266,33 @@ export class CheckinComponent implements OnInit {
);
}

/** display a circulation note about an item as a permanent toastr message
/** display a circulation infos about an item as a permanent toastr message
*
* @param item: the item
* @param noteType: the note type to display
*/
private _displayCirculationNote(item: Item, noteType: ItemNoteType): void {
private displayCirculationInformation(action: string, item: Item, noteType: ItemNoteType): void {
let message = '';
const note = item.getNote(noteType);
if (note != null) {
message += note.content;
}
// Show additional message only for the owning library
if (item.library.pid === this.userService.user.currentLibrary) {
const additionalMessage = this.displayCollectionsAndTemporaryLocation(item);
if (additionalMessage.length > 0) {
if (message.length > 0) {
message += '<br />';
}
message += additionalMessage;
}
}
if (message.length > 0) {
this.toastService.warning(
note.content, null,
message,
this.translate.instant('Checkin'),
{
enableHtml: true,
closeButton: true, // add a close button to the toastr message
disableTimeOut: true, // permanent toastr message (until click on 'close' button)
tapToDismiss: false // toastr message only close when click on the 'close' button.
Expand Down Expand Up @@ -306,14 +322,42 @@ export class CheckinComponent implements OnInit {
if (checkinNote) {
message += `<br/>${this.translate.instant('Note')}: ${checkinNote.content}`
}
// Show additional message only for the owning library
if (item.library.pid === this.userService.user.currentLibrary) {
const additionalMessage = this.displayCollectionsAndTemporaryLocation(item);
if (additionalMessage.length > 0) {
message += `<br />${additionalMessage}`;
}
}
this.toastService.warning(
this.translate.instant(message),
message,
this.translate.instant('Checkin'),
{ enableHtml: true }
{
enableHtml: true,
closeButton: true,
disableTimeOut: true,
tapToDismiss: false
}
);
this._resetSearchInput();
}

private displayCollectionsAndTemporaryLocation(item: Item): string {
let message = '';
if (item.collections && item.collections.length > 0) {
message += `${this.translate.instant('This item is in exhibition/course')} "${item.collections[0]}"`;
if (item.collections.length > 1) {
message += ` ${this.translate.instant('and X other(s)')}`;
}
message += '.';
}
if (item.temporary_location) {
message += `<br/>${this.translate.instant('This item is in temporary location')} "${item.temporary_location.name}".`;
}

return message;
}

hasFees(event: boolean) {
if (event) {
this.toastService.error(
Expand Down
12 changes: 12 additions & 0 deletions projects/admin/src/app/circulation/item/item.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,18 @@
{{ $any(location).metadata.name }}
</dd>
}
@if (item.temporary_location) {
<dt class="offset-1 col-sm-3 col-md-2 col-lg-1 label-title" translate>Temporary location</dt>
<dd class="col-sm-8 col-md-9 col-lg-10">
{{ item.temporary_location.name }}
</dd>
}
@if (item.collections && item.collections.length > 0) {
<dt class="offset-1 col-sm-3 col-md-2 col-lg-1 label-title" translate>Collection</dt>
<dd class="col-sm-8 col-md-9 col-lg-10">
{{ item.collections.join(', ') }}
</dd>
}
@if (item.loan && item.loan.extension_count) {
<dt class="offset-1 col-sm-3 col-md-2 col-lg-1 label-title" translate>Renewals</dt>
<dd name="renewals" class="col-sm-8 col-md-9 col-lg-10">
Expand Down
40 changes: 36 additions & 4 deletions projects/admin/src/app/circulation/patron/loan/loan.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,7 @@ export class LoanComponent implements OnInit, OnDestroy {
newItems.map((newItem: Item) => {
switch (newItem.actionDone) {
case ItemAction.checkin: {
this._displayCirculationNote(newItem, ItemNoteType.CHECKIN);
this.displayCirculationInformation(ItemAction.checkin, newItem, ItemNoteType.CHECKIN);
this.checkedOutItems = this.checkedOutItems.filter(currItem => currItem.pid !== newItem.pid);
this.checkedInItems.unshift(newItem);
// display a toast message if the item goes in transit...
Expand All @@ -302,7 +302,7 @@ export class LoanComponent implements OnInit, OnDestroy {
}
case ItemAction.checkout: {
this._displayTransactionEndDateChanged(newItem);
this._displayCirculationNote(newItem, ItemNoteType.CHECKOUT);
this.displayCirculationInformation(ItemAction.checkout, newItem, ItemNoteType.CHECKOUT);
this.checkedOutItems.unshift(newItem);
this.checkedInItems = this.checkedInItems.filter(currItem => currItem.pid !== newItem.pid);
this.circulationService.incrementCirculationStatistic('loans');
Expand Down Expand Up @@ -360,12 +360,28 @@ export class LoanComponent implements OnInit, OnDestroy {
* @param item: the item
* @param noteType: the note type to display
*/
private _displayCirculationNote(item: Item, noteType: ItemNoteType): void {
private displayCirculationInformation(action: string, item: Item, noteType: ItemNoteType): void {
let message = '';
const note = item.getNote(noteType);
if (note != null) {
message += note.content;
}
// Show additional message only for the owning library
if (action === ItemAction.checkin && (item.library.pid === this.userService.user.currentLibrary)) {
const additionalMessage = this.displayCollectionsAndTemporaryLocation(item);
if (additionalMessage.length > 0) {
if (message.length > 0) {
message += '<br />';
}
message += additionalMessage;
}
}
if (message.length > 0) {
this.toastService.warning(
note.content, null,
message,
this.translateService.instant('Checkin'),
{
enableHtml: true,
closeButton: true, // add a close button to the toastr message
disableTimeOut: true, // permanent toastr message (until click on 'close' button)
tapToDismiss: false // toastr message only close when click on the 'close' button.
Expand All @@ -374,6 +390,22 @@ export class LoanComponent implements OnInit, OnDestroy {
}
}

private displayCollectionsAndTemporaryLocation(item: Item): string {
let message = '';
if (item.collections && item.collections.length > 0) {
message += `${this.translateService.instant('This item is in exhibition/course')} "${item.collections[0]}"`;
if (item.collections.length > 1) {
message += ` ${this.translateService.instant('and X other(s)')}`;
}
message += '.';
}
if (item.temporary_location) {
message += `<br/>${this.translateService.instant('This item is in temporary location')} "${item.temporary_location.name}".`;
}

return message;
}

/**
* Display a warning toastr message if transaction end_date is not the same as the user selected end_date.
* The backend will check if the selected end_date is an opening day ; if not then it will automatically
Expand Down
2 changes: 2 additions & 0 deletions projects/admin/src/app/classes/items.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ export class Item {
available: boolean;
barcode: string;
call_number: string;
collections?: string[];
document: any;
status: ItemStatus;
organisation: Organisation;
Expand All @@ -99,6 +100,7 @@ export class Item {
notes: ItemNote[];
acquisition_date: Moment;
enumerationAndChronology: string;
temporary_location?: any;


constructor(obj?: any) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,9 @@ import { ResultItem } from '@rero/ng-core';
<h5 class="mb-0 card-title">
<i class="fa fa-circle mr-1 text-{{ record.metadata.published ? 'success' : 'danger' }}" aria-hidden="true"></i>
<a id="collection-link" [routerLink]="[detailUrl.link]">{{ record.metadata.title }}</a>
({{ record.metadata.collection_id }})
@if (record.metadata.collection_id) {
({{ record.metadata.collection_id }})
}
</h5>
<div class="card-text">
@if (record.metadata.teachers) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@
@if (record) {
<h5 class="mb-0 card-title">
<a id="collection-link" [href]="detailUrl.link">{{ record.metadata.title }}</a>
({{ record.metadata.collection_id }})
@if (record.metadata.collection_id) {
({{ record.metadata.collection_id }})
}
</h5>
<div class="card-text">
@if (record.metadata.teachers) {
Expand Down

0 comments on commit 8301e1b

Please sign in to comment.