From 4f2205f429b3d082c7ee78a8e92f0ec064687621 Mon Sep 17 00:00:00 2001 From: Cori Lynn Arnold Date: Thu, 11 Oct 2018 18:29:58 +0000 Subject: [PATCH] Bug 18823: Refactor and fix issue with updating import batch record Rebased code with changes from Bug 19263 Added missing function from previous patch to make saves of edits to import batches Changed setting for import batches created by Rancor to 'staged' as there is no mechanism to change them from 'staging' Changes to make batch names work with single quotes "Client's Batch" Changes to fix QA tool issues (i.e. bootstrap button & undef) Tests: 1) Open advanced cataloging editor 2) Under settings select 'Import Batches' 3) Create a few import batches, some for searching and some as targets (and some both) 3.a) not that import batches for saving appear on the left side as targets to save 4) Search for a bibliographic record, make changes and apply to an import batch 5) Search for the bibliographic record in the import batch 6) Make changes and verify the changes are applied (either through searching again, or through the Staged MARC management in Tools) --- C4/ImportBatch.pm | 23 ++++++++++++++++++++++ Koha/MetaSearcher.pm | 2 +- .../prog/en/includes/cateditor-ui.inc | 6 +++--- .../prog/en/modules/cataloguing/editor.tt | 7 ++++--- svc/cataloguing/import_batches | 3 ++- 5 files changed, 33 insertions(+), 8 deletions(-) diff --git a/C4/ImportBatch.pm b/C4/ImportBatch.pm index 9a7ca66c26..e1a8653325 100644 --- a/C4/ImportBatch.pm +++ b/C4/ImportBatch.pm @@ -1608,6 +1608,29 @@ sub _create_import_record { return $import_record_id; } +sub _get_import_record_timestamp { + my ( $marc_record ) = @_; + + my $upload_timestamp = DateTime->now(); + + # Attempt to parse the 005 timestamp. This is a bit weird because we have to parse the + # tenth-of-a-second ourselves. + my $f005 = $marc_record->field('005'); + if ($f005 && $f005->data =~ /(\d{8}\d{6})\.(\d)/ ) { + my $parser = DateTime::Format::Strptime->new( pattern => '%Y%m%d%H%M%S' ); + my $parsed_timestamp = $parser->parse_datetime($1); + + # We still check for success because we only did enough validation above to extract the + # tenth-of-a-second; the timestamp could still be some nonsense like the 50th of Jantober. + if ( $parsed_timestamp ) { + $parsed_timestamp->set_nanosecond( $2 * 100_000_000 ); + $upload_timestamp = $parsed_timestamp; + } + } + + return $upload_timestamp; +} + sub _update_import_record_marc { my ($import_record_id, $marc_record, $marc_type) = @_; diff --git a/Koha/MetaSearcher.pm b/Koha/MetaSearcher.pm index 1cac8afee7..3f82dc51bb 100644 --- a/Koha/MetaSearcher.pm +++ b/Koha/MetaSearcher.pm @@ -273,7 +273,7 @@ sub _batch_db_query_from_terms { push @db_terms, $_batch_db_mapping->{$index} => [ -and => _db_query_get_match_conditions( $index, $value ) ]; } else { # No such index, we should fail - return undef; + die("No such index"); } } diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/cateditor-ui.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/cateditor-ui.inc index a5f52467fa..e0b0516e5d 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/includes/cateditor-ui.inc +++ b/koha-tmpl/intranet-tmpl/prog/en/includes/cateditor-ui.inc @@ -42,7 +42,7 @@ require( [ 'koha-backend', 'search', 'macros', 'marc-editor', 'marc-record', 'pr }, [%- FOREACH batch = editable_batches -%] 'batch:[% batch.import_batch_id %]': { - name: _("Batch: ") + '[% batch.file_name %]', + name: _("Batch: ") + `[% batch.file_name %]`, recordtype: 'biblio', checked: false, }, @@ -314,7 +314,7 @@ require( [ 'koha-backend', 'search', 'macros', 'marc-editor', 'marc-record', 'pr var editable_batches = { [%- FOREACH batch = editable_batches -%] [% batch.import_batch_id %]: { - 'name': '[% batch.file_name %]', + 'name': `[% batch.file_name %]`, }, [%- END -%] }; @@ -339,7 +339,7 @@ require( [ 'koha-backend', 'search', 'macros', 'marc-editor', 'marc-record', 'pr $.each( target_list, function( i, target ) { var $new_target = $( - '
  • ' + '
  • ` ); $new_target.find('input').change( function() { diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/editor.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/editor.tt index c1bb6ed161..ac741d6eeb 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/editor.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/editor.tt @@ -263,6 +263,7 @@