Skip to content

Commit

Permalink
circulation: fix problems on circulation module
Browse files Browse the repository at this point in the history
This commit fixes some problems detected after the test of new invenio
circulation module in the backend :
  * adds a toastr message when no circulation are done on checkin page.
  * displays a message when no notification process date exists for an
item into the checkin/checkout component.

Co-Authored-By: Renaud Michotte <renaud.michotte@gmail.com>
  • Loading branch information
zannkukai committed Aug 19, 2020
1 parent c048caa commit 4363c38
Show file tree
Hide file tree
Showing 4 changed files with 54 additions and 42 deletions.
83 changes: 45 additions & 38 deletions projects/admin/src/app/circulation/checkin/checkin.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,51 +95,58 @@ export class CheckinComponent implements OnInit {
*/
checkin(itemBarcode: string) {
this.searchInputFocus = false;
this._itemsService.checkin(itemBarcode, this._loggedUser.getCurrentLibrary()).subscribe(item => {
// TODO: remove this when policy will be in place
if (
item === null ||
item.location.organisation.pid !==
this._loggedUser.library.organisation.pid
) {
this._toastService.error(
this._translate.instant('Item or patron not found!'),
this._translate.instant('Checkin')
);
return;
}
if (item.hasRequests) {
this._toastService.warning(
this._translate.instant('The item contains requests'),
this._translate.instant('Checkin')
);
}
switch (item.actionDone) {
case ItemAction.return_missing:
this._itemsService.checkin(itemBarcode, this._loggedUser.getCurrentLibrary()).subscribe(
item => {
// TODO: remove this when policy will be in place
if (item === null || item.location.organisation.pid !== this._loggedUser.library.organisation.pid) {
this._toastService.error(
this._translate.instant('Item or patron not found!'),
this._translate.instant('Checkin')
);
return;
}
if (item.hasRequests) {
this._toastService.warning(
this._translate.instant('The item has been returned from missing'),
this._translate.instant('The item contains requests'),
this._translate.instant('Checkin')
);
break;
case ItemAction.checkin:
this._displayCirculationNote(item, ItemNoteType.CHECKIN);
if (item.action_applied.checkin) {
this.getPatronInfo(item.action_applied.checkin.patron.barcode);
}
if (item.status === ItemStatus.IN_TRANSIT) {
}
switch (item.actionDone) {
case ItemAction.return_missing:
this._toastService.warning(
this._translate.instant('The item is ' + ItemStatus.IN_TRANSIT),
this._translate.instant('The item has been returned from missing'),
this._translate.instant('Checkin')
);
}
break;
default:
break;
break;
case ItemAction.checkin:
this._displayCirculationNote(item, ItemNoteType.CHECKIN);
if (item.action_applied.checkin) {
this.getPatronInfo(item.action_applied.checkin.patron.barcode);
}
if (item.status === ItemStatus.IN_TRANSIT) {
this._toastService.warning(
this._translate.instant('The item is ' + ItemStatus.IN_TRANSIT),
this._translate.instant('Checkin')
);
}
break;
}
this._itemsList.unshift(item);
this.searchText = '';
this.searchInputFocus = true;
},
error => {
// If no action could be done by the '/item/checkin' api, an error will be raised.
// catch this error to display it as an toastr message.
const message = (error.hasOwnProperty('error') && error.error.hasOwnProperty('status'))
? error.error.status.replace(/^error:/, '')
: error.message;
this._toastService.warning(
this._translate.instant(message),
this._translate.instant('Checkin')
);
}
this._itemsList.unshift(item);
this.searchText = '';
this.searchInputFocus = true;
});
);
}

/** Get patron information
Expand Down
8 changes: 7 additions & 1 deletion projects/admin/src/app/circulation/item/item.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,13 @@
<dd class="col-sm-7 col-md-9" name="notifications">
<ul class="list-unstyled pl-2 mb-0">
<li *ngFor="let notification of notifications">
{{ notification.metadata.process_date | dateTranslate :'shortDate' }}:
<ng-container *ngIf="notification.metadata.process_date; else noProcessDate">
{{ notification.metadata.process_date | dateTranslate :'shortDate' }}
</ng-container>
<ng-template #noProcessDate>
{{ notification.metadata.creation_date | dateTranslate : 'shortDate' }}
<small class="text-muted"><em>({{ 'Not yet sent' | translate }})</em></small>
</ng-template> :
{{ notification.metadata.notification_type | translate }}
</li>
</ul>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -162,9 +162,6 @@ export class LoanComponent implements OnInit {
);
this.searchText = '';
this.searchInputFocus = true;
},
() => {
console.log('loan success');
}
);
}
Expand Down
2 changes: 2 additions & 0 deletions projects/admin/src/app/service/items.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,8 @@ export class ItemsService {
catchError(e => {
if (e.status === 404) {
return of(null);
} else {
throw e;
}
})
);
Expand Down

0 comments on commit 4363c38

Please sign in to comment.