From 0aa8c036390647e2a3dac694cfb11ad2a62e680b Mon Sep 17 00:00:00 2001 From: Florian Bontemps Date: Tue, 28 Jun 2022 13:42:46 +0000 Subject: [PATCH] Bug 26247: Adding two Sysprefs for Search Terms This patch adds two system preferences options : 'RetainCatalogSearchTerms' and 'RetainPatronsSearchTerms'. If enabled, search terms will be retained between searches made from, respectively, the Search Catalog header and the Checkout or Search Patrons headers. If disabled, the searchbars will clear out between page loads. To test: 1 - From the staff client, search some terms using the Check out header search bar. 2 - Confirm search terms are retained. 3 - Do Step 1-2 twice again, this time using the Search patrons and Search the catalog. 4 - Apply patch, update database. 5 - In the system preferences, look for RetainCatalogSearchTerms and set it to 'don't retain'. 6 - Use the checkout head search bar again, confirm that search terms aren't retained after page load. 7 - Do Step 5-6 once again, this time with the RetainPatronsSearchTerms and the Search Patrons and Search the catalog headers. 8 - Search boxes should be cleared. Thanks-to: Fridolin Somers and Nick Clemens for the bases I built on --- ...ug_26247-add_RetainCatalogSearchTerms_syspref.pl | 13 +++++++++++++ ...ug_26247-add_RetainPatronsSearchTerms_syspref.pl | 13 +++++++++++++ installer/data/mysql/mandatory/sysprefs.sql | 2 ++ .../prog/en/includes/catalogue-search-box.inc | 6 +++++- .../prog/en/includes/patron-search-header.inc | 4 ++++ .../en/modules/admin/preferences/circulation.pref | 7 +++++++ .../en/modules/admin/preferences/searching.pref | 7 +++++++ 7 files changed, 51 insertions(+), 1 deletion(-) create mode 100644 installer/data/mysql/atomicupdate/bug_26247-add_RetainCatalogSearchTerms_syspref.pl create mode 100644 installer/data/mysql/atomicupdate/bug_26247-add_RetainPatronsSearchTerms_syspref.pl diff --git a/installer/data/mysql/atomicupdate/bug_26247-add_RetainCatalogSearchTerms_syspref.pl b/installer/data/mysql/atomicupdate/bug_26247-add_RetainCatalogSearchTerms_syspref.pl new file mode 100644 index 0000000000..a8e9a14752 --- /dev/null +++ b/installer/data/mysql/atomicupdate/bug_26247-add_RetainCatalogSearchTerms_syspref.pl @@ -0,0 +1,13 @@ +use Modern::Perl; + +return { + bug_number => "26247", + description => "Add new system preference RetainCatalogSearchTerms", + up => sub { + my ($args) = @_; + my ($dbh, $out) = @$args{qw(dbh out)}; + + $dbh->do(q{INSERT IGNORE INTO systempreferences (variable,value,options,explanation,type) VALUES ('RetainCatalogSearchTerms', '1', NULL, 'If enabled, searches entered into the catalog search bar will be retained', 'YesNo') }); + }, +}; + diff --git a/installer/data/mysql/atomicupdate/bug_26247-add_RetainPatronsSearchTerms_syspref.pl b/installer/data/mysql/atomicupdate/bug_26247-add_RetainPatronsSearchTerms_syspref.pl new file mode 100644 index 0000000000..40a5f0372a --- /dev/null +++ b/installer/data/mysql/atomicupdate/bug_26247-add_RetainPatronsSearchTerms_syspref.pl @@ -0,0 +1,13 @@ +use Modern::Perl; + +return { + bug_number => "26247", + description => "Add new system preference RetainPatronsSearchTerms", + up => sub { + my ($args) = @_; + my ($dbh, $out) = @$args{qw(dbh out)}; + + $dbh->do(q{INSERT IGNORE INTO systempreferences (variable,value,options,explanation,type) VALUES ('RetainPatronSearchTerms', '1', NULL, 'If enabled, searches entered into the checkout and patrons search bars will be retained', 'YesNo') }); + }, +}; + diff --git a/installer/data/mysql/mandatory/sysprefs.sql b/installer/data/mysql/mandatory/sysprefs.sql index c1162d9f6c..2e0d3f4e46 100644 --- a/installer/data/mysql/mandatory/sysprefs.sql +++ b/installer/data/mysql/mandatory/sysprefs.sql @@ -592,6 +592,8 @@ INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, ` ('RestrictionBlockRenewing','0',NULL,'If patron is restricted, should renewal be allowed or blocked','YesNo'), ('OPACResultsMaxItems','1','','Maximum number of available items displayed in search results','Integer'), ('OPACResultsMaxItemsUnavailable','0','','Maximum number of unavailable items displayed in search results','Integer'), +('RetainCatalogSearchTerms', '1', NULL, 'If enabled, searches entered into the catalog search bar will be retained', 'YesNo'), +('RetainPatronsSearchTerms', '1', NULL, 'If enabled, searches entered into the checkout and patrons search bar will be retained', 'YesNo'), ('ReturnBeforeExpiry','0',NULL,'If ON, checkout will be prevented if returndate is after patron card expiry','YesNo'), ('ReturnLog','1',NULL,'If ON, enables the circulation (returns) log','YesNo'), ('ReturnpathDefault','',NULL,'Use this email address as return path or bounce address for undeliverable emails','Free'), diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/catalogue-search-box.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/catalogue-search-box.inc index 134bf93de8..35af98c91d 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/includes/catalogue-search-box.inc +++ b/koha-tmpl/intranet-tmpl/prog/en/includes/catalogue-search-box.inc @@ -5,8 +5,12 @@ [% IF ( Koha.Preference('IntranetCatalogSearchPulldown') ) %] [% INCLUDE 'search_indexes.inc' %] [% END %] + [% IF ( Koha.Preference('RetainCatalogSearchTerms') ) %] - + [% ELSE %] + + [% END %] + [% END %] diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/patron-search-header.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/patron-search-header.inc index d800b9c239..12db22dfc6 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/includes/patron-search-header.inc +++ b/koha-tmpl/intranet-tmpl/prog/en/includes/patron-search-header.inc @@ -11,7 +11,11 @@
+ [% IF ( Koha.Preference('RetainPatronsSearchTerms') ) %] + [% ELSE %] + + [% END %] [-] [+] diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/circulation.pref b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/circulation.pref index 1da543cc74..05113970a8 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/circulation.pref +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/circulation.pref @@ -85,6 +85,13 @@ Circulation: - pref: numReturnedItemsToShow class: integer - last returned items on the checkin screen. + - + - When searching from the checkout or patrons headers in the staff client, + - pref: RetainPatronsSearchTerms + choices: + 0: don't retain + 1: retain + - search terms between searches. - - pref: FineNotifyAtCheckin choices: 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 69619fd6f8..e92d5517e9 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 @@ -269,6 +269,13 @@ Searching: 1: "search" 0: "don't search" - on all variations of the ISBN. + - + - When searching from the catalog header in the staff client, + - pref: RetainCatalogSearchTerms + choices: + 0: "don't retain" + 1: "retain" + - search terms between searches. - - pref: BiblioItemtypeInfo choices: -- 2.30.2