Bug 5428: Jump back to the search result after deleting a record
authorJonathan Druart <jonathan.druart@bugs.koha-community.org>
Tue, 4 Aug 2020 12:36:38 +0000 (14:36 +0200)
committerJonathan Druart <jonathan.druart@bugs.koha-community.org>
Thu, 13 Aug 2020 05:55:45 +0000 (07:55 +0200)
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 <martin.renvoize@ptfs-europe.com>

Signed-off-by: Nick Clemens <nick@bywatersolutions.com>

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>

catalogue/search.pl
cataloguing/addbiblio.pl
koha-tmpl/intranet-tmpl/js/browser.js
koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/advsearch.tt
koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/detail.tt
koha-tmpl/intranet-tmpl/prog/js/catalog.js

index 1fd012d..6876499 100755 (executable)
@@ -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;
index 4bbf81d..4895564 100755 (executable)
@@ -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 {
index 120d710..66a15d1 100644 (file)
@@ -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('<div><div class="browse-label"><a href="' + searchURL + '"><i class="fa fa-list"></i> ' + __("Go back to the results") + '</a></div></div>');
+            });
+        }
+    };
+
+
     return me;
 };
index 9eb252d..8c55544 100644 (file)
@@ -40,6 +40,9 @@
 <h1>Advanced search</h1>
 <p>
   <a href="/cgi-bin/koha/catalogue/itemsearch.pl">Go to item search</a>
+  [% IF searchid %]
+      <div id="previous_search_link"></div>
+  [% END %]
 </p>
 
 <!-- SEARCH BUTTONS -->
 
 [% MACRO jsinclude BLOCK %]
     [% Asset.js("lib/hc-sticky.js") | $raw %]
+    [% Asset.js("js/browser.js") | $raw %]
     <script>
         /**
          *  Function add_field();
                     document.getElementById("categoryloop").disabled=false;
                 }
             });
+
+            [% IF searchid %]
+                browser = KOHA.browser('[% searchid | html %]');
+                browser.show_back_link();
+            [% END %]
+
         });
     </script>
 [% END %]
index dad9ade..6bc8bcf 100644 (file)
@@ -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 %]
     <script>
+        var searchid = '[% searchid | html %]';
         var browser;
         browser = KOHA.browser('[% searchid | html %]', parseInt(biblionumber, 10));
         browser.show();
index 8aeafc2..96adfbe 100644 (file)
@@ -44,7 +44,7 @@ function confirm_deletion(link) {
     }
     if (is_confirmed) {
         $("#deletebiblio").unbind('click');
-        window.location="/cgi-bin/koha/cataloguing/addbiblio.pl?op=delete&amp;biblionumber=" + biblionumber;
+        window.location="/cgi-bin/koha/cataloguing/addbiblio.pl?op=delete&amp;biblionumber=" + biblionumber + (searchid ? "&amp;searchid="+searchid : "");
     } else {
         return false;
     }
@@ -59,7 +59,7 @@ function confirm_items_deletion() {
         alert( MSG_DELETE_ALL_HOLDS.format(holdcount) );
     } else if ( count > 0 ) {
         if( confirm( CONFIRM_DELETE_ITEMS.format(count) ) ) {
-            window.location="/cgi-bin/koha/cataloguing/additem.pl?op=delallitems&amp;biblionumber=" + biblionumber;
+            window.location="/cgi-bin/koha/cataloguing/additem.pl?op=delallitems&amp;biblionumber=" + biblionumber + (searchid ? "&amp;searchid="+searchid : "");
         } else {
             return false;
         }