From 437a3e1de58e0555c0c9a7f1891ffe351d2ce94e Mon Sep 17 00:00:00 2001 From: ThibaudGLT Date: Wed, 8 Dec 2021 09:16:38 +0000 Subject: [PATCH] Bug 20398: Added a syspref to highlight or not highlight search terms in results on the staff interface There is a possibility on OPAC but not yet on the staff interface, so I added this syspref which has the same behaviour as the OPAC highlighting syspref. When you choose to disable highlighting on the syspref, the toggle anchor in the result page does not appear at all. But if you keep the default state (highlighting on), you still have the option to switch between "Unhighlight" and "Highlight" modes. Test plan : 1. Go to the syspref named "StaffHighlightedWords" and see that the default state is "Highlight". 2. Look for something in the catalogue for example and see that the words are highlighted and that it is also possible to change between "Unhighlight" and "Highlight". 3. Go back to syspref and choose to disable highlighting by choosing "Don't Highlight". 4. Refresh your results page if you have not closed it or reload a new search. 5. There is no highlighting at all and anchors do not exist (same behaviour as the OPAC interface). Signed-off-by: ManuB Signed-off-by: Katrin Fischer Signed-off-by: Fridolin Somers --- ...ystem-preference-StaffHighlightedWords.perl | 8 ++++++++ installer/data/mysql/mandatory/sysprefs.sql | 1 + .../admin/preferences/staff_interface.pref | 7 +++++++ .../prog/en/modules/catalogue/results.tt | 9 ++++++--- .../intranet-tmpl/prog/js/pages/results.js | 18 ++++++++++++------ 5 files changed, 34 insertions(+), 9 deletions(-) create mode 100644 installer/data/mysql/atomicupdate/add-system-preference-StaffHighlightedWords.perl diff --git a/installer/data/mysql/atomicupdate/add-system-preference-StaffHighlightedWords.perl b/installer/data/mysql/atomicupdate/add-system-preference-StaffHighlightedWords.perl new file mode 100644 index 0000000000..2aaa8b9d40 --- /dev/null +++ b/installer/data/mysql/atomicupdate/add-system-preference-StaffHighlightedWords.perl @@ -0,0 +1,8 @@ +$DBversion = 'XXX'; +if ( CheckVersion($DBversion) ) { + $dbh->do(q{ + INSERT IGNORE INTO systempreferences (`variable`,`value`,`options`,`explanation`,`type`) + VALUES ('StaffHighlightedWords','1','','Activate or not highlighting of search terms for staff interface','YesNo ') + }); + NewVersion( $DBversion, '20398', 'Add system preference StaffHighlightedWords'); +} diff --git a/installer/data/mysql/mandatory/sysprefs.sql b/installer/data/mysql/mandatory/sysprefs.sql index 4e750929b1..27538b54f1 100644 --- a/installer/data/mysql/mandatory/sysprefs.sql +++ b/installer/data/mysql/mandatory/sysprefs.sql @@ -238,6 +238,7 @@ INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, ` ('hidelostitems','0','','If ON, disables display of\"lost\" items in OPAC.','YesNo'), ('HidePatronName','0','','If this is switched on, patron\'s cardnumber will be shown instead of their name on the holds and catalog screens','YesNo'), ('hide_marc','0',NULL,'If ON, disables display of MARC fields, subfield codes & indicators (still shows data)','YesNo'), +('StaffHighlightedWords','1','','Highlight search terms on staff interface','YesNo'), ('HoldFeeMode','not_always','any_time_is_placed|not_always|any_time_is_collected','Set the hold fee mode','Choice'), ('HoldsAutoFill','0',NULL,'If on, librarian will not be asked if hold should be filled, it will be filled automatically','YesNo'), ('HoldsAutoFillPrintSlip','0',NULL,'If on, hold slip print dialog will be displayed automatically','YesNo'), diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/staff_interface.pref b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/staff_interface.pref index d840cfaa16..08352eca1f 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/staff_interface.pref +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/staff_interface.pref @@ -125,6 +125,13 @@ Staff interface: type: textarea syntax: text/html class: code + - + - pref: StaffHighlightedWords + type: boolean + choices: + 1: Highlight + 0: Don't highlight + - words searched for in the staff interface search results pages. Options: - - pref: viewMARC 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 c9887f9d59..d404da064d 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/results.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/results.tt @@ -74,9 +74,11 @@ | Clear all | - Unhighlight - Highlight - | + [% IF Koha.Preference("StaffHighlightedWords") == 1 %] + Unhighlight + Highlight + | + [% END %] [% IF (Koha.Preference("intranetbookbag")) %]
@@ -711,6 +713,7 @@ var CoceHost = "[% CoceHost | html %]"; var CoceProviders = "[% CoceProviders | html %]"; var PREF_BrowseResultSelection = parseInt( "[% Koha.Preference('BrowseResultSelection') | html %]", 10); + var PREF_StaffHighlightedWords = "[% Koha.Preference('StaffHighlightedWords') | html %]"; var PREF_NotHighlightedWords = "[% Koha.Preference('NotHighlightedWords') | html %]"; var biblionumber = "[% biblionumber | html %]"; var holdfor_cardnumber = "[% holdfor_cardnumber | html %]"; diff --git a/koha-tmpl/intranet-tmpl/prog/js/pages/results.js b/koha-tmpl/intranet-tmpl/prog/js/pages/results.js index c7b47bdcb3..b54e046b18 100644 --- a/koha-tmpl/intranet-tmpl/prog/js/pages/results.js +++ b/koha-tmpl/intranet-tmpl/prog/js/pages/results.js @@ -1,4 +1,4 @@ -/* global KOHA biblionumber new_results_browser addMultiple vShelfAdd openWindow search_result SEARCH_RESULTS PREF_LocalCoverImages PREF_IntranetCoce PREF_CoceProviders CoceHost CoceProviders addRecord delSingleRecord PREF_BrowseResultSelection resetSearchContext addBibToContext delBibToContext getContextBiblioNumbers holdfor_cardnumber holdforclub strQuery PREF_NotHighlightedWords __ Cookies */ +/* global KOHA biblionumber new_results_browser addMultiple vShelfAdd openWindow search_result SEARCH_RESULTS PREF_LocalCoverImages PREF_IntranetCoce PREF_CoceProviders CoceHost CoceProviders addRecord delSingleRecord PREF_BrowseResultSelection resetSearchContext addBibToContext delBibToContext getContextBiblioNumbers holdfor_cardnumber holdforclub strQuery PREF_StaffHighlightedWords PREF_NotHighlightedWords __ */ function verify_cover_images() { /* Loop over each container in the template which contains covers */ @@ -202,17 +202,23 @@ $(document).ready(function() { while ( q_array.length > 0 && q_array[q_array.length-1] == "") { q_array = q_array.splice(0,-1); } - highlightOn(); - $("#highlight_toggle_on" ).hide().click(function(e) { + $("#highlight_toggle_off" ).hide().click(function(e) { e.preventDefault(); - highlightOn(); + highlightOff(); }); - $("#highlight_toggle_off").show().click(function(e) { + $("#highlight_toggle_on").show().click(function(e) { e.preventDefault(); - highlightOff(); + highlightOn(); }); } + if( PREF_StaffHighlightedWords == 1 ){ + highlightOn(); + } else { + highlightOff(); + } + + if( SEARCH_RESULTS ){ var browser = KOHA.browser( search_result.searchid, parseInt( biblionumber, 10)); browser.create( search_result.first_result_number, search_result.query_cgi, search_result.limit_cgi, search_result.sort_by, new_results_browser, search_result.total ); -- 2.39.5