Bugzilla – Attachment 19506 Details for
Bug 10558
Convert records table in manage-marc-import.pl to ajax DataTable
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
WIP - Bug 10558 - Convert records table in manage-marc-import.pl to ajax DataTable
WIP---Bug-10558---Convert-records-table-in-manage-.patch (text/plain), 11.97 KB, created by
Kyle M Hall (khall)
on 2013-07-09 16:31:23 UTC
(
hide
)
Description:
WIP - Bug 10558 - Convert records table in manage-marc-import.pl to ajax DataTable
Filename:
MIME Type:
Creator:
Kyle M Hall (khall)
Created:
2013-07-09 16:31:23 UTC
Size:
11.97 KB
patch
obsolete
>From 895e7f0d41b67d01776c18b906705e1101532b9b Mon Sep 17 00:00:00 2001 >From: Kyle M Hall <kyle@bywatersolutions.com> >Date: Tue, 9 Jul 2013 12:30:58 -0400 >Subject: [PATCH] WIP - Bug 10558 - Convert records table in manage-marc-import.pl to ajax DataTable > >--- > C4/ImportBatch.pm | 7 +- > .../prog/en/modules/tools/manage-marc-import.tt | 98 ++++++---------- > tools/batch_records_ajax.pl | 122 ++++++++++++++++++++ > tools/manage-marc-import.pl | 2 +- > 4 files changed, 162 insertions(+), 67 deletions(-) > create mode 100755 tools/batch_records_ajax.pl > >diff --git a/C4/ImportBatch.pm b/C4/ImportBatch.pm >index 3ce5c67..7279b26 100644 >--- a/C4/ImportBatch.pm >+++ b/C4/ImportBatch.pm >@@ -990,7 +990,10 @@ 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 $order_by = $parameters->{order_by} || 'import_record_id'; >+ my $order_by_direction = $parameters->{order_by_direction} || 'ASC'; > > my $dbh = C4::Context->dbh; > my $query = "SELECT title, author, isbn, issn, authorized_heading, import_records.import_record_id, >@@ -1006,7 +1009,7 @@ 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 5b0e3a2..e8bb347 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,22 +1,3 @@ >-[% BLOCK final_match_link %] >- [% IF ( record.record_type == 'biblio' ) %] >- <a target="_blank" href="/cgi-bin/koha/catalogue/detail.pl?biblionumber=[% record.final_match_id %]">[% record.final_match_id %]</a> >- [% ELSIF ( record.record_type == 'auth' ) %] >- <a href="/cgi-bin/koha/authorities/detail.pl?authid=[% record.final_match_id %]">[% record.final_match_id %]</a> >- [% END %] >-[% END %] >-[% BLOCK match_link %] >- [% IF ( record_lis.match_id ) %] >- <tr> >- <td /> >- [% IF ( record.record_type == 'biblio' ) %] >- <td class="highlight" colspan="4">Matches biblio [% record_lis.match_id %] (score = [% record_lis.match_score %]): <a href="/cgi-bin/koha/catalogue/detail.pl?biblionumber=[% record_lis.match_id %]">[% record_lis.match_citation %]</a></td> >- [% ELSIF ( record.record_type == 'auth' ) %] >- <td class="highlight" colspan="4">Matches authority [% record_lis.match_id %] (score = [% record_lis.match_score %]): <a href="/cgi-bin/koha/authorities/detail.pl?authid=[% record_lis.match_id %]">[% record_lis.match_citation %]</a></td> >- [% END %] >- </tr> >- [% END %] >-[% END %] > [% INCLUDE 'doc-head-open.inc' %] > <title>Koha › Tools › Manage staged MARC records > [% IF ( import_batch_id ) %] >@@ -26,6 +7,11 @@ > [% INCLUDE 'greybox.inc' %] > [% INCLUDE 'doc-head-close.inc' %] > <script type="text/javascript" src="[% themelang %]/js/background-job-progressbar.js"></script> >+<link rel="stylesheet" type="text/css" href="[% themelang %]/css/datatables.css" /> >+<script type="text/javascript" src="[% themelang %]/lib/jquery/plugins/jquery.dataTables.min.js"></script> >+<script type="text/javascript" src="[% themelang %]/lib/jquery/plugins/jquery.dataTables.columnFilter.js"></script> >+[% INCLUDE 'datatables-strings.inc' %] >+<script type="text/javascript" src="[% themelang %]/js/datatables.js"></script> > <script type="text/JavaScript" language="JavaScript"> > //<![CDATA[ > var MSG_CONFIRM_CLEAN = _("Clear all reservoir records staged in this batch? This cannot be undone."); >@@ -41,6 +27,24 @@ $(document).ready(function(){ > $("#"+str+" option[selected='selected']").attr("selected","selected"); > $(this).parent().hide(); > }); >+ >+ $("#records-table").dataTable({ >+ "bProcessing": true, >+ "bServerSide": true, >+ "sAjaxSource": 'batch_records_ajax.pl', >+ "sPaginationType": "full_numbers", >+ "fnServerData": function ( sSource, aoData, fnCallback ) { >+ aoData.push( { "name": "import_batch_id", "value": [% import_batch_id %] } ); >+ >+ $.getJSON( sSource, aoData, function (json) { >+ fnCallback(json) >+ } ); >+ }, >+ "fnRowCallback": function( nRow, aData, iDisplayIndex, iDisplayIndexFull ) { >+ $('td:eq(1)', nRow).html( '<a rel="gb_page_center[600,500]" href="/cgi-bin/koha/catalogue/showmarc.pl?importid=' + aData[0] + '">' + aData[1] + '</a>' ); >+ $('td:eq(5)', nRow).html( '<a target="_blank" href="http://staff.kohadev/cgi-bin/koha/catalogue/detail.pl?biblionumber=' + aData[5] + '">' + aData[5] + '</a>' ); >+ }, >+ }); > }); > //]]> > </script> >@@ -317,53 +321,19 @@ Page > [% END %] > > [% IF ( record_list ) %] >- [% IF ( pages ) %] >-<div class="pages"> >-Page >- [% FOREACH page IN pages %] >- [% IF ( page.current_page ) %] >- <span class="current">[% page.page_number %]</span> >- [% ELSE %] >- <a class="nav" href="[% page.script_name %]?import_batch_id=[% import_batch_id %]&offset=[% page.offset %]">[% page.page_number %]</a> >- [% END %] >- [% END %] >-</div> >- [% END %] >-<table> >- <tr> >- <th>#</th> >- <th>Citation</th> >- <th>Status</th> >- <th>Match?</th> >- <th>Record</th> >+<table id="records-table"> >+ <thead> >+ <tr> >+ <th>#</th> >+ <th>Citation</th> >+ <th>Status</th> >+ <th>Match?</th> >+ <th> </th> >+ <th>Record</th> >+ </tr> >+ </thead> > >- </tr> >- [% FOREACH record_lis IN record_list %] >- [% UNLESS ( loop.odd ) %]<tr class="highlight">[% ELSE %]<tr>[% END %] >- <td>[% record_lis.record_sequence %]</td> >- <td><a href="/cgi-bin/koha/catalogue/showmarc.pl?importid=[% record_lis.import_record_id %]" rel="gb_page_center[600,500]">[% record_lis.citation %]</a></td> >- <td>[% record_lis.status %]</td> >- <td>[% record_lis.overlay_status %]</td> >- <td>[% IF ( record_lis.final_match_id ) %] >- [% PROCESS final_match_link record=record_lis %] >- [% END %] >- </td> >- </tr> >- [% PROCESS match_link record=record_lis %] >- [% END %] > </table> >- [% IF ( pages ) %] >-<div class="pages"> >-Page >- [% FOREACH page IN pages %] >- [% IF ( page.current_page ) %] >- <span class="current">[% page.page_number %]</span> >- [% ELSE %] >- <a class="nav" href="[% page.script_name %]?import_batch_id=[% import_batch_id %]&offset=[% page.offset %]">[% page.page_number %]</a> >- [% END %] >- [% END %] >-</div> >- [% END %] > [% ELSE %] > [% IF ( batch_info ) %] > <div class="dialog alert">There are no records in this batch to import. >diff --git a/tools/batch_records_ajax.pl b/tools/batch_records_ajax.pl >new file mode 100755 >index 0000000..589a6ff >--- /dev/null >+++ b/tools/batch_records_ajax.pl >@@ -0,0 +1,122 @@ >+#!/usr/bin/perl >+ >+# This software is placed under the gnu General Public License, v2 (http://www.gnu.org/licenses/gpl.html) >+ >+# Copyright 2007 Tamil s.a.r.l. >+# >+# This file is part of Koha. >+# >+# Koha is free software; you can redistribute it and/or modify it under the >+# terms of the GNU General Public License as published by the Free Software >+# Foundation; either version 2 of the License, or (at your option) any later >+# version. >+# >+# Koha is distributed in the hope that it will be useful, but WITHOUT ANY >+# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR >+# A PARTICULAR PURPOSE. See the GNU General Public License for more details. >+# >+# You should have received a copy of the GNU General Public License along >+# with Koha; if not, write to the Free Software Foundation, Inc., >+# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. >+ >+=head1 ysearch.pl >+ >+ >+=cut >+ >+use Modern::Perl; >+ >+use CGI; >+use JSON qw/ to_json /; >+ >+use C4::Context; >+use C4::Charset; >+use C4::Auth qw/check_cookie_auth/; >+use C4::ImportBatch; >+ >+my $input = new CGI; >+ >+use Log::Trivial; >+my $logger = Log::Trivial->new( log_file => "/tmp/file.log" ); >+ >+my @sort_columns = qw/import_record_id title status overlay_status overlay_status/; >+ >+my $import_batch_id = $input->param('import_batch_id'); >+my $offset = $input->param('iDisplayStart'); >+my $results_per_page = $input->param('iDisplayLength'); >+my $sorting_column = $sort_columns[ $input->param('iSortCol_0') ]; >+my $sorting_direction = $input->param('sSortDir_0'); >+ >+$logger->write( >+ comment => " >+ import_batch_id => $import_batch_id >+ offset => $offset >+ results_per_page => $results_per_page >+ sorting_column => $sorting_column >+ sorting_direction => $sorting_direction >+" >+); >+ >+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 => '*' } ); >+if ( $auth_status ne "ok" ) { >+ exit 0; >+} >+ >+my $batch = GetImportBatch($import_batch_id); >+my $records = >+ GetImportRecordsRange( $import_batch_id, $offset, $results_per_page, undef, { order_by => $sorting_column, order_by_direction => $sorting_direction } ); >+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, >+ { >+ DT_RowId => $record->{'import_record_id'}, >+ 0 => $record->{'import_record_id'}, >+ 1 => $citation, >+ 2 => $record->{'status'}, >+ 3 => $record->{'overlay_status'}, >+ 4 => 'match data', >+ 5 => $record->{'matched_biblionumber'} >+ || $record->{'matched_authid'} >+ || q{}, >+ }; >+} >+ >+my $data; >+$data->{'iTotalRecords'} = $batch->{'num_records'}; >+$data->{'iTotalDisplayRecords'} = @list; >+$data->{'sEcho'} = $input->param('sEcho') || undef; >+$data->{'aaData'} = \@list; >+ >+$logger->write( comment => Data::Dumper::Dumper($data) ); >+ >+print to_json($data); >diff --git a/tools/manage-marc-import.pl b/tools/manage-marc-import.pl >index 25f7769..9bd6d08 100755 >--- a/tools/manage-marc-import.pl >+++ b/tools/manage-marc-import.pl >@@ -352,7 +352,7 @@ 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, $offset, $results_per_page); >+ my $records = GetImportRecordsRange($import_batch_id); > my @list = (); > foreach my $record (@$records) { > my $citation = $record->{'title'} || $record->{'authorized_heading'}; >-- >1.7.2.5
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 10558
:
19506
|
19507
|
19515
|
19516
|
19517
|
19520
|
19525
|
19526
|
19547
|
19674
|
19675
|
19681
|
19682
|
19692
|
20183
|
20184
|
20185
|
20328
|
20345
|
20395
|
22062
|
22063
|
22064
|
22065
|
22066
|
22067
|
22068
|
23993
|
23994
|
23995
|
25936
|
25937