From 4d3242163451c429569e1236bc5a32c3b704bd96 Mon Sep 17 00:00:00 2001 From: Kyle M Hall Date: Tue, 9 Jul 2013 12:30:58 -0400 Subject: [PATCH] Bug 10558 - Convert records table in manage-marc-import.pl to Ajax DataTable Some libraries would like to sort by columns for the records of an import batch. This seems like a good use of Ajax DataTables. Test plan: 1) Apply this patch 2) Import a record batch into Koha a) Use some form of matching b) Have some records that will match and some that won't c) Have at least 30 records so you can test the pager 3) Verify the new table is functionally equivalent to the old static one Signed-off-by: Owen Leonard Tests fine and looks good with the exception of the corrections I put in a follow-up. Signed-off-by: Galen Charlton --- C4/ImportBatch.pm | 11 +- .../en/modules/tools/manage-marc-import.tt | 189 ++++++++---------- tools/batch_records_ajax.pl | 112 +++++++++++ tools/manage-marc-import.pl | 98 ++++----- 4 files changed, 249 insertions(+), 161 deletions(-) create mode 100755 tools/batch_records_ajax.pl diff --git a/C4/ImportBatch.pm b/C4/ImportBatch.pm index c045878227..f320c7a0b4 100644 --- a/C4/ImportBatch.pm +++ b/C4/ImportBatch.pm @@ -1028,9 +1028,15 @@ starting at the given offset. =cut sub GetImportRecordsRange { - my ($batch_id, $offset, $results_per_group, $status) = @_; + my ( $batch_id, $offset, $results_per_group, $status, $parameters ) = @_; my $dbh = C4::Context->dbh; + + my $order_by = + $dbh->quote_identifier( $parameters->{order_by} || 'import_record_id' ); + my $order_by_direction = + uc( $parameters->{order_by_direction} ) eq 'DESC' ? 'DESC' : 'ASC'; + my $query = "SELECT title, author, isbn, issn, authorized_heading, import_records.import_record_id, record_sequence, status, overlay_status, matched_biblionumber, matched_authid, record_type @@ -1044,7 +1050,8 @@ sub GetImportRecordsRange { $query .= " AND status=?"; push(@params,$status); } - $query.=" ORDER BY import_record_id"; + + $query.=" ORDER BY $order_by $order_by_direction"; if($results_per_group){ $query .= " LIMIT ?"; 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 e8384c12cc..c19a05bdc5 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 @@ -1,38 +1,16 @@ -[% BLOCK final_match_link %] - [% IF ( record.record_type == 'biblio' ) %] - [% record.final_match_id %] - [% ELSIF ( record.record_type == 'auth' ) %] - [% record.final_match_id %] - [% END %] -[% END %] -[% BLOCK match_link %] - [% IF ( record_lis.match_id ) %] - - - [% IF ( record.record_type == 'biblio' ) %] - Matches biblio [% record_lis.match_id %] (score = [% record_lis.match_score %]): [% record_lis.match_citation %] - [% ELSIF ( record.record_type == 'auth' ) %] - Matches authority [% record_lis.match_id %] (score = [% record_lis.match_score %]): [% record_lis.match_citation %] | - Merge - - [% END %] - - [% ELSIF ( record.record_type == 'auth') %] - - - Search for a record to merge in a new window - - [% END %] -[% END %] [% INCLUDE 'doc-head-open.inc' %] Koha › Tools › Manage staged MARC records [% IF ( import_batch_id ) %] › Batch [% import_batch_id %] [% END %] -[% INCLUDE 'greybox.inc' %] [% INCLUDE 'doc-head-close.inc' %] + + + +[% INCLUDE 'datatables-strings.inc' %] +