Bugzilla – Attachment 112971 Details for
Bug 23475
Search context is lost when simple search leads to a single record
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 23475: Use localStorage to preserve simple search values
Bug-23475-Use-localStorage-to-preserve-simple-sear.patch (text/plain), 4.92 KB, created by
David Nind
on 2020-11-04 02:07:05 UTC
(
hide
)
Description:
Bug 23475: Use localStorage to preserve simple search values
Filename:
MIME Type:
Creator:
David Nind
Created:
2020-11-04 02:07:05 UTC
Size:
4.92 KB
patch
obsolete
>From b00ff4a841de7dcf847a2ded1f685d9c41e29340 Mon Sep 17 00:00:00 2001 >From: Nick Clemens <nick@bywatersolutions.com> >Date: Mon, 19 Aug 2019 19:38:52 +0000 >Subject: [PATCH] Bug 23475: Use localStorage 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: David Nind <david@davidnind.com> >--- > catalogue/detail.pl | 3 +++ > catalogue/search.pl | 8 ++++---- > koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/detail.tt | 7 +++++++ > koha-tmpl/intranet-tmpl/prog/js/staff-global.js | 7 +++++++ > 4 files changed, 21 insertions(+), 4 deletions(-) > >diff --git a/catalogue/detail.pl b/catalogue/detail.pl >index 7b7f4d2944..893ea41fc0 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; >@@ -51,6 +52,8 @@ use Koha::Virtualshelves; > use Koha::Plugins; > use Koha::SearchEngine::Search; > >+use URI::Escape; >+ > my $query = CGI->new(); > > my $analyze = $query->param('analyze'); >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/en/modules/catalogue/detail.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/detail.tt >index 296b2eed4b..c97425f81b 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/detail.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/detail.tt >@@ -1305,6 +1305,13 @@ Note that permanent location is a code, and location may be an authval. > })); > [% END %] > }); >+ >+ $(document).ready(function() { >+ var search_index = localStorage.getItem("cat_search_pulldown_selection"); >+ var search_value = localStorage.getItem("searchbox_value"); >+ if ( search_index ){ $('.advsearch[name="idx"]').val(search_index)}; >+ if ( search_value ){ $('#search-form').val(search_value)}; >+ }); > </script> > [% END %] > [% INCLUDE 'intranet-bottom.inc' %] >diff --git a/koha-tmpl/intranet-tmpl/prog/js/staff-global.js b/koha-tmpl/intranet-tmpl/prog/js/staff-global.js >index 29ba0d9805..aea46051b9 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 >+ localStorage.setItem('cat_search_pulldown_selection', $("#cat-search-block select.advsearch").val() ); >+ localStorage.setItem('searchbox_value', $("#cat-search-block #search-form").val() ); >+} >-- >2.11.0
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 23475
:
92357
|
93558
|
93562
|
108124
|
109624
|
111325
|
111338
|
111339
|
111340
|
111798
|
111799
|
111800
|
112697
|
112714
|
112971
|
113744
|
113784
|
113904
|
114055
|
114056