From 2753eec1ce8ce57afc10162936967d1f39c2b0b8 Mon Sep 17 00:00:00 2001 From: Julian Maurice Date: Wed, 7 Feb 2024 14:36:01 +0100 Subject: [PATCH] Bug 35963: Fix bundled items table ordering and filtering Using the many-to-many relationship results in the table alias `me` to be used for table `item_bundles` instead of the expected table `items`. This causes ordering and filtering to fail for columns Callnumber and Barcode. Using Koha::Items->search does not have this problem. This patch also disables ordering by status because it does not work (error message is: "Cannot find Koha::Object class for return_claim'") Test plan: 1. Create an item bundle https://koha-community.org/manual/23.11/en/html/circulation.html#circulating-bundles 2. Add at least 2 items to this bundle 3. Verify that ordering/filtering by callnumber or barcode works 4. Run `prove t/db_dependent/api/v1/items/bundled_items.t` Signed-off-by: Victor Grousset/tuxayo Signed-off-by: Martin Renvoize Signed-off-by: Katrin Fischer --- Koha/REST/V1/Items.pm | 11 +++++++++-- .../intranet-tmpl/prog/en/modules/catalogue/detail.tt | 2 +- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/Koha/REST/V1/Items.pm b/Koha/REST/V1/Items.pm index 5db12b669d..69333c1bdf 100644 --- a/Koha/REST/V1/Items.pm +++ b/Koha/REST/V1/Items.pm @@ -294,8 +294,15 @@ sub bundled_items { } return try { - my $items_set = $item->bundle_items; - my $items = $c->objects->search( $items_set ); + my $items_set = Koha::Items->search( + { + 'item_bundles_item.host' => $item_id, + }, + { + join => 'item_bundles_item', + } + ); + my $items = $c->objects->search($items_set); return $c->render( status => 200, openapi => $items 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 863ae272f2..b8aa4e0486 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/detail.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/detail.tt @@ -1906,7 +1906,7 @@ "data": "lost_status:last_seen_date:return_claim.patron", "title": _("Status"), "searchable": false, - "orderable": true, + "orderable": false, "render": function(data, type, row, meta) { if ( row.lost_status == bundle_lost_value ) { let out = '' + _("Last seen") + ': ' + $date(row.last_seen_date) + ''; -- 2.39.5