From 0f4ca331ed83c87e71839716fd2dd49340c70469 Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Tue, 16 Dec 2025 12:02:23 +0100 Subject: [PATCH] Bug 41456: Fix item type searching and filtering on the holds history table Use should use coded_values for the library and item type column so that we can search using the code and the description. With this patch we now have a dropdown list with the libraries and item types in the table's headers. Test plan: 0. Turn on AllowHoldItemTypeSelection 1. Create a hold and select an item type Note: I think there is a bug if you select it from "Hold next available item", use "Hold details". Please confirm? 2. Go to the holds history view 3. Filter and search by item type description and code. Same for library. Use the dropdown list in the headers. Signed-off-by: David Nind --- Koha/Hold.pm | 19 +++++++- api/v1/swagger/definitions/hold.yaml | 2 +- .../prog/en/modules/members/holdshistory.tt | 46 ++++++++++++++++--- t/db_dependent/Koha/Hold.t | 45 ++++++++++++++++-- 4 files changed, 99 insertions(+), 13 deletions(-) diff --git a/Koha/Hold.pm b/Koha/Hold.pm index 66a236a853..78eb4a5d38 100644 --- a/Koha/Hold.pm +++ b/Koha/Hold.pm @@ -695,6 +695,19 @@ sub item { return Koha::Item->_new_from_dbic($rs); } +=head3 item_type + +Returns the related Koha::ItemType object for this hold + +=cut + +sub item_type { + my ($self) = @_; + my $rs = $self->_result->itemtype; + return unless $rs; + return Koha::ItemType->_new_from_dbic($rs); +} + =head3 item_group Returns the related Koha::Biblio::ItemGroup object for this Hold @@ -1281,7 +1294,7 @@ sub to_api_mapping { lowestPriority => 'lowest_priority', suspend => 'suspended', suspend_until => 'suspended_until', - itemtype => 'item_type', + itemtype => 'item_type_id', item_level_hold => 'item_level', }; } @@ -1319,6 +1332,10 @@ sub strings_map { pickup_library_id => { str => $self->pickup_library->branchname, type => 'library' }, }; + if ( defined $self->itemtype ) { + $strings->{item_type_id} = { str => $self->item_type->description, type => 'item_type' }; + } + if ( defined $self->cancellation_reason ) { my $av = Koha::AuthorisedValues->search( { diff --git a/api/v1/swagger/definitions/hold.yaml b/api/v1/swagger/definitions/hold.yaml index f09580f874..9a62c768c4 100644 --- a/api/v1/swagger/definitions/hold.yaml +++ b/api/v1/swagger/definitions/hold.yaml @@ -101,7 +101,7 @@ properties: non_priority: description: Set this hold as non priority type: boolean - item_type: + item_type_id: type: - string - "null" diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/members/holdshistory.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/members/holdshistory.tt index 909f021204..3145bc1424 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/members/holdshistory.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/members/holdshistory.tt @@ -1,3 +1,4 @@ +[% USE To %] [% USE raw %] [% USE Asset %] [% USE KohaDates %] @@ -158,6 +159,29 @@ [% INCLUDE 'str/members-menu.inc' %] [% Asset.js("js/members-menu.js") | $raw %] [% INCLUDE 'js-biblio-format.inc' %] +