From 31381e3e8cc8fb0b96bf07c225d431a073d891bf Mon Sep 17 00:00:00 2001 From: Jake Deery Date: Thu, 9 Oct 2025 10:45:30 +0100 Subject: [PATCH] Bug 41199: Add optional labels to search fields This patch adds the OPACShowLabelsForSearchInputs, which, when enabled, will add numerous additional labels to the OPAC's advanced search and masthead search regions. When disabled, this syspref will exhibit the same behaviour we see now. == TO TEST == a) visually look at the OPAC's mainpage, and advanced search page *) notice the input fields lack visual labels == APPLY PATCH == b) repeat step a) *) observe how nothing has visually changed c) set the OPACShowLabelsForSearchInputs syspref to Show d) repeat step a) again *) notice how there are now visual labels associated with each of the input fields e) revert the OPACShowLabelsForSearchInputs syspref to Don't show f) repeat step a) again *) notice how there are again no visual labels == SIGN OFF == --- .../bug_41199_add_labels_to_advsearch.pl | 17 +++++ installer/data/mysql/mandatory/sysprefs.sql | 1 + .../en/modules/admin/preferences/opac.pref | 8 +++ .../bootstrap/css/src/_responsive.scss | 6 -- .../opac-tmpl/bootstrap/css/src/opac.scss | 7 ++ .../bootstrap/en/includes/masthead.inc | 68 ++++++++++++------- .../bootstrap/en/modules/opac-advsearch.tt | 20 ++++-- 7 files changed, 92 insertions(+), 35 deletions(-) create mode 100755 installer/data/mysql/atomicupdate/bug_41199_add_labels_to_advsearch.pl diff --git a/installer/data/mysql/atomicupdate/bug_41199_add_labels_to_advsearch.pl b/installer/data/mysql/atomicupdate/bug_41199_add_labels_to_advsearch.pl new file mode 100755 index 00000000000..4d462b46f81 --- /dev/null +++ b/installer/data/mysql/atomicupdate/bug_41199_add_labels_to_advsearch.pl @@ -0,0 +1,17 @@ +use Modern::Perl; +use Koha::Installer::Output qw(say_warning say_success say_info); + +return { + bug_number => "41199", + description => "Add a way to enable/disable search input field labels", + up => sub { + my ($args) = @_; + my ( $dbh, $out ) = @$args{qw(dbh out)}; + + $dbh->do( + q{INSERT IGNORE INTO systempreferences (variable,value,options,explanation,type) VALUES ('OPACShowLabelsForSearchInputs','0',NULL,'If enabled, show labels beside each input field related to search inputs','YesNo')} + ); + + say_success( $out, "Added new system preference 'OPACShowLabelsForSearchInputs'" ); + }, +}; diff --git a/installer/data/mysql/mandatory/sysprefs.sql b/installer/data/mysql/mandatory/sysprefs.sql index b47f27df977..975251b572f 100644 --- a/installer/data/mysql/mandatory/sysprefs.sql +++ b/installer/data/mysql/mandatory/sysprefs.sql @@ -570,6 +570,7 @@ INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, ` ('OPACShibOnly','0','','If ON enables shibboleth only authentication for the opac','YesNo'), ('OPACShowCheckoutName','0','','Displays in the OPAC the name of patron who has checked out the material. WARNING: Most sites should leave this off. It is intended for corporate or special sites which need to track who has the item.','YesNo'), ('OPACShowHoldQueueDetails','none','none|priority|holds|holds_priority','Show holds details in OPAC','Choice'), +('OPACShowLabelsForSearchInputs', '0', NULL, 'If enabled, show labels beside each input field related to search inputs', 'YesNo'), ('OPACShowLibraries', '1', '', 'If enabled, a link is shown in the OPAC pointing to a page with library information', 'YesNo'), ('OPACShowMusicalInscripts','0','','Display musical inscripts on the OPAC record details page when available.','YesNo'), ('OPACShowOpenURL', '0', NULL, 'Enable display of OpenURL links in OPAC search results and detail page', 'YesNo'), diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/opac.pref b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/opac.pref index 37202dc17c6..3bbaebc3645 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/opac.pref +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/opac.pref @@ -42,6 +42,14 @@ OPAC: 0: Disable - "Koha OPAC as public. Private OPAC requires authentication before accessing the OPAC. " - 'Note: This does not affect the public API, see the RESTPublicAnonymousRequests to control the API.' + + - + - pref: OPACShowLabelsForSearchInputs + choices: + 1: "Show" + 0: "Don't show" + - "labels beside each of the search input fields." + - - pref: OPACShowLibraries choices: diff --git a/koha-tmpl/opac-tmpl/bootstrap/css/src/_responsive.scss b/koha-tmpl/opac-tmpl/bootstrap/css/src/_responsive.scss index 04a84b18938..819bae8c702 100644 --- a/koha-tmpl/opac-tmpl/bootstrap/css/src/_responsive.scss +++ b/koha-tmpl/opac-tmpl/bootstrap/css/src/_responsive.scss @@ -221,12 +221,6 @@ @media only screen and ( max-width: 700px ) { /* Screens below 700 pixels wide */ - #opac-main-search { - label { - display: none; - } - } - #logo { background: transparent url( "data:image/svg+xml," ) no-repeat; margin: 14px; diff --git a/koha-tmpl/opac-tmpl/bootstrap/css/src/opac.scss b/koha-tmpl/opac-tmpl/bootstrap/css/src/opac.scss index d407c017594..ff4dd181c40 100644 --- a/koha-tmpl/opac-tmpl/bootstrap/css/src/opac.scss +++ b/koha-tmpl/opac-tmpl/bootstrap/css/src/opac.scss @@ -222,6 +222,13 @@ th { #advsearches, #booleansearch { label { + color: #727272; + display: block; + font-size: 110%; + font-weight: bold; + } + + label[for^="search-field_"] { display: inline; } } diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/includes/masthead.inc b/koha-tmpl/opac-tmpl/bootstrap/en/includes/masthead.inc index c136dfeb29a..201e5c962ac 100644 --- a/koha-tmpl/opac-tmpl/bootstrap/en/includes/masthead.inc +++ b/koha-tmpl/opac-tmpl/bootstrap/en/includes/masthead.inc @@ -17,6 +17,7 @@ [% SET CookieConsentBar = AdditionalContents.get( location => "CookieConsentBar", lang => lang, library => branchcode || default_branch ) %] [% SET CookieConsentPopup = AdditionalContents.get( location => "CookieConsentPopup", lang => lang, library => branchcode || default_branch ) %] [% SET AllPublicBranches = Branches.all( search_params => { public => 1 }, selected => opac_name ) %] +[% SET ShowLabelsForSearchInputs = Koha.Preference('OPACShowLabelsForSearchInputs') %] @@ -235,54 +236,58 @@
- + [% IF ( ShowLabelsForSearchInputs ) %] + + [% ELSE %] + + [% END %] @@ -291,7 +296,11 @@
[% IF ( !Koha.Preference( 'OpacAddMastheadLibraryPulldown' ) == 1 && mylibraryfirst ) %] - + [% IF ( ShowLabelsForSearchInputs ) %] + + [% ELSE %] + + [% END %] [% ELSE %] - - + [% IF ( ShowLabelsForSearchInputs ) %] + + [% ELSE %] + + [% END %] + + [% END # /ms_value %]
[% IF ( Koha.Preference( 'OpacAddMastheadLibraryPulldown' ) == 1 && AllPublicBranches.size > 1 ) %]
- + [% IF ( ShowLabelsForSearchInputs ) %] + + [% ELSE %] + + [% END %] @@ -57,7 +58,10 @@
[% IF ( expanded_options ) %] - @@ -75,7 +79,10 @@
- [% IF ( expanded_options ) %] @@ -131,11 +138,15 @@
- + [% IF ( ShowLabelsForSearchInputs ) %] + + [% END %] +
[% IF ( expanded_options ) %]
+ @@ -546,7 +557,8 @@ $("#advsearches li:first a").tab("show"); } - $('.search-term-row .search-term-input select[name="op"]').first().prop("disabled",true).hide(); + $('.search-term-row .search-term-input label[for^="op_"]').first().prop("disabled",true).hide(); + $('.search-term-row .search-term-input select#op_0').prop("disabled",true).hide(); [% IF ( ReturnToSearch ) %] if (form_serialized = JSON.parse( Cookies.get("form_serialized") ) ) { -- 2.50.1 (Apple Git-155)