From 2bb09975bc5efc336e77b04e5f5f791aad3d6f76 Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Tue, 4 Aug 2020 14:36:38 +0200 Subject: [PATCH] Bug 5428: Jump back to the search result after deleting a record This patch adds the ability to jump back to the search result after a record has been deleted. Also it keeps the "browser" when all items are deleted from a bibliographic record Test plan: - Start a new search - Select a record with items - Delete all the items => You still see the browser - Delete the record => You are back to the adv search form but we new link "Go back to the results" is present at the top of the page Limitation: As we delete the record we do not longer know the offset, we are back to the first page of the result list Signed-off-by: Martin Renvoize Signed-off-by: Nick Clemens Signed-off-by: Jonathan Druart --- catalogue/search.pl | 4 ++-- cataloguing/addbiblio.pl | 2 +- koha-tmpl/intranet-tmpl/js/browser.js | 10 ++++++++++ .../prog/en/modules/catalogue/advsearch.tt | 10 ++++++++++ .../intranet-tmpl/prog/en/modules/catalogue/detail.tt | 1 + koha-tmpl/intranet-tmpl/prog/js/catalog.js | 4 ++-- 6 files changed, 26 insertions(+), 5 deletions(-) diff --git a/catalogue/search.pl b/catalogue/search.pl index 1fd012d8df..6876499fc8 100755 --- a/catalogue/search.pl +++ b/catalogue/search.pl @@ -241,6 +241,8 @@ my $types = C4::Context->preference("AdvancedSearchTypes") || "itemtypes"; my $advancedsearchesloop = prepare_adv_search_types($types); $template->param(advancedsearchesloop => $advancedsearchesloop); +$template->param( searchid => scalar $cgi->param('searchid'), ); + # The following should only be loaded if we're bringing up the advanced search template if ( $template_type eq 'advsearch' ) { @@ -691,8 +693,6 @@ for (my $i=0;$i<@servers;$i++) { } #/end of the for loop #$template->param(FEDERATED_RESULTS => \@results_array); -$template->{'VARS'}->{'searchid'} = $cgi->param('searchid'); - my $gotonumber = $cgi->param('gotoNumber'); if ( $gotonumber && ( $gotonumber eq 'last' || $gotonumber eq 'first' ) ) { $template->{'VARS'}->{'gotoNumber'} = $gotonumber; diff --git a/cataloguing/addbiblio.pl b/cataloguing/addbiblio.pl index 4bbf81df9a..4895564216 100755 --- a/cataloguing/addbiblio.pl +++ b/cataloguing/addbiblio.pl @@ -927,7 +927,7 @@ elsif ( $op eq "delete" ) { exit; } - print $input->redirect('/cgi-bin/koha/catalogue/search.pl'); + print $input->redirect('/cgi-bin/koha/catalogue/search.pl' . ($searchid ? "?searchid=$searchid" : "")); exit; } else { diff --git a/koha-tmpl/intranet-tmpl/js/browser.js b/koha-tmpl/intranet-tmpl/js/browser.js index 120d710a2c..66a15d1e70 100644 --- a/koha-tmpl/intranet-tmpl/js/browser.js +++ b/koha-tmpl/intranet-tmpl/js/browser.js @@ -109,5 +109,15 @@ KOHA.browser = function (searchid, biblionumber) { } }; + me.show_back_link = function () { + if (current_search) { + $(document).ready(function () { + var searchURL = '/cgi-bin/koha/catalogue/search.pl?' + decodeURIComponent(current_search.query) + '&limit=' + decodeURIComponent(current_search.limit) + '&sort_by=' + current_search.sort + '&searchid=' + me.searchid; + $('#previous_search_link').replaceWith('
'); + }); + } + }; + + return me; }; diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/advsearch.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/advsearch.tt index 9eb252d68b..8c555441e1 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/advsearch.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/advsearch.tt @@ -40,6 +40,9 @@

Advanced search

Go to item search + [% IF searchid %] +

+ [% END %]

@@ -296,6 +299,7 @@ [% MACRO jsinclude BLOCK %] [% Asset.js("lib/hc-sticky.js") | $raw %] + [% Asset.js("js/browser.js") | $raw %] [% END %] 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 dad9adeb4c..6bc8bcf49f 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/detail.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/detail.tt @@ -1219,6 +1219,7 @@ Note that permanent location is a code, and location may be an authval. [% Asset.js("js/browser.js") | $raw %] [% Asset.js("js/table_filters.js") | $raw %]