Bugzilla – Attachment 184550 Details for
Bug 38122
Cannot sort holdings table by status
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 38122: Sort holdings table by status
Bug-38122-Sort-holdings-table-by-status.patch (text/plain), 3.28 KB, created by
Hammat wele
on 2025-07-23 12:57:41 UTC
(
hide
)
Description:
Bug 38122: Sort holdings table by status
Filename:
MIME Type:
Creator:
Hammat wele
Created:
2025-07-23 12:57:41 UTC
Size:
3.28 KB
patch
obsolete
>From 3a04c0a7860006f9603ad89b237a56d4a6b877fb Mon Sep 17 00:00:00 2001 >From: Hammat Wele <hammat.wele@inlibro.com> >Date: Wed, 23 Jul 2025 12:56:56 +0000 >Subject: [PATCH] Bug 38122: Sort holdings table by status > >To test: > > 1. Apply the patch > 2. Go to a record details page Example: http://localhost:8081/cgi-bin/koha/catalogue/detail.pl?biblionumber=285 > 3. Add several items to the record (with different statuses) > 3. Click the Status column header in the holdings table to sort > ---> items are correctly sorted by status (ascending and descending on repeated clicks) >--- > Koha/REST/V1/Biblios.pm | 28 +++++++++++++++++-- > .../tables/items/catalogue_detail.inc | 4 +-- > 2 files changed, 28 insertions(+), 4 deletions(-) > >diff --git a/Koha/REST/V1/Biblios.pm b/Koha/REST/V1/Biblios.pm >index f99b61af223..ddda0adde35 100644 >--- a/Koha/REST/V1/Biblios.pm >+++ b/Koha/REST/V1/Biblios.pm >@@ -280,8 +280,32 @@ sub get_items { > ); > } > >- # FIXME We need to order_by serial.publisheddate if we have _order_by=+me.serial_issue_number >- my $items = $c->objects->search($items_rs); >+ my $items; >+ >+ my $sort = $c->param('_order_by') // ''; >+ my $args = $c->validation->output; >+ >+ if ( $sort =~ /^[+-]me\._status$/ && $args->{_order_by} ) { >+ my $order_by = $args->{_order_by}; >+ my @order_by = ref $order_by eq 'ARRAY' ? @$order_by : ($order_by); >+ >+ # Supprimer les tris sur champs virtuels comme me._status >+ @order_by = grep { $_ !~ /^[-+]?me\._status$/ } @order_by; >+ >+ $args->{_order_by} = @order_by ? \@order_by : undef; >+ delete $args->{_order_by} unless (@order_by); >+ $items = $c->objects->search( $items_rs, $args ); >+ if ( $sort eq '+me._status' ) { >+ @$items = >+ sort { join( ',', @{ $a->{_status} // [] } ) cmp join( ',', @{ $b->{_status} // [] } ) } @$items; >+ } elsif ( $sort eq '-me._status' ) { >+ @$items = >+ sort { join( ',', @{ $b->{_status} // [] } ) cmp join( ',', @{ $a->{_status} // [] } ) } @$items; >+ } >+ } else { >+ # FIXME We need to order_by serial.publisheddate if we have _order_by=+me.serial_issue_number >+ $items = $c->objects->search($items_rs); >+ } > > return $c->render( > status => 200, >diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/html_helpers/tables/items/catalogue_detail.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/html_helpers/tables/items/catalogue_detail.inc >index 50e9b4a9df0..2fd5efeae18 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/includes/html_helpers/tables/items/catalogue_detail.inc >+++ b/koha-tmpl/intranet-tmpl/prog/en/includes/html_helpers/tables/items/catalogue_detail.inc >@@ -532,10 +532,10 @@ > } > }, > { >- data: "", >+ data: "_status", > className: "status", > searchable: false, >- orderable: false, >+ orderable: true, > render: function (data, type, row, meta) { > let nodes = ""; > row._status.forEach( status => { >-- >2.34.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 38122
:
183789
| 184550