From afbc648a9c9af7bff057f9fa43c72d1f07192e8e Mon Sep 17 00:00:00 2001 From: Pascal Repond Date: Tue, 23 Jul 2024 12:12:01 +0200 Subject: [PATCH] fix(circ): error when no item note * When performing a circulation action on an item that had no circulation note, `getCirculationNoteForAction()` returned [null] and this created an error when displaying the note. Now, `getCirculationNoteForAction()` only returns a note if it exists, else it return an empty array. * Also fixes some in transit alerts on checkin that was not correctly translated and was missing destination info. Co-Authored-by: Pascal Repond --- .../circulation/checkin/checkin.component.ts | 3 ++- .../src/app/circulation/item/item.component.ts | 17 ++++++++++------- .../circulation/patron/loan/loan.component.ts | 5 +++-- .../src/assets/rero-ils-ui/admin/i18n/ar.json | 3 +-- .../src/assets/rero-ils-ui/admin/i18n/de.json | 3 +-- .../src/assets/rero-ils-ui/admin/i18n/en.json | 3 +-- .../assets/rero-ils-ui/admin/i18n/en_US.json | 3 +-- .../src/assets/rero-ils-ui/admin/i18n/es.json | 2 +- .../src/assets/rero-ils-ui/admin/i18n/fr.json | 3 +-- .../src/assets/rero-ils-ui/admin/i18n/it.json | 3 +-- .../src/assets/rero-ils-ui/admin/i18n/nl.json | 3 +-- projects/admin/src/manual_translations.ts | 2 +- 12 files changed, 24 insertions(+), 26 deletions(-) diff --git a/projects/admin/src/app/circulation/checkin/checkin.component.ts b/projects/admin/src/app/circulation/checkin/checkin.component.ts index a7b533d59..d507dd168 100644 --- a/projects/admin/src/app/circulation/checkin/checkin.component.ts +++ b/projects/admin/src/app/circulation/checkin/checkin.component.ts @@ -132,8 +132,9 @@ export class CheckinComponent implements OnInit { this.getPatronInfo(item.action_applied.checkin.patron.barcode); } if (item.status === ItemStatus.IN_TRANSIT) { + const destination = item.loan.item_destination.library_name; this.toastService.warning( - this.translate.instant('The item is ' + ItemStatus.IN_TRANSIT), + this.translate.instant('The item is in transit to {{ destination }}', {destination}), this.translate.instant('Checkin') ); } diff --git a/projects/admin/src/app/circulation/item/item.component.ts b/projects/admin/src/app/circulation/item/item.component.ts index 1ce16d6b2..9f21cbf28 100644 --- a/projects/admin/src/app/circulation/item/item.component.ts +++ b/projects/admin/src/app/circulation/item/item.component.ts @@ -160,14 +160,17 @@ export class ItemComponent implements OnInit { */ getCirculationNoteForAction(): ItemNote[] { if (this.item.actionDone) { - if ( - (this.item.actionDone === this.itemAction.checkin) - || (((this.item.actionDone === this.itemAction.receive) && this.item.library.pid === this.userService.user.currentLibrary)) - ) { - return [this.item.getNote(ItemNoteType.CHECKIN)]; + const checkinNote = this.item.getNote(ItemNoteType.CHECKIN) + if (checkinNote && ( + (this.item.actionDone === this.itemAction.checkin) || ( + (((this.item.actionDone === this.itemAction.receive) && this.item.library.pid === this.userService.user.currentLibrary)) + ) + )) { + return [checkinNote]; } - if (this.item.actionDone === this.itemAction.checkout) { - return [this.item.getNote(ItemNoteType.CHECKOUT)]; + const checkoutNote = this.item.getNote(ItemNoteType.CHECKOUT) + if (checkoutNote && this.item.actionDone === this.itemAction.checkout) { + return [checkoutNote]; } } else if (this.item.notes) { // Notes for item without loan. diff --git a/projects/admin/src/app/circulation/patron/loan/loan.component.ts b/projects/admin/src/app/circulation/patron/loan/loan.component.ts index 5ad40a769..12361b699 100644 --- a/projects/admin/src/app/circulation/patron/loan/loan.component.ts +++ b/projects/admin/src/app/circulation/patron/loan/loan.component.ts @@ -210,8 +210,9 @@ export class LoanComponent implements OnInit, OnDestroy { ); } if (item.status === ItemStatus.IN_TRANSIT) { + const destination = item.loan.item_destination.library_name; this.toastService.warning( - this.translateService.instant('The item is in transit'), + this.translateService.instant('The item is in transit to {{ destination }}', {destination}), this.translateService.instant('Checkin') ); } @@ -292,7 +293,7 @@ export class LoanComponent implements OnInit, OnDestroy { if (newItem.status === ItemStatus.IN_TRANSIT) { const destination = newItem.loan.item_destination.library_name; this.toastService.warning( - this.translateService.instant('The item is in transit to [{{ destination }}]', {destination}), + this.translateService.instant('The item is in transit to {{ destination }}', {destination}), this.translateService.instant('Checkin') ); } diff --git a/projects/admin/src/assets/rero-ils-ui/admin/i18n/ar.json b/projects/admin/src/assets/rero-ils-ui/admin/i18n/ar.json index 3e823134d..1634e78da 100644 --- a/projects/admin/src/assets/rero-ils-ui/admin/i18n/ar.json +++ b/projects/admin/src/assets/rero-ils-ui/admin/i18n/ar.json @@ -905,8 +905,7 @@ "The item is {{ status }}": "The item is {{ status }}", "The item is already checked out or requested by this patron.": "تم بالفعل اعارة أو طلب النسخة من قبل المستفيد.", "The item is already in the list.": "النسخة موجودة في القائمة", - "The item is in transit": "The item is in transit", - "The item is in transit to [{{ destination }}]": "The item is in transit to [{{ destination }}]", + "The item is in transit to {{ destination }}": "The item is in transit to {{ destination }}", "The item status does not allow requests.": "حالة النسخة لا تسمح بطلبات جديدة", "The maximum number of files is reached. No additional upload is allowed.": "The maximum number of files is reached. No additional upload is allowed.", "The notifications for patrons without e-mail are sent to this address.": "The notifications for patrons without e-mail are sent to this address.", diff --git a/projects/admin/src/assets/rero-ils-ui/admin/i18n/de.json b/projects/admin/src/assets/rero-ils-ui/admin/i18n/de.json index 24974b3a3..40f9954b8 100644 --- a/projects/admin/src/assets/rero-ils-ui/admin/i18n/de.json +++ b/projects/admin/src/assets/rero-ils-ui/admin/i18n/de.json @@ -905,8 +905,7 @@ "The item is {{ status }}": "The item is {{ status }}", "The item is already checked out or requested by this patron.": "Das Exemplar ist von diesem Kunde bereits bestellt oder ausgeliehen.", "The item is already in the list.": "Das Exemplar ist bereits in der Liste.", - "The item is in transit": "Das Exemplar ist in Transit", - "The item is in transit to [{{ destination }}]": "Das Exemplar ist in Transit nach [{{ destination }}]", + "The item is in transit to {{ destination }}": "Das Exemplar ist in Transit nach {{ destination }}", "The item status does not allow requests.": "Der Exemplarstatus erlaubt keine Bestellungen.", "The maximum number of files is reached. No additional upload is allowed.": "Die maximale Anzahl von Dateien ist erreicht. Ein weiterer Upload ist nicht möglich.", "The notifications for patrons without e-mail are sent to this address.": "Die Benachrichtigungen für Kunden ohne E-Mail werden an diese Adresse gesendet.", diff --git a/projects/admin/src/assets/rero-ils-ui/admin/i18n/en.json b/projects/admin/src/assets/rero-ils-ui/admin/i18n/en.json index f9389118e..c0cac5bb7 100644 --- a/projects/admin/src/assets/rero-ils-ui/admin/i18n/en.json +++ b/projects/admin/src/assets/rero-ils-ui/admin/i18n/en.json @@ -905,8 +905,7 @@ "The item is {{ status }}": "The item is {{ status }}", "The item is already checked out or requested by this patron.": "The item is already checked out or requested by this patron.", "The item is already in the list.": "The item is already in the list.", - "The item is in transit": "The item is in transit", - "The item is in transit to [{{ destination }}]": "The item is in transit to [{{ destination }}]", + "The item is in transit to {{ destination }}": "The item is in transit to {{ destination }}", "The item status does not allow requests.": "The item status does not allow requests.", "The maximum number of files is reached. No additional upload is allowed.": "The maximum number of files is reached. No additional upload is allowed.", "The notifications for patrons without e-mail are sent to this address.": "The notifications for patrons without e-mail are sent to this address.", diff --git a/projects/admin/src/assets/rero-ils-ui/admin/i18n/en_US.json b/projects/admin/src/assets/rero-ils-ui/admin/i18n/en_US.json index cee0877b3..c992563ec 100644 --- a/projects/admin/src/assets/rero-ils-ui/admin/i18n/en_US.json +++ b/projects/admin/src/assets/rero-ils-ui/admin/i18n/en_US.json @@ -905,8 +905,7 @@ "The item is {{ status }}": "The item is {{ status }}", "The item is already checked out or requested by this patron.": "The item is already checked out or requested by this patron.", "The item is already in the list.": "The item is already in the list.", - "The item is in transit": "The item is in transit", - "The item is in transit to [{{ destination }}]": "The item is in transit to [{{ destination }}]", + "The item is in transit to {{ destination }}": "The item is in transit to {{ destination }}", "The item status does not allow requests.": "The item status does not allow requests.", "The maximum number of files is reached. No additional upload is allowed.": "The maximum number of files is reached. No additional upload is allowed.", "The notifications for patrons without e-mail are sent to this address.": "The notifications for patrons without e-mail are sent to this address.", diff --git a/projects/admin/src/assets/rero-ils-ui/admin/i18n/es.json b/projects/admin/src/assets/rero-ils-ui/admin/i18n/es.json index 45b0ff1ec..7c4c926ea 100644 --- a/projects/admin/src/assets/rero-ils-ui/admin/i18n/es.json +++ b/projects/admin/src/assets/rero-ils-ui/admin/i18n/es.json @@ -906,7 +906,7 @@ "The item is already checked out or requested by this patron.": "El ejemplar ya está eb préstamo o reservado por el usuario.", "The item is already in the list.": "El ejemplar ya está en la lista.", "The item is in transit": "El ejemplar está en tránsito", - "The item is in transit to [{{ destination }}]": "El ejemplar está en tránsito a [{{ destination }}]", + "The item is in transit to {{ destination }}": "El ejemplar está en tránsito a {{ destination }}", "The item status does not allow requests.": "El estado del ejemplar no permite reservaciones.", "The maximum number of files is reached. No additional upload is allowed.": "The maximum number of files is reached. No additional upload is allowed.", "The notifications for patrons without e-mail are sent to this address.": "Las notificaciones para los usuarios sin correo electrónico se envían a esta dirección.", diff --git a/projects/admin/src/assets/rero-ils-ui/admin/i18n/fr.json b/projects/admin/src/assets/rero-ils-ui/admin/i18n/fr.json index 8becc07a2..1430c685f 100644 --- a/projects/admin/src/assets/rero-ils-ui/admin/i18n/fr.json +++ b/projects/admin/src/assets/rero-ils-ui/admin/i18n/fr.json @@ -905,8 +905,7 @@ "The item is {{ status }}": "L'exemplaire est {{ status }}", "The item is already checked out or requested by this patron.": "L'exemplaire est déjà en prêt ou demandé par ce lecteur.", "The item is already in the list.": "L'exemplaire est déjà dans la liste.", - "The item is in transit": "L'exemplaire est en transit", - "The item is in transit to [{{ destination }}]": "L'exemplaire est en transit vers [{{ destination }}]", + "The item is in transit to {{ destination }}": "L'exemplaire est en transit vers {{ destination }}", "The item status does not allow requests.": "Le statut de l'exemplaire n'autorise pas les demandes.", "The maximum number of files is reached. No additional upload is allowed.": "Nombre maximum de fichiers atteint. Aucun chargement supplémentaire autorisé.", "The notifications for patrons without e-mail are sent to this address.": "Les notifications aux lecteurs sans e-mail sont envoyées à cette adresse.", diff --git a/projects/admin/src/assets/rero-ils-ui/admin/i18n/it.json b/projects/admin/src/assets/rero-ils-ui/admin/i18n/it.json index 443605e95..932dc3602 100644 --- a/projects/admin/src/assets/rero-ils-ui/admin/i18n/it.json +++ b/projects/admin/src/assets/rero-ils-ui/admin/i18n/it.json @@ -905,8 +905,7 @@ "The item is {{ status }}": "The item is {{ status }}", "The item is already checked out or requested by this patron.": "L'esemplare è già in prestito o richiesto da questo lettore.", "The item is already in the list.": "L'esemplare è già nella lista.", - "The item is in transit": "L'esemplare è in transito", - "The item is in transit to [{{ destination }}]": "L'esemplare è in transito verso [{{ destinazione }}]", + "The item is in transit to {{ destination }}": "L'esemplare è in transito verso {{ destination }}", "The item status does not allow requests.": "Lo stato dell'esemplare non consente le richieste.", "The maximum number of files is reached. No additional upload is allowed.": "È stato raggiunto il numero massimo di file. Non è consentito un ulteriore caricamento.", "The notifications for patrons without e-mail are sent to this address.": "Le notifiche per i lettori senza e-mail vengono inviate a questo indirizzo.", diff --git a/projects/admin/src/assets/rero-ils-ui/admin/i18n/nl.json b/projects/admin/src/assets/rero-ils-ui/admin/i18n/nl.json index 08d8ef83c..2183efb8f 100644 --- a/projects/admin/src/assets/rero-ils-ui/admin/i18n/nl.json +++ b/projects/admin/src/assets/rero-ils-ui/admin/i18n/nl.json @@ -905,8 +905,7 @@ "The item is {{ status }}": "The item is {{ status }}", "The item is already checked out or requested by this patron.": "Item is al uitleend of aangevraagd door de lezer.", "The item is already in the list.": "Het exemplaar staat al in de lijst", - "The item is in transit": "The item is in transit", - "The item is in transit to [{{ destination }}]": "The item is in transit to [{{ destination }}]", + "The item is in transit to {{ destination }}": "The item is in transit to {{ destination }}", "The item status does not allow requests.": "The item status does not allow requests.", "The maximum number of files is reached. No additional upload is allowed.": "The maximum number of files is reached. No additional upload is allowed.", "The notifications for patrons without e-mail are sent to this address.": "The notifications for patrons without e-mail are sent to this address.", diff --git a/projects/admin/src/manual_translations.ts b/projects/admin/src/manual_translations.ts index 62afadaa3..f1ca46b0a 100644 --- a/projects/admin/src/manual_translations.ts +++ b/projects/admin/src/manual_translations.ts @@ -172,7 +172,7 @@ _('Circulation policy disallows the operation.'); _('No circulation action performed'); _('Item returned at owning library'); _('The item is {{ status }}'); -_('The item is in transit to [{{ destination }}]'); +_('The item is in transit to {{ destination }}'); _('Checkout is not allowed by circulation policy'); // item note