From 022330b8d26b81e53f9c4af7798fa42ff48bdaa3 Mon Sep 17 00:00:00 2001 From: Nick Clemens Date: Wed, 18 May 2022 15:08:39 +0000 Subject: [PATCH] Bug 27697: Only preopulate search when we have found a single biblio This patch uses the url parameter we created in 23475 to determine whether we should populate the search bar or not Note - a bookmark with this param will still populate search term with last search To test: 1 - Search staff client for 'cat' 2 - Browse to a patrons checkouts and click on a title, or just go directly to a details page: http://localhost:8081/cgi-bin/koha/catalogue/detail.pl?biblionumber=2850 3 - Search bar says 'cat' 4 - Apply patch 5 - Repeat 1-2 6 - Search bar is not populated 7 - Search "dalek war box set" or a term that finds a single record in your instance 8 - Search bar is populated 9 - Note url like: http://localhost:8081/cgi-bin/koha/catalogue/detail.pl?biblionumber=2850&found1=1 Signed-off-by: David Nind Signed-off-by: Jonathan Druart Signed-off-by: Tomas Cohen Arazi --- catalogue/detail.pl | 2 ++ .../prog/en/modules/catalogue/detail.tt | 14 ++++++++------ 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/catalogue/detail.pl b/catalogue/detail.pl index 29b6167f61..502963f8d6 100755 --- a/catalogue/detail.pl +++ b/catalogue/detail.pl @@ -619,6 +619,8 @@ if ( C4::Context->preference('UseCourseReserves') ) { $template->param( course_reserves => $course_reserves ); } +$template->param(found1 => $query->param('found1') ); + $template->param(biblio => $biblio); output_html_with_http_headers $query, $cookie, $template->output; 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 957882603a..1be6ee679a 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/detail.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/detail.tt @@ -1405,12 +1405,14 @@ 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 ){ $('#cat-search-block select.advsearch').val(search_index)}; - if ( search_value ){ $('#cat-search-block #search-form').val(search_value)}; - }); + [% IF (found1) %] + $(document).ready(function() { + var search_index = localStorage.getItem("cat_search_pulldown_selection"); + var search_value = localStorage.getItem("searchbox_value"); + if ( search_index ){ $('#cat-search-block select.advsearch').val(search_index)}; + if ( search_value ){ $('#cat-search-block #search-form').val(search_value)}; + }); + [% END %] [% END %] [% INCLUDE 'intranet-bottom.inc' %] -- 2.39.5