From b502d5060b106b7671393cb2ad15678fbae74eb8 Mon Sep 17 00:00:00 2001 From: Hammat Wele Date: Fri, 8 Aug 2025 20:02:16 +0000 Subject: [PATCH] Bug 27113: Fix autocomplete suggestions across Staff interface and OPAC --- ...bug_27113-elasticsearch_autocomplete_input_search.perl | 4 ++-- installer/data/mysql/mandatory/sysprefs.sql | 4 ++-- koha-tmpl/intranet-tmpl/js/elasticsearch/autocomplete.js | 2 +- koha-tmpl/intranet-tmpl/prog/en/includes/js_includes.inc | 4 ++-- .../prog/en/modules/admin/preferences/searching.pref | 4 ++-- .../intranet-tmpl/prog/en/modules/catalogue/advsearch.tt | 4 ++-- koha-tmpl/opac-tmpl/bootstrap/css/src/opac.scss | 4 ++-- koha-tmpl/opac-tmpl/bootstrap/en/includes/opac-bottom.inc | 4 ++-- .../opac-tmpl/bootstrap/en/modules/opac-advsearch.tt | 8 ++++---- 9 files changed, 19 insertions(+), 19 deletions(-) diff --git a/installer/data/mysql/atomicupdate/bug_27113-elasticsearch_autocomplete_input_search.perl b/installer/data/mysql/atomicupdate/bug_27113-elasticsearch_autocomplete_input_search.perl index fafe0894d32..44eab76acf3 100644 --- a/installer/data/mysql/atomicupdate/bug_27113-elasticsearch_autocomplete_input_search.perl +++ b/installer/data/mysql/atomicupdate/bug_27113-elasticsearch_autocomplete_input_search.perl @@ -1,9 +1,9 @@ $DBversion = 'XXX'; # will be replaced by the RM if( CheckVersion( $DBversion ) ) { # you can use $dbh here like: - $dbh->do(q{INSERT IGNORE INTO systempreferences (variable,value,options,explanation,type) VALUES ('OPACAutocompleteElasticSearch', '0', NULL, 'If ON, show search suggestions in the OPAC when using Elasticsearch.', 'YesNo')}); + $dbh->do(q{INSERT IGNORE INTO systempreferences (variable,value,options,explanation,type) VALUES ('OPACAutocompleteElasticsearch', '0', NULL, 'If ON, show search suggestions in the OPAC when using Elasticsearch.', 'YesNo')}); - $dbh->do(q{INSERT IGNORE INTO systempreferences (variable,value,options,explanation,type) VALUES ('IntranetAutocompleteElasticSearch', '0', NULL, 'If ON, show search suggestions in the staff interface when using Elasticsearch.', 'YesNo')}); + $dbh->do(q{INSERT IGNORE INTO systempreferences (variable,value,options,explanation,type) VALUES ('StaffInterfaceAutocompleteElasticsearch', '0', NULL, 'If ON, show search suggestions in the staff interface when using Elasticsearch.', 'YesNo')}); # Always end with this (adjust the bug info) NewVersion( $DBversion, 27113, "Autocomplete with Elasticsearch"); diff --git a/installer/data/mysql/mandatory/sysprefs.sql b/installer/data/mysql/mandatory/sysprefs.sql index 6c2c0ccc24a..a17822e5f6f 100644 --- a/installer/data/mysql/mandatory/sysprefs.sql +++ b/installer/data/mysql/mandatory/sysprefs.sql @@ -348,7 +348,7 @@ INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, ` ('IndependentBranchesPatronModifications','0', NULL, 'Show only modification request for the logged in branch','YesNo'), ('IndependentBranchesTransfers','0', NULL, 'Allow non-superlibrarians to transfer items between libraries','YesNo'), ('IntranetAddMastheadLibraryPulldown','0', NULL, 'Add a library select pulldown menu on the staff header search','YesNo'), -('IntranetAutocompleteElasticSearch','0',NULL,'If ON, show search suggestions in the staff interface when using Elasticsearch.','YesNo'), +('StaffInterfaceAutocompleteElasticsearch','0',NULL,'If ON, show search suggestions in the staff interface when using Elasticsearch.','YesNo'), ('IntranetBiblioDefaultView','normal','normal|marc|isbd|labeled_marc','Choose the default detail view in the staff interface; choose between normal, labeled_marc, marc or isbd','Choice'), ('intranetbookbag','1','','If ON, enables display of Cart feature in the intranet','YesNo'), ('IntranetCatalogSearchPulldown','0', NULL, 'Show a search field pulldown for \"Search the catalog\" boxes','YesNo'), @@ -485,7 +485,7 @@ INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, ` ('OPACAmazonCoverImages','0','','Display cover images on OPAC from Amazon Web Services','YesNo'), ('OPACAuthorIdentifiersAndInformation', '', '', 'Display author information on the OPAC detail page','multiple_sortable'), ('OpacAuthorities','1',NULL,'If ON, enables the search authorities link on OPAC','YesNo'), -('OPACAutocompleteElasticSearch','0',NULL,'If ON, show search suggestions in the OPAC when using Elasticsearch.','YesNo'), +('OPACAutocompleteElasticsearch','0',NULL,'If ON, show search suggestions in the OPAC when using Elasticsearch.','YesNo'), ('OPACBaseURL','',NULL,'Specify the Base URL of the OPAC, e.g., http://opac.mylibrary.com, including the protocol (http:// or https://). Otherwise, the http:// will be added automatically by Koha upon saving.','Free'), ('opacbookbag','1','','If ON, enables display of Cart feature','YesNo'), ('OpacBrowser','0',NULL,'If ON, enables subject authorities browser on OPAC (needs to set misc/cronjob/sbuild_browser_and_cloud.pl)','YesNo'), diff --git a/koha-tmpl/intranet-tmpl/js/elasticsearch/autocomplete.js b/koha-tmpl/intranet-tmpl/js/elasticsearch/autocomplete.js index ae89321796e..f503befc4e4 100644 --- a/koha-tmpl/intranet-tmpl/js/elasticsearch/autocomplete.js +++ b/koha-tmpl/intranet-tmpl/js/elasticsearch/autocomplete.js @@ -158,7 +158,7 @@ function autocomplete(inp, nb, left, right) { for (j = 0; j < tmp_data[i]['highlight'][pref[k] + '.' + key].length; j++){ /* div with data for autocomplete */ let tmp = tmp_data[i]['highlight'][pref[k] + '.' + key][j] - myset.add(tmp.replace(/[ &#,+()$~%.'":*?<{}!/;]+$/g, '')); + myset.add(tmp.replace(/[ &#,+($~%.:*?<{!/;]+$/g, '')); if (myset.size >= nb_autocomplete) break; }; if (myset.size >= nb_autocomplete) break; diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/js_includes.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/js_includes.inc index df31beabac5..09295515505 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/includes/js_includes.inc +++ b/koha-tmpl/intranet-tmpl/prog/en/includes/js_includes.inc @@ -98,8 +98,8 @@ [% IF Koha.Preference( 'CookieConsent' ) %] [% Asset.js("js/cookieconsent.js") | $raw %] [% END %] - -[% IF ( Koha.Preference('IntranetAutocompleteElasticSearch') ) %] + +[% IF ( Koha.Preference('StaffInterfaceAutocompleteElasticsearch') ) %] [% Asset.js("js/elasticsearch/autocomplete.js") | $raw %] [% 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 877ba5ac3d3..8733ff4520c 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 @@ -393,7 +393,7 @@ Searching: class: url - "Please only change this if you are sure it needs changing." - - - pref: OPACAutocompleteElasticSearch + - pref: OPACAutocompleteElasticsearch type: boolean default: 0 choices: @@ -401,7 +401,7 @@ Searching: 0: "Don't show" - search suggestions in the OPAC when using Elasticsearch. - - - pref: IntranetAutocompleteElasticSearch + - pref: StaffInterfaceAutocompleteElasticsearch type: boolean default: 0 choices: diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/advsearch.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/advsearch.tt index 64e81fb9242..bcd369b4e66 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/advsearch.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/advsearch.tt @@ -393,8 +393,8 @@ var dad = line.parentNode; dad.appendChild(line.cloneNode(true)); line.removeChild(ButtonPlus); - /* Intranet JS IntranetAutocompleteElasticSearch */ - [% IF ( Koha.Preference('IntranetAutocompleteElasticSearch') ) %] + /* Intranet JS StaffInterfaceAutocompleteElasticsearch */ + [% IF ( Koha.Preference('StaffInterfaceAutocompleteElasticsearch') ) %] AutocompleteInitIntranet(); [% END %] } diff --git a/koha-tmpl/opac-tmpl/bootstrap/css/src/opac.scss b/koha-tmpl/opac-tmpl/bootstrap/css/src/opac.scss index 9f0f0e1d95e..d92c7b47527 100644 --- a/koha-tmpl/opac-tmpl/bootstrap/css/src/opac.scss +++ b/koha-tmpl/opac-tmpl/bootstrap/css/src/opac.scss @@ -3013,12 +3013,12 @@ fieldset.brief label.show-password-toggle-label { &:hover { /*when hovering an item:*/ - background-color: #e9e9e9; + background-color: lighten( $dropdown-dark-color, 20 ); } &.autocomplete-active { /*when navigating through the items using the arrow keys:*/ - background-color: lighten( $input-btn-focus-color, 45% ); + background-color: lighten( $dropdown-dark-color, 20 ); } } } diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/includes/opac-bottom.inc b/koha-tmpl/opac-tmpl/bootstrap/en/includes/opac-bottom.inc index 9c54b345869..54b3ee1b530 100644 --- a/koha-tmpl/opac-tmpl/bootstrap/en/includes/opac-bottom.inc +++ b/koha-tmpl/opac-tmpl/bootstrap/en/includes/opac-bottom.inc @@ -192,8 +192,8 @@ [% INCLUDE 'js-date-format.inc' %] [% INCLUDE 'js-biblio-format.inc' %] [% PROCESS jsinclude %] - -[% IF ( Koha.Preference('OPACAutocompleteElasticSearch') ) %] + +[% IF ( Koha.Preference('OPACAutocompleteElasticsearch') ) %] [% Asset.js("js/opac-elasticsearch/opac-autocomplete.js") | $raw %] [% END %] [% IF ( Koha.Preference('OPACUserJS') ) %] diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-advsearch.tt b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-advsearch.tt index 3219e350246..e2ad519a08c 100644 --- a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-advsearch.tt +++ b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-advsearch.tt @@ -612,8 +612,8 @@ $(newLine).find('.search-term-input select[name="op"]').first().prop("disabled",false).show(); newLine.find('input').val(''); thisLine.after(newLine); - /* OPAC JS OPACAutocompleteElasticSearch */ - [% IF ( Koha.Preference('OPACAutocompleteElasticSearch') ) %] + /* OPAC JS OPACAutocompleteElasticsearch */ + [% IF ( Koha.Preference('OPACAutocompleteElasticsearch') ) %] AutocompleteInitOpac(); [% END %] }); @@ -625,8 +625,8 @@ } $(this).parent().parent().remove(); $('.search-term-row .search-term-input select[name="op"]').first().prop("disabled",true).hide(); - /* OPAC JS OPACAutocompleteElasticSearch */ - [% IF ( Koha.Preference('OPACAutocompleteElasticSearch') ) %] + /* OPAC JS OPACAutocompleteElasticsearch */ + [% IF ( Koha.Preference('OPACAutocompleteElasticsearch') ) %] AutocompleteInitOpac(); [% END %] }); -- 2.34.1