From 420166db8c82c53ca1582dc4588ee041a50933e0 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 equivilent 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. --- C4/ImportBatch.pm | 11 +- .../prog/en/modules/tools/manage-marc-import.tt | 179 +++++++++----------- tools/batch_records_ajax.pl | 112 ++++++++++++ tools/manage-marc-import.pl | 98 ++++++------ 4 files changed, 251 insertions(+), 149 deletions(-) create mode 100755 tools/batch_records_ajax.pl diff --git a/C4/ImportBatch.pm b/C4/ImportBatch.pm index 3ce5c67..97498ed 100644 --- a/C4/ImportBatch.pm +++ b/C4/ImportBatch.pm @@ -990,9 +990,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 @@ -1006,7 +1012,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 789b02a..04dabf2 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,31 +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 %] - [% END %] - - [% 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' %] +