From 938915e47f4105b97cae17ef94a075bbb2a8e28b Mon Sep 17 00:00:00 2001 From: Owen Leonard Date: Mon, 28 Oct 2019 16:02:35 +0000 Subject: [PATCH] Bug 23913: Use a single menu to sort lists in the OPAC This patch modifies the sorting form on the OPAC list contents view so that the two menus (sort field and direction) are combined into one. This makes it consistent with the sort menu on the search results page. To test, apply the patch and view a list with multiple titles on it. Test the "Sort by" menu, trying all the various options. Confirm that the pre-selected item in the sorting menu is correct after each re-sort. Edit the list to change the default sorting and verify that the "Sort by" menu reflects your selection. Signed-off-by: Katrin Fischer Signed-off-by: Jonathan Druart --- .../opac-tmpl/bootstrap/en/modules/opac-shelves.tt | 110 ++++++++++++--------- opac/opac-shelves.pl | 9 +- 2 files changed, 72 insertions(+), 47 deletions(-) diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-shelves.tt b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-shelves.tt index d96c4a3684..2ec0e49e9b 100644 --- a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-shelves.tt +++ b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-shelves.tt @@ -207,52 +207,68 @@ - - - [% IF sortfield == 'author' %] - - [% ELSE %] - - [% END %] - - [% IF sortfield == 'title' %] - - [% ELSE %] - - [% END %] - - [% IF sortfield == 'itemcallnumber' %] - - [% ELSE %] - - [% END %] - - [% IF sortfield == 'copyrightdate' %] - - [% ELSE %] - - [% END %] - - [% IF sortfield == "dateadded" %] - - [% ELSE %] - - [% END %] - - - @@ -977,6 +993,10 @@ $(function() { stickyClass: "floating" }); + $("#sortfield").on("change", function(){ + $('#sorting-form').submit(); + }); + }); // document.ready function AdjustRemark() { diff --git a/opac/opac-shelves.pl b/opac/opac-shelves.pl index 802366d994..f671f1f3f1 100755 --- a/opac/opac-shelves.pl +++ b/opac/opac-shelves.pl @@ -234,9 +234,14 @@ if ( $op eq 'view' ) { if ( $shelf ) { if ( $shelf->can_be_viewed( $loggedinuser ) ) { $category = $shelf->category; - my $sortfield = $query->param('sortfield') || $shelf->sortfield; # Passed in sorting overrides default sorting + my( $sortfield, $direction ); + if( defined( $query->param('sortfield') ) ){ # Passed in sorting overrides default sorting + ( $sortfield, $direction ) = split /:/, $query->param('sortfield'); + } else { + $sortfield = $shelf->sortfield; + $direction = 'asc'; + } $sortfield = 'title' unless grep $_ eq $sortfield, qw( title author copyrightdate itemcallnumber dateadded ); - my $direction = $query->param('direction') || 'asc'; $direction = 'asc' if $direction ne 'asc' and $direction ne 'desc'; my ( $page, $rows ); unless ( $query->param('print') or $query->param('rss') ) { -- 2.11.0