From 5ee4b061134e180ec269ebd70390ba30e2cf0026 Mon Sep 17 00:00:00 2001
From: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
Date: Wed, 16 Nov 2022 07:53:42 +0100
Subject: [PATCH] Bug 32214: Prevent empty search option block in catalog
 search header

In the header, if "Search catalog" is selected, there is an "option"
icon to display some filters.
Fitlers are displayed if IntranetCatalogSearchPulldown or
IntranetAddMastheadLibraryPulldown is set. If none are set we should
hide the icon to avoid and empty div to be displayed

Test plan:
Confirm that the icon is only displayed if one of the 2 prefs is turned
on.

Signed-off-by: David Nind <david@davidnind.com>
---
 .../intranet-tmpl/prog/en/includes/catalogue-search-box.inc  | 5 ++++-
 koha-tmpl/intranet-tmpl/prog/js/staff-global.js              | 1 -
 2 files changed, 4 insertions(+), 2 deletions(-)

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 00823a1b70..ac15548243 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
@@ -1,3 +1,4 @@
+[% USE Koha %]
 [% USE Branches %]
 [% IF ( CAN_user_catalogue ) %]
     <div id="catalog_search" class="residentsearch">
@@ -13,7 +14,9 @@
                     <input type="text" name="q" id="search-form" size="20" title="Enter the terms you wish to search for." class="query form-text head-searchbox form-control" placeholder="Enter search keywords" />
                 [% END %]
 
-                <button type="button" class="form-extra-content-toggle"><i class="fa fa-sliders"></i></button>
+                [% IF Koha.Preference('IntranetCatalogSearchPulldown') || Koha.Preference('IntranetAddMastheadLibraryPulldown') %]
+                    <button type="button" class="form-extra-content-toggle"><i class="fa fa-sliders"></i></button>
+                [% END %]
             </span>
             <button type="submit"><i class="fa fa-arrow-right"></i></button>
 
diff --git a/koha-tmpl/intranet-tmpl/prog/js/staff-global.js b/koha-tmpl/intranet-tmpl/prog/js/staff-global.js
index 7d4d16826e..dd380236fc 100644
--- a/koha-tmpl/intranet-tmpl/prog/js/staff-global.js
+++ b/koha-tmpl/intranet-tmpl/prog/js/staff-global.js
@@ -71,7 +71,6 @@ $(document).ready(function() {
 
     $('#header_search .form-extra-content-toggle').on('click', function () {
         const extraContent = $(this).closest('form').find('.form-extra-content');
-        console.log(extraContent);
         if (extraContent.is(':visible')) {
             extraContent.hide();
         } else {
-- 
2.30.2