Bugzilla – Attachment 146018 Details for
Bug 32121
Show an alert when adding a checked out item to an item bundle
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 32121: (QA follow-up) Use error_code rather than key
Bug-32121-QA-follow-up-Use-errorcode-rather-than-k.patch (text/plain), 5.75 KB, created by
Martin Renvoize (ashimema)
on 2023-02-02 16:19:56 UTC
(
hide
)
Description:
Bug 32121: (QA follow-up) Use error_code rather than key
Filename:
MIME Type:
Creator:
Martin Renvoize (ashimema)
Created:
2023-02-02 16:19:56 UTC
Size:
5.75 KB
patch
obsolete
>From d3301b4c5095525150a3d07e9365fabd87822e87 Mon Sep 17 00:00:00 2001 >From: Martin Renvoize <martin.renvoize@ptfs-europe.com> >Date: Thu, 2 Feb 2023 16:17:06 +0000 >Subject: [PATCH] Bug 32121: (QA follow-up) Use error_code rather than key > >We semi-recently introduced error_code into our error object to allow >for translation and code paths for different errors without having to >rely on long description string matches. > >This QA follow-up converts the existing match and new 'key' fields >introduced in this patchset to use the updated 'error_code' key. > >Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com> >--- > Koha/REST/V1/Items.pm | 32 +++++++++++-------- > .../prog/en/modules/catalogue/detail.tt | 8 ++--- > 2 files changed, 23 insertions(+), 17 deletions(-) > >diff --git a/Koha/REST/V1/Items.pm b/Koha/REST/V1/Items.pm >index 515acff3b6e..365d5e29929 100644 >--- a/Koha/REST/V1/Items.pm >+++ b/Koha/REST/V1/Items.pm >@@ -289,35 +289,41 @@ sub add_to_bundle { > return $c->render( > status => 409, > openapi => { >- error => 'Item is already bundled', >- key => $_->duplicate_id >+ error => 'Item is already bundled', >+ error_code => 'already_bundled', >+ key => $_->duplicate_id > } > ); > } >- elsif ( ref($_) eq 'Koha::Exceptions::Item::Bundle::IsBundle' ) { >+ elsif ( ref($_) eq 'Koha::Exceptions::Item::Bundle::ItemIsCheckedOut' ) >+ { > return $c->render( >- status => 400, >+ status => 409, > openapi => { >- error => 'Bundles cannot be nested' >+ error => 'Item is checked out', >+ error_code => 'checked_out' > } > ); >- } elsif (ref($_) eq 'Koha::Exceptions::Item::Bundle::ItemIsCheckedOut') { >+ } >+ elsif ( ref($_) eq 'Koha::Exceptions::Checkin::FailedCheckin' ) { > return $c->render( > status => 409, > openapi => { >- error => 'Item is checked out', >- key => 'checked_out' >+ error => 'Item cannot be checked in', >+ error_code => 'failed_checkin' > } > ); >- } elsif (ref($_) eq 'Koha::Exceptions::Checkin::FailedCheckin') { >+ } >+ elsif ( ref($_) eq 'Koha::Exceptions::Item::Bundle::IsBundle' ) { > return $c->render( >- status => 409, >+ status => 400, > openapi => { >- error => 'Item cannot be checked in', >- key => 'failed_checkin' >+ error => 'Bundles cannot be nested', >+ error_code => 'failed_nesting' > } > ); >- } else { >+ } >+ else { > $c->unhandled_exception($_); > } > }; >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/detail.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/detail.tt >index 07ec640925f..a9d8d220c78 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/detail.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/detail.tt >@@ -1779,9 +1779,9 @@ Note that permanent location is a code, and location may be an authval. > posting.fail(function(data) { > if ( data.status === 409 ) { > var response = data.responseJSON; >- if ( response.key === "PRIMARY" ) { >+ if ( response.error_code === 'already_bundled' ) { > $('#addResult').replaceWith('<div id="addResult" class="alert alert-warning">'+_("Warning: Item '%s' already attached").format(barcode)+'</div>'); >- } else if (response.key === 'checked_out') { >+ } else if (response.error_code === 'checked_out') { > const button = $('<button type="button">') > .addClass('btn btn-xs') > .text(__('Check in and add to bundle')) >@@ -1793,7 +1793,7 @@ Note that permanent location is a code, and location may be an authval. > .attr('class', 'alert alert-warning') > .append(__x('Warning: Item {barcode} is checked out', { barcode })) > .append(' ', button); >- } else if (response.key === 'failed_checkin') { >+ } else if (response.error_code === 'failed_checkin') { > $('#addResult') > .empty() > .attr('class', 'alert alert-danger') >@@ -1805,7 +1805,7 @@ Note that permanent location is a code, and location may be an authval. > $('#addResult').replaceWith('<div id="addResult" class="alert alert-danger">'+_("Failure: Item '%s' not found").format(barcode)+'</div>'); > } else if ( data.status === 400 ) { > var response = data.responseJSON; >- if ( response.error === "Bundles cannot be nested" ) { >+ if ( response.error_code === "failed_nesting" ) { > $('#addResult').replaceWith('<div id="addResult" class="alert alert-danger">'+_("Failure: Item '%s' is a bundle and bundles cannot be nested").format(barcode)+'</div>'); > } else { > $('#addResult').replaceWith('<div id="addResult" class="alert alert-danger">'+_("Failure: Check the logs for details")+'</div>'); >-- >2.39.1
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 32121
:
143367
|
146017
|
146018
|
148659
|
148660
|
148664
|
148667
|
148668
|
148669