From c8c2d9ad795301c390ed733e123eea56e6822f59 Mon Sep 17 00:00:00 2001 From: Chloe Zermatten Date: Mon, 16 Dec 2024 11:04:59 +0000 Subject: [PATCH] Bug 38712: Order public and private lists alphabetically In the OPAC top header navigation menu, public and private lists are ordered by the date created, instead of alphabetically. Test plan: 1. On the Koha OPAC, login and navigate to Your account > Lists (/cgi-bin/koha/opac-shelves.pl). 2. Create a few public and private lists. 3. Open the lists dropdown in the top navigation menu. 4. Notice that the lists appear in the order they were created. 5. Apply the patch. 6. Refresh the page and open the lists dropdown in the top navigation. 7. Notice that the lists are now sorted alphabetically. 8. Log out and notice that the lists are now sorted alphabetically. --- C4/Auth.pm | 2 ++ Koha/Virtualshelves.pm | 14 +++++++++----- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/C4/Auth.pm b/C4/Auth.pm index 0ee06104a4..fcc9b6de54 100644 --- a/C4/Auth.pm +++ b/C4/Auth.pm @@ -333,11 +333,13 @@ sub get_template_and_user { { borrowernumber => $borrowernumber, public => 0, + search_attributes => {order_by => { -asc => 'shelfname' }} } ); my $some_public_shelves = Koha::Virtualshelves->get_some_shelves( { public => 1, + search_attributes => {order_by => { -asc => 'shelfname' }} } ); $template->param( diff --git a/Koha/Virtualshelves.pm b/Koha/Virtualshelves.pm index 58653130a4..afc9a8cadc 100644 --- a/Koha/Virtualshelves.pm +++ b/Koha/Virtualshelves.pm @@ -191,16 +191,20 @@ sub get_some_shelves { }; } + my $default_search_attributes = { + join => [ 'virtualshelfshares' ], + distinct => 'shelfnumber', + order_by => { -desc => 'lastmodified' }, + }; + + my %search_attributes = (%{$default_search_attributes}, %{$params->{search_attributes}}); + $self->search( { public => $public, ( @conditions ? ( -and => \@conditions ) : () ), }, - { - join => [ 'virtualshelfshares' ], - distinct => 'shelfnumber', - order_by => { -desc => 'lastmodified' }, - } + \%search_attributes ); } -- 2.39.5