Bug 4198 - deleting an authority refreshes the page
authorKyle M Hall <kyle@bywatersolutions.com>
Thu, 5 Jul 2012 14:33:40 +0000 (10:33 -0400)
committerPaul Poulain <paul.poulain@biblibre.com>
Thu, 2 Aug 2012 13:43:08 +0000 (15:43 +0200)
Makes clicking a Delete link refresh the search that
was performed so that the results are still on the screen.

Signed-off-by: Frédéric Demians <f.demians@tamil.fr>
Works as advertised. Very usefull. Still the issue that indexing being
not in real time, the search result displays the just deleted authority.
But there is no way to do better.

authorities/authorities-home.pl
koha-tmpl/intranet-tmpl/prog/en/modules/authorities/searchresultlist.tt

index d687c78..fde4bf9 100755 (executable)
@@ -54,6 +54,21 @@ foreach my $thisauthtype ( sort { $authtypes->{$a}{'authtypetext'} cmp $authtype
     push @authtypesloop, \%row;
 }
 
+if ( $op eq "delete" ) {
+    ( $template, $loggedinuser, $cookie ) = get_template_and_user(
+        {
+            template_name   => "authorities/authorities-home.tmpl",
+            query           => $query,
+            type            => 'intranet',
+            authnotrequired => 0,
+            flagsrequired   => { catalogue => 1 },
+            debug           => 1,
+        }
+    );
+    &DelAuthority( $authid, 1 );
+
+    $op = "do_search";
+}
 if ( $op eq "do_search" ) {
     my @marclist  = $query->param('marclist');
     my @and_or    = $query->param('and_or');
@@ -69,7 +84,7 @@ if ( $op eq "do_search" ) {
       SearchAuthorities( \@marclist, \@and_or, \@excluding, \@operator, \@value,
         ( $startfrom - 1 ) * $resultsperpage,
         $resultsperpage, $authtypecode, $orderby );
-#     use Data::Dumper; warn Data::Dumper::Dumper(@$results);
+
     ( $template, $loggedinuser, $cookie ) = get_template_and_user(
         {
             template_name   => "authorities/searchresultlist.tmpl",
@@ -81,6 +96,18 @@ if ( $op eq "do_search" ) {
         }
     );
 
+    $template->param(
+        marclist       => $query->param('marclist'),
+        and_or         => $query->param('and_or'),
+        excluding      => $query->param('excluding'),
+        operator       => $query->param('operator'),
+        orderby        => $query->param('orderby'),
+        value          => $query->param('value'),
+        authtypecode   => $query->param('authtypecode'),
+        startfrom      => $startfrom,
+        resultsperpage => $resultsperpage,
+    );
+
     my @field_data = ();
 
     # we must get parameters once again. Because if there is a mainentry, it
@@ -146,20 +173,7 @@ if ( $op eq "do_search" ) {
     );
 
 }
-elsif ( $op eq "delete" ) {
-    ( $template, $loggedinuser, $cookie ) = get_template_and_user(
-        {
-            template_name   => "authorities/authorities-home.tmpl",
-            query           => $query,
-            type            => 'intranet',
-            authnotrequired => 0,
-            flagsrequired   => { catalogue => 1 },
-            debug           => 1,
-        }
-    );
-    &DelAuthority( $authid, 1 );
-}
-else {
+if ( $op eq '' ) {
     ( $template, $loggedinuser, $cookie ) = get_template_and_user(
         {
             template_name   => "authorities/authorities-home.tmpl",
index 038959f..6ac139a 100644 (file)
@@ -8,7 +8,9 @@ function confirm_deletion(id) {
     
     var is_confirmed = confirm('Are you sure you want to delete this authority?');
     if (is_confirmed) {
-        window.location="authorities-home.pl?op=delete&amp;authid="+id;
+      window.location="authorities-home.pl?op=delete&amp;authid="
+          + id
+          + "&amp;marclist=[% marclist %]&amp;and_or=[% and_or %]&amp;excluding=[% excluding %]&amp;operator=[%operator%]&amp;orderby=[% orderby %]&amp;value=[% value %]&amp;startfrom=[% startfrom %]&amp;resultsperpage=[% resultsperpage %]";
     }
 }
 function Help() {