From 7e642371a815a66ad7931ac6048234bc28195dde Mon Sep 17 00:00:00 2001 From: Nick Clemens Date: Mon, 19 Aug 2019 19:38:52 +0000 Subject: [PATCH] Bug 23475: Use cookies to preserve simple search values To test: 1 - Enable IntranetCatalogSearchPulldown 2 - Perform a search that brings you to a single title 3 - Note the search is not displayed on the details page 4 - Apply patch 5 - Repeat 6 - Note the search is retained on details page 7 - Try with different dropdown values and search terms 8 - Test search terms including accented characters etc Signed-off-by: Sally Signed-off-by: Katrin Fischer --- catalogue/detail.pl | 11 +++++++++++ catalogue/search.pl | 8 ++++---- koha-tmpl/intranet-tmpl/prog/js/staff-global.js | 7 +++++++ 3 files changed, 22 insertions(+), 4 deletions(-) diff --git a/catalogue/detail.pl b/catalogue/detail.pl index 7b7f4d2944..d22bea4266 100755 --- a/catalogue/detail.pl +++ b/catalogue/detail.pl @@ -21,6 +21,7 @@ use Modern::Perl; use CGI qw ( -utf8 ); use HTML::Entities; use Try::Tiny; +use Encode qw( decode_utf8 ); use C4::Auth; use C4::Context; use C4::Koha; @@ -115,6 +116,16 @@ if ( not defined $record ) { eval { $biblio->metadata->record }; $template->param( decoding_error => $@ ); +if( $query->param('found1') ){ + if($query->cookie("pulldown_selection")){ + my $ms = "ms_". Encode::decode_utf8( uri_unescape( $query->cookie("pulldown_selection") ) ); + $template->param( $ms => 1); + } + if($query->cookie("searchbox_value")){ + $template->param( ms_value => Encode::decode_utf8( uri_unescape( $query->cookie("searchbox_value") ) ) ); + } +} + if($query->cookie("holdfor")){ my $holdfor_patron = Koha::Patrons->find( $query->cookie("holdfor") ); $template->param( diff --git a/catalogue/search.pl b/catalogue/search.pl index a5e0ecb408..d354a40eeb 100755 --- a/catalogue/search.pl +++ b/catalogue/search.pl @@ -557,13 +557,13 @@ for (my $i=0;$i<@servers;$i++) { my $defaultview = C4::Context->preference('IntranetBiblioDefaultView'); my $views = { C4::Search::enabled_staff_search_views }; if ($defaultview eq 'isbd' && $views->{can_view_ISBD}) { - print $cgi->redirect("/cgi-bin/koha/catalogue/ISBDdetail.pl?biblionumber=$biblionumber"); + print $cgi->redirect("/cgi-bin/koha/catalogue/ISBDdetail.pl?biblionumber=$biblionumber&found1=1"); } elsif ($defaultview eq 'marc' && $views->{can_view_MARC}) { - print $cgi->redirect("/cgi-bin/koha/catalogue/MARCdetail.pl?biblionumber=$biblionumber"); + print $cgi->redirect("/cgi-bin/koha/catalogue/MARCdetail.pl?biblionumber=$biblionumber&found1=1"); } elsif ($defaultview eq 'labeled_marc' && $views->{can_view_labeledMARC}) { - print $cgi->redirect("/cgi-bin/koha/catalogue/labeledMARCdetail.pl?biblionumber=$biblionumber"); + print $cgi->redirect("/cgi-bin/koha/catalogue/labeledMARCdetail.pl?biblionumber=$biblionumber&found1=1"); } else { - print $cgi->redirect("/cgi-bin/koha/catalogue/detail.pl?biblionumber=$biblionumber"); + print $cgi->redirect("/cgi-bin/koha/catalogue/detail.pl?biblionumber=$biblionumber&found1=1"); } exit; } diff --git a/koha-tmpl/intranet-tmpl/prog/js/staff-global.js b/koha-tmpl/intranet-tmpl/prog/js/staff-global.js index 29ba0d9805..a8b234178d 100644 --- a/koha-tmpl/intranet-tmpl/prog/js/staff-global.js +++ b/koha-tmpl/intranet-tmpl/prog/js/staff-global.js @@ -132,6 +132,7 @@ $.fn.selectTabByID = function (tabID) { /* forms with action leading to search */ $("form[action*='search.pl']").submit(function(){ resetSearchContext(); + saveOrClearSimpleSearchParams(); }); /* any link to launch a search except navigation links */ $("[href*='search.pl?']").not(".nav").not('.searchwithcontext').click(function(){ @@ -324,3 +325,9 @@ function getContextBiblioNumbers() { function resetSearchContext() { setContextBiblioNumbers( new Array() ); } + +function saveOrClearSimpleSearchParams() { + // Simple masthead search - pass value for display on details page + $.cookie('pulldown_selection', $("#cat-search-block select.advsearch").val() ); + $.cookie('searchbox_value', $("#cat-search-block #search-form").val() ); +} -- 2.11.0