From 3cb9f925ec59c7348797bfc0d2ba538caa670b89 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 --- catalogue/search.pl | 2 +- koha-tmpl/intranet-tmpl/prog/en/includes/cat-search.inc | 2 +- .../intranet-tmpl/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 110bbbd07a..6a0259e9da 100755 --- a/catalogue/search.pl +++ b/catalogue/search.pl @@ -366,7 +366,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/cat-search.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/cat-search.inc index cdafcfe01f..c548cc63e1 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/includes/cat-search.inc +++ b/koha-tmpl/intranet-tmpl/prog/en/includes/cat-search.inc @@ -28,7 +28,7 @@
[% IF ( Koha.Preference('IntranetCatalogSearchPulldown') ) %] - [% INCLUDE 'search_indexes.inc' %] + [% INCLUDE 'search_indexes.inc' $header_pulldown = 1 %] [% ELSE %] [% 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 e7d6bc20e7..29d010b728 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/results.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/results.tt @@ -66,6 +66,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 %] + + + +
@@ -769,6 +779,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.11.0