From 95cdfa9b639711a6bfcf2f525366474c3e68c9bf Mon Sep 17 00:00:00 2001 From: Jesse Weaver Date: Fri, 20 Nov 2015 10:13:37 -0700 Subject: [PATCH] Bug 19265: Rancor - Add export of selected records, edit button to manage imports To test: 1 - Open a batch of staged records 2 - Note the new toolbar 3 - Select some records and export 4 - Verify previous functionality works as expected --- .../prog/en/modules/tools/manage-marc-import.tt | 62 +++++++++++++++++++--- svc/cataloguing/import_batches | 6 +++ 2 files changed, 60 insertions(+), 8 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 4d84eb3..3a03b47 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 @@ -23,6 +23,7 @@ $(document).ready(function(){ }); [% IF import_batch_id %] + var checkedRecords = {}; $("#records-table").dataTable($.extend(true, {}, dataTablesDefaults, { "bAutoWidth": false, "bFilter": false, @@ -31,14 +32,25 @@ $(document).ready(function(){ "sAjaxSource": 'batch_records_ajax.pl', "sPaginationType": "full_numbers", "sDom": '<"top pager"iflp>rt<"bottom pager"flp><"clear">', + "aaSorting": [ [ 1, 'asc' ] ], "aoColumns": [ + { + "bSortable": false, + "mDataProp": null, + "sDefaultContent": '' + }, { "mDataProp": "import_record_id" }, { "mDataProp": "citation" }, { "mDataProp": "status" }, { "mDataProp": "overlay_status" }, { "mDataProp": "match_citation" }, { "mDataProp": "diff_url" }, - { "mDataProp": "matched" } + { "mDataProp": "matched" }, + { + "bSortable": false, + "mDataProp": null, + "sDefaultContent": '' + } ], "fnServerData": function ( sSource, aoData, fnCallback ) { aoData.push( { "name": "import_batch_id", "value": [% import_batch_id %] } ); @@ -60,11 +72,23 @@ $(document).ready(function(){ var record_details_url = "/cgi-bin/koha/catalogue/detail.pl?biblionumber="; [% END %] - $('td:eq(1)', nRow).html( - '' + aData['citation'] + '' - ); + var record_id = aData['import_record_id']; + var $checkbox = $(''); + $('td:eq(0)', nRow).append($checkbox); + $checkbox.prop( 'checked', checkedRecords[record_id] ); + $checkbox.change( function() { + if ( this.checked ) { + checkedRecords[record_id] = true; + } else { + delete checkedRecords[record_id]; + } + } ); $('td:eq(2)', nRow).html( + '' + aData['citation'] + '' + ); + + $('td:eq(3)', nRow).html( aData['status'] == 'imported' ? _("Imported") : aData['status'] == 'ignored' ? _("Ignored") : aData['status'] == 'reverted' ? _("Reverted") : @@ -73,7 +97,7 @@ $(document).ready(function(){ aData['status'] ); - $('td:eq(3)', nRow).html( + $('td:eq(4)', nRow).html( aData['overlay_status'] == 'no_match' ? _("No match") : aData['overlay_status'] == 'match_applied' ? _("Match applied") : aData['overlay_status'] == 'auto_match' ? _("Match found") : @@ -93,14 +117,18 @@ $(document).ready(function(){ ); } if (aData['diff_url']){ - $('td:eq(5)', nRow).html( - 'View' + $('td:eq(6)', nRow).html( + 'View' ); } - $('td:eq(6)', nRow).html( + $('td:eq(7)', nRow).html( '' + aData['matched'] + '' ); + $('td:eq(8)', nRow).html( + '' + _("Edit") + '' + ); }, })); $("#import_batch_form").on("submit",function(){ @@ -109,6 +137,16 @@ $(document).ready(function(){ $("#revert_batch_form").on("submit",function(){ return confirm( _("Are you sure you want to undo the import of this batch into the catalog?") ) && submitBackgroundJob( document.getElementById("revert_batch_form") ); }); + $('#export-selected').click( function() { + var options = { + import_record_id: $.map( checkedRecords, function( undef, key ) { return key; } ).join('|'), + }; + + if ( options.import_record_id.length == 0 ) return false;_ + + window.open( '/cgi-bin/koha/svc/cataloguing/import_batches/' + [% import_batch_id %] + '?download=1&' + $.param( options ) ); + return false; + }); [% END %] $("body").on("click",".previewMARC", function(e){ e.preventDefault(); @@ -162,6 +200,7 @@ $(document).ready(function(){ › Batch [% import_batch_id %] [% END %] + [% IF ( label_batch_msg ) %] [% IF ( alert ) %]
@@ -467,9 +506,15 @@ Page [% END %] [% IF import_batch_id %] +
+ + +
+ + @@ -477,6 +522,7 @@ Page +
  # Citation StatusMatch details Diff RecordAction
diff --git a/svc/cataloguing/import_batches b/svc/cataloguing/import_batches index 6c07203..a4826a5 100755 --- a/svc/cataloguing/import_batches +++ b/svc/cataloguing/import_batches @@ -85,6 +85,12 @@ sub download_batch { }; } + my $import_record_ids = $query->param( 'import_record_id' ); + + if ( $import_record_ids ) { + $extra_conditions{'import_record.import_record_id'} = { -in => [ split /\|/, $import_record_ids ] }; + } + my $records = $schema->resultset('ImportBiblio')->search( { 'import_record.import_batch_id' => $batch_id, -- 2.7.4