From 01a5e63bb7121c95f7d3a2323c59bce3e7376281 Mon Sep 17 00:00:00 2001 From: Aleisha Amohia Date: Tue, 5 Nov 2019 02:53:26 +0000 Subject: [PATCH] Bug 14715: Results per page dropdown for catalogue search This patch utilises an unused search facet to handle results shown per page. To test: 1) Enable patch and update database to apply atomic updates 2) Go to system preferences and set both 'numSearchResultsDropdown' and 'OPACnumSearchResultsDropdown' to 'Show' 3) Set both 'numSearchResults' and 'OPACnumSearchResults' system preferences to 10 so that it will be clear to see how the patch works 4) Do a catalogue search in the intranet using a search term that will bring lots of results 5) The results per page dropdown should show with the selected option as the library default, the value of numSearchResults. The number of results shown on the page should match numSearchResults. 6) Choose a different number of results per page in the dropdown. The search results will automatically refresh 7) Confirm that the correct number of results per page shows 8) Confirm that changing pages does not revert the number of results shown per page to the default value 9) Confirm that you are still able to use other search facets as expected 10) Repeat steps 4-9 on the OPAC (note OPAC uses OPACnumSearchResults as the default value) Sponsored-by: Region Halland --- ..._14715-add_resultsperpagedropdown_sysprefs.perl | 11 ++++++++++ installer/data/mysql/sysprefs.sql | 2 ++ .../prog/en/includes/page-numbers.inc | 10 ++++----- .../en/modules/admin/preferences/searching.pref | 18 ++++++++++++++++ .../prog/en/modules/catalogue/results.tt | 23 ++++++++++++++++++++ .../bootstrap/en/includes/page-numbers.inc | 10 ++++----- .../opac-tmpl/bootstrap/en/modules/opac-results.tt | 25 ++++++++++++++++++++++ 7 files changed, 89 insertions(+), 10 deletions(-) create mode 100644 installer/data/mysql/atomicupdate/bug_14715-add_resultsperpagedropdown_sysprefs.perl diff --git a/installer/data/mysql/atomicupdate/bug_14715-add_resultsperpagedropdown_sysprefs.perl b/installer/data/mysql/atomicupdate/bug_14715-add_resultsperpagedropdown_sysprefs.perl new file mode 100644 index 0000000..c107cb6 --- /dev/null +++ b/installer/data/mysql/atomicupdate/bug_14715-add_resultsperpagedropdown_sysprefs.perl @@ -0,0 +1,11 @@ +$DBversion = 'XXX'; +if( CheckVersion( $DBversion ) ) { + $dbh->do(q{ + INSERT IGNORE INTO systempreferences (`variable`, `value`, `options`, `explanation`,`type`) VALUES + ('OPACnumSearchResultsDropdown', 0, NULL, 'Enable option list of number of results per page to show in OPAC search results','YesNo'), + ('numSearchResultsDropdown', 0, NULL, 'Enable option list of number of results per page to show in staff client search results','YesNo') + }); + + SetVersion( $DBversion ); + print "Upgrade to $DBversion done (Bug 14715 - Add sysprefs numSearchResultsDropdown and OPACnumSearchResultsDropdown)\n"; +} diff --git a/installer/data/mysql/sysprefs.sql b/installer/data/mysql/sysprefs.sql index 86514d9..80b61a9 100644 --- a/installer/data/mysql/sysprefs.sql +++ b/installer/data/mysql/sysprefs.sql @@ -342,6 +342,7 @@ INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, ` ('numReturnedItemsToShow','20',NULL,'Number of returned items to show on the check-in page','Integer'), ('NumSavedReports', '20', NULL, 'By default, show this number of saved reports.', 'Integer'), ('numSearchResults','20',NULL,'Specify the maximum number of results to display on a page of results','Integer'), +('numSearchResultsDropdown', 0, NULL, 'Enable option list of number of results per page to show in staff client search results','YesNo'), ('numSearchRSSResults','50',NULL,'Specify the maximum number of results to display on a RSS page of results','Integer'), ('OAI-PMH','0',NULL,'if ON, OAI-PMH server is enabled','YesNo'), ('OAI-PMH:archiveID','KOHA-OAI-TEST',NULL,'OAI-PMH archive identification','Free'), @@ -412,6 +413,7 @@ INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, ` ('OPACNoResultsFound','','70|10','Display this HTML when no results are found for a search in the OPAC','Textarea'), ('OPACNumbersPreferPhrase','0',NULL,'Control the use of phr operator in callnumber and standard number OPAC searches','YesNo'), ('OPACnumSearchResults','20',NULL,'Specify the maximum number of results to display on a page of results','Integer'), +('OPACnumSearchResultsDropdown', 0, NULL, 'Enable option list of number of results per page to show in OPAC search results','YesNo'), ('OpacPasswordChange','1',NULL,'If ON, enables patron-initiated password change in OPAC (disable it when using LDAP auth)','YesNo'), ('OPACPatronDetails','1','','If OFF the patron details tab in the OPAC is disabled.','YesNo'), ('OPACpatronimages','0',NULL,'Enable patron images in the OPAC','YesNo'), diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/page-numbers.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/page-numbers.inc index 4fb9a6b..03cf92d 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/includes/page-numbers.inc +++ b/koha-tmpl/intranet-tmpl/prog/en/includes/page-numbers.inc @@ -1,19 +1,19 @@ [% IF ( PAGE_NUMBERS ) %][% END %] diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/searching.pref b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/searching.pref index 497447f..012f121 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/searching.pref +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/searching.pref @@ -140,6 +140,24 @@ Searching: - 'the operator "phr" in the callnumber and standard number staff client searches' Results Display: - + - pref: numSearchResultsDropdown + type: boolean + default: no + choices: + yes: Show + no: "Don't show" + - results per page dropdown on staff client search results. + - "Note: This does not work if ElasticSearch is activated." + - + - pref: OPACnumSearchResultsDropdown + type: boolean + default: no + choices: + yes: Show + no: "Don't show" + - results per page dropdown on OPAC search results. + - "Note: This does not work if ElasticSearch is activated." + - - By default, sort search results in the staff client by - pref: defaultSortField default: relevance 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 2f8d5db..8c9d2aa 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/results.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/results.tt @@ -267,6 +267,29 @@ [% END %] + + [% IF Koha.Preference('numSearchResultsDropdown') && Koha.Preference('SearchEngine') == "Zebra" %] +
+ + +
+ [% END %] + diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/includes/page-numbers.inc b/koha-tmpl/opac-tmpl/bootstrap/en/includes/page-numbers.inc index 3633b0c..af10556 100644 --- a/koha-tmpl/opac-tmpl/bootstrap/en/includes/page-numbers.inc +++ b/koha-tmpl/opac-tmpl/bootstrap/en/includes/page-numbers.inc @@ -3,19 +3,19 @@ [% IF hits_to_paginate < total %]
[% hits_to_paginate | html %] of [% total | html %] results loaded, refine your search to view other records
[% END %] diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-results.tt b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-results.tt index 479415c..717d7aa 100644 --- a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-results.tt +++ b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-results.tt @@ -163,9 +163,29 @@ [% UNLESS tag %]
+ + [% IF Koha.Preference('OPACnumSearchResultsDropdown') && Koha.Preference('SearchEngine') == "Zebra" %] + + + [% END %] +
[% END %] +
@@ -843,6 +863,11 @@ $(document).ready(function(){ $('.resort').change(function() { $('#bookbag_form').submit(); }); + + $('#results_per_page').change(function() { + $('#bookbag_form').submit(); + }); + $("span.clearall").html(""+_("Clear all")+"<\/a>"); $("span.checkall").html(""+_("Select all")+"<\/a>"); -- 2.1.4