From 67ffcf3d6a23e4785b0585191de15aa318d652ea Mon Sep 17 00:00:00 2001 From: Nick Clemens Date: Thu, 21 Jan 2021 14:23:35 +0000 Subject: [PATCH] Bug 27546: Add 'Search within results' search box This enhancement adds a new input above the search results allowing one to search within the results. The search box will take a query and add it as a limit to the previous search These patches make a slight change to the search header, passing the dropdown selection as a parameter rather thandirectly. Searching this way is functionally equivaled to adding 'AND' with the new term to original results. To test: 1 - Apply patch 2 - Search on staff client wiht a term that returns results 3 - Note the new 'Search within results box' 4 - Add a search term 5 - Note new results and confirm they are as expected 6 - Enable IntranetCatalogSearchPulldown and confirm the dropdown works as expected 7 - Edit your search - the reinfements appear in the limits section and can be removed Signed-off-by: Barbara Johnson Signed-off-by: Victor Grousset/tuxayo --- catalogue/search.pl | 2 +- .../prog/en/includes/catalogue-search-box.inc | 2 +- .../prog/en/modules/catalogue/results.tt | 17 +++++++++++++++++ 3 files changed, 19 insertions(+), 2 deletions(-) diff --git a/catalogue/search.pl b/catalogue/search.pl index ef7f49088f..e82e577f1a 100755 --- a/catalogue/search.pl +++ b/catalogue/search.pl @@ -369,7 +369,7 @@ if ($indexes[0] && (!$indexes[1] || $params->{'scan'})) { my $idx = "ms_".$indexes[0]; $idx =~ s/\,/comma/g; # template toolkit doesn't like variables with a , in it $idx =~ s/-/dash/g; # template toolkit doesn't like variables with a dash in it - $template->param($idx => 1); + $template->param(header_pulldown => $idx); } # an operand can be a single term, a phrase, or a complete ccl query 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..0bb0e63df6 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 @@ -3,7 +3,7 @@
[% IF ( Koha.Preference('IntranetCatalogSearchPulldown') ) %] - [% INCLUDE 'search_indexes.inc' %] + [% INCLUDE 'search_indexes.inc' $header_pulldown = 1 %] [% END %] 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 0251cbe792..070120fcc8 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/results.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/results.tt @@ -75,6 +75,16 @@ [% total | html %] result(s) found [% IF ( query_desc ) %]for '[% query_desc | html %]'[% END %][% IF limit_desc %] with limit(s): '[% limit_desc | html %]'[% END %][% IF ( LibraryName ) %] in [% LibraryName | html %] Catalog[% END %]. Edit this search +
+ + + [% IF ( Koha.Preference('IntranetCatalogSearchPulldown') ) %] + [% INCLUDE 'search_indexes.inc' ms_kw = 1 %] + [% END %] + + + +
@@ -740,6 +750,13 @@ first_biblionumber: "[% SEARCH_RESULTS.first.biblionumber | html %]", last_biblionumber: "[% SEARCH_RESULTS.last.biblionumber | html %]", } + + $("#refine_search").on('submit',function(e){ + e.preventDefault(); + var index = $("#refine_search #idx").val() || ""; + if( index){index += ":";} + window.location.href = "/cgi-bin/koha/catalogue/search.pl?[% query_cgi | $raw %]&[% limit_cgi | $raw %]&[% sort_cgi | $raw %]&limit="+index+$("#refiner").val(); + }); [% Asset.js("js/pages/results.js") | $raw %] [% END %] -- 2.30.2