From 8b1264095ca0f0954dd68d4e5ff103ea9191c6f3 Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Tue, 17 Dec 2019 10:45:11 +0100 Subject: [PATCH] Bug 24219: Preserve sort order when returning to result list There is a mismatch between sort_cgi, sort and sort_by variables. * sort_cgi I did not find relevant occurrences of sort_cgi in the git log of both search.pl and results.tt. So it seems that it never worked correctly. * sort It is the JS variable use in browser.js * sort_by is the search.pl parameter to set the sort_by option Test plan: 1. Perform a search in the staff client 2. Change the sort order to something different (try Author A-Z) 3. Click on a result to view the record 4. Click on "Results" button on left side to return to result list => Without this patch the result list is sorted by relevancy => With this patch applied the Author A-Z is kept --- koha-tmpl/intranet-tmpl/js/browser.js | 6 +++--- koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/results.tt | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/koha-tmpl/intranet-tmpl/js/browser.js b/koha-tmpl/intranet-tmpl/js/browser.js index 3b9ca87cbb..09f1d02d38 100644 --- a/koha-tmpl/intranet-tmpl/js/browser.js +++ b/koha-tmpl/intranet-tmpl/js/browser.js @@ -32,9 +32,9 @@ KOHA.browser = function (searchid, biblionumber) { var browseRecords = function (movement) { var newSearchPos = me.curPos + movement; if (newSearchPos > current_search.results.length - 1) { - window.location = '/cgi-bin/koha/catalogue/search.pl?' + decodeURIComponent(current_search.query) + '&limit=' + decodeURIComponent(current_search.limit) + '&sort=' + current_search.sort + '&gotoPage=detail.pl&gotoNumber=first&searchid=' + me.searchid + '&offset=' + newSearchPos; + window.location = '/cgi-bin/koha/catalogue/search.pl?' + decodeURIComponent(current_search.query) + '&limit=' + decodeURIComponent(current_search.limit) + '&sort_by=' + current_search.sort + '&gotoPage=detail.pl&gotoNumber=first&searchid=' + me.searchid + '&offset=' + newSearchPos; } else if (newSearchPos < 0) { - window.location = '/cgi-bin/koha/catalogue/search.pl?' + decodeURIComponent(current_search.query) + '&limit=' + decodeURIComponent(current_search.limit) + '&sort=' + current_search.sort + '&gotoPage=detail.pl&gotoNumber=last&searchid=' + me.searchid + '&offset=' + (me.offset - current_search.pagelen); + window.location = '/cgi-bin/koha/catalogue/search.pl?' + decodeURIComponent(current_search.query) + '&limit=' + decodeURIComponent(current_search.limit) + '&sort_by=' + current_search.sort + '&gotoPage=detail.pl&gotoNumber=last&searchid=' + me.searchid + '&offset=' + (me.offset - current_search.pagelen); } else { window.location = window.location.href.replace('biblionumber=' + biblionumber, 'biblionumber=' + current_search.results[newSearchPos]); } @@ -91,7 +91,7 @@ KOHA.browser = function (searchid, biblionumber) { $(document).ready(function () { if (me.curPos > -1) { - var searchURL = '/cgi-bin/koha/catalogue/search.pl?' + decodeURIComponent(current_search.query) + '&limit=' + decodeURIComponent(current_search.limit) + '&sort=' + current_search.sort + '&searchid=' + me.searchid + '&offset=' + me.offset; + var searchURL = '/cgi-bin/koha/catalogue/search.pl?' + decodeURIComponent(current_search.query) + '&limit=' + decodeURIComponent(current_search.limit) + '&sort_by=' + current_search.sort + '&searchid=' + me.searchid + '&offset=' + me.offset; var prevbutton; var nextbutton; if (me.curPos === 0 && current_search.offset === 1) { diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/results.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/results.tt index fe22771aa1..70eaf696f8 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/results.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/results.tt @@ -797,7 +797,7 @@ [%- END -%] ]; var browser = KOHA.browser('[% searchid | html %]', parseInt('[% biblionumber | html %]', 10)); - browser.create([% SEARCH_RESULTS.first.result_number | html %], '[% query_cgi | html %]', '[% limit_cgi | html %]','[% sort_cgi | html %]', + browser.create([% SEARCH_RESULTS.first.result_number | html %], '[% query_cgi | html %]', '[% limit_cgi | html %]','[% sort_by| html %]', newresults, '[% total | html %]'); [% END %] @@ -935,7 +935,7 @@ var bibnums = getContextBiblioNumbers(); if ( bibnums && bibnums.length > 0 ) { var browser = KOHA.browser('', parseInt('[% biblionumber | html %]', 10)); - browser.create(1, '[% query_cgi | html %]', '[% limit_cgi | html %]','[% sort_cgi | html %]', bibnums, bibnums.length); + browser.create(1, '[% query_cgi | html %]', '[% limit_cgi | html %]','[% sort_by | html %]', bibnums, bibnums.length); window.location = '/cgi-bin/koha/catalogue/detail.pl?biblionumber=' + bibnums[0] + '&searchid='+browser.searchid; } else { alert(MSG_NO_ITEM_SELECTED); -- 2.11.0