From 3c2dad9e55ec149e2e044ea1b040de07819cec72 Mon Sep 17 00:00:00 2001
From: Kyle M Hall <kyle@bywatersolutions.com>
Date: Tue, 16 Jul 2013 08:32:55 -0400
Subject: [PATCH] Bug 10558 [QA Follow-up] Convert records table in manage-marc-import.pl to ajax DataTable

---
 .../prog/en/modules/tools/manage-marc-import.tt    |   31 ++++++------
 tools/batch_records_ajax.pl                        |    4 +-
 tools/manage-marc-import.pl                        |   53 ++------------------
 3 files changed, 23 insertions(+), 65 deletions(-)

diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/manage-marc-import.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/tools/manage-marc-import.tt
index 08d90b5..37924da 100644
--- a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/manage-marc-import.tt
+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/tools/manage-marc-import.tt
@@ -28,7 +28,7 @@ $(document).ready(function(){
   });
 
   $("#records-table").dataTable({
-      "aLengthMenu": [[10, 15, 20, 25, 50, 100], [10, 15, 20, 25, 50, 100]],
+      "aLengthMenu": [[10, 15, 20, 25, 50, 100, -1], [10, 15, 20, 25, 50, 100, _("All")]],
       "iDisplayLength" : 20,
       "bAutoWidth": false,
       "bFilter": false,
@@ -54,7 +54,7 @@ $(document).ready(function(){
       },
       "fnRowCallback": function( nRow, aData, iDisplayIndex, iDisplayIndexFull ) {
         $('td:eq(1)', nRow).html(
-            '<a href="javascript:void()" onclick="show_marc('
+            '<a href="javascript:void(0)" onclick="show_marc('
             + aData['import_record_id']
             + ')">' + aData['citation'] + '</a>'
         );
@@ -367,19 +367,20 @@ Page
   [% END %]
 [% END %]
 
-<table id="records-table">
-    <thead>
-        <tr>
-            <th>#</th>
-            <th>Citation</th>
-            <th>Status</th>
-            <th>Match type</th>
-            <th>Match details</th>
-            <th>Record</th>
-        </tr>
-    </thead>
-
-</table>
+[% IF import_batch_id %]
+    <table id="records-table">
+        <thead>
+            <tr>
+                <th>#</th>
+                <th>Citation</th>
+                <th>Status</th>
+                <th>Match type</th>
+                <th>Match details</th>
+                <th>Record</th>
+            </tr>
+        </thead>
+    </table>
+[% END %]
 
 </div>
 </div>
diff --git a/tools/batch_records_ajax.pl b/tools/batch_records_ajax.pl
index f4a1542..709e8bf 100755
--- a/tools/batch_records_ajax.pl
+++ b/tools/batch_records_ajax.pl
@@ -45,11 +45,13 @@ my $results_per_page  = $input->param('iDisplayLength');
 my $sorting_column    = $sort_columns[ $input->param('iSortCol_0') ];
 my $sorting_direction = $input->param('sSortDir_0');
 
+$results_per_page = undef if ( $results_per_page == -1 );
+
 binmode STDOUT, ":encoding(UTF-8)";
 print $input->header( -type => 'text/plain', -charset => 'UTF-8' );
 
 my ( $auth_status, $sessionID ) =
-  check_cookie_auth( $input->cookie('CGISESSID'), { editcatalogue => '*' } );
+  check_cookie_auth( $input->cookie('CGISESSID'), { tools => 'manage_staged_marc' } );
 if ( $auth_status ne "ok" ) {
     exit 0;
 }
diff --git a/tools/manage-marc-import.pl b/tools/manage-marc-import.pl
index 05f4021..9251ed5 100755
--- a/tools/manage-marc-import.pl
+++ b/tools/manage-marc-import.pl
@@ -351,65 +351,20 @@ sub import_records_list {
     my ($template, $import_batch_id, $offset, $results_per_page) = @_;
 
     my $batch = GetImportBatch($import_batch_id);
-#    my $records = GetImportRecordsRange($import_batch_id);
-#    my @list = ();
-#    foreach my $record (@$records) {
-#        my $citation = $record->{'title'} || $record->{'authorized_heading'};
-#        $citation .= " $record->{'author'}" if $record->{'author'};
-#        $citation .= " (" if $record->{'issn'} or $record->{'isbn'};
-#        $citation .= $record->{'isbn'} if $record->{'isbn'};
-#        $citation .= ", " if $record->{'issn'} and $record->{'isbn'};
-#        $citation .= $record->{'issn'} if $record->{'issn'};
-#        $citation .= ")" if $record->{'issn'} or $record->{'isbn'};
-#
-#        my $match = GetImportRecordMatches($record->{'import_record_id'}, 1);
-#        my $match_citation = '';
-#        my $match_id;
-#        if ($#$match > -1) {
-#            if ($match->[0]->{'record_type'} eq 'biblio') {
-#                $match_citation .= $match->[0]->{'title'} if defined($match->[0]->{'title'});
-#                $match_citation .= ' ' . $match->[0]->{'author'} if defined($match->[0]->{'author'});
-#                $match_id = $match->[0]->{'biblionumber'};
-#            } elsif ($match->[0]->{'record_type'} eq 'auth') {
-#                if (defined($match->[0]->{'authorized_heading'})) {
-#                    $match_citation .= $match->[0]->{'authorized_heading'};
-#                    $match_id = $match->[0]->{'candidate_match_id'};
-#                }
-#            }
-#        }
-#
-#        push @list,
-#          { import_record_id         => $record->{'import_record_id'},
-#            final_match_id           => $record->{'matched_biblionumber'} || $record->{'matched_authid'},
-#            citation                 => $citation,
-#            status                   => $record->{'status'},
-#            record_sequence          => $record->{'record_sequence'},
-#            overlay_status           => $record->{'overlay_status'},
-#            # Sorry about the match_id being from the "biblionumber" field;
-#            # as it turns out, any match id will go in biblionumber
-#            match_id                 => $match_id,
-#            match_citation           => $match_citation,
-#            match_score              => $#$match > -1 ? $match->[0]->{'score'} : 0,
-#            record_type              => $record->{'record_type'},
-#          };
-#    }
-#    my $num_records = $batch->{'num_records'};
-#    $template->param(record_list => \@list);
-#    add_page_numbers($template, $offset, $results_per_page, $num_records);
-#    $template->param(offset => $offset);
-#    $template->param(range_top => $offset + $results_per_page - 1);
-#    $template->param(num_results => $num_records);
-#    $template->param(results_per_page => $results_per_page);
     $template->param(import_batch_id => $import_batch_id);
+
     my $overlay_action = GetImportBatchOverlayAction($import_batch_id);
     $template->param("overlay_action_${overlay_action}" => 1);
     $template->param(overlay_action => $overlay_action);
+
     my $nomatch_action = GetImportBatchNoMatchAction($import_batch_id);
     $template->param("nomatch_action_${nomatch_action}" => 1);
     $template->param(nomatch_action => $nomatch_action);
+
     my $item_action = GetImportBatchItemAction($import_batch_id);
     $template->param("item_action_${item_action}" => 1);
     $template->param(item_action => $item_action);
+
     batch_info($template, $batch);
     
 }
-- 
1.7.2.5