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

feat(circulation): add informations message #1146

Merged
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
59 changes: 51 additions & 8 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(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(item, ItemNoteType.CHECKIN);
}
break;
}
Expand Down Expand Up @@ -266,17 +266,32 @@ 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(item: Item, noteType: ItemNoteType): void {
let message = [];
const note = item.getNote(noteType);
if (note != null) {
message.push(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.push('<br />');
}
message.push(additionalMessage);
}
}
if (message.length > 0) {
this.toastService.warning(
note.content, null,
message.join(),
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 +321,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.push(`${this.translate.instant('This item is in exhibition/course')} "${item.collections[0]}"`);
if (item.collections.length > 1) {
message.push(` ${this.translate.instant('and {{ count }} other(s)', { count: item.collections.length - 1 })}`);
}
message.push('.');
}
if (item.temporary_location) {
message.push(`<br/>${this.translate.instant('This item is in temporary location')} "${item.temporary_location.name}".`);
}

return message.join('');
}

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
41 changes: 37 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 @@ -357,15 +357,32 @@ export class LoanComponent implements OnInit, OnDestroy {

/**
* display a circulation note about an item as a permanent toastr message
* @param action: the current action
* @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.push(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.push('<br />');
}
message.push(additionalMessage);
}
}
if (message.length > 0) {
this.toastService.warning(
note.content, null,
message.join(),
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 +391,22 @@ export class LoanComponent implements OnInit, OnDestroy {
}
}

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

return message.join('');
}

/**
* 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
Loading