From 8a5518f9eeb80f38c071cf3a8edd45bb674854e1 Mon Sep 17 00:00:00 2001 From: Matt Blenkinsop Date: Wed, 3 Jul 2024 09:52:45 +0000 Subject: [PATCH] Bug 36831: Allow for multiple file types This patch allows the KBART import tool to accept different filetypes and then work out whether they are CSV or TSV files. Test plan: 1) Try to import the file attached to the bug using the KBART import tool (E-resource management > eHoldings > Local > Titles > Import from a KBART file) 2) It should return an error saying that the file must be .csv or .tsv 3) Apply patch 4) yarn build 5) restart_all 6) Repeat step 1 7) The file should now successfully import Signed-off-by: David Nind --- Koha/ERM/EHoldings/Title.pm | 4 ++-- .../ERM/EHoldingsLocalTitlesKBARTImport.vue | 17 +---------------- 2 files changed, 3 insertions(+), 18 deletions(-) diff --git a/Koha/ERM/EHoldings/Title.pm b/Koha/ERM/EHoldings/Title.pm index 73e4d53846b..15abf6e33a4 100644 --- a/Koha/ERM/EHoldings/Title.pm +++ b/Koha/ERM/EHoldings/Title.pm @@ -141,7 +141,7 @@ sub read_file { return ( $column_headers, $lines, $error ); } - return ( $column_headers, $lines ); + return ( $column_headers, $lines, '' ); } @@ -268,7 +268,7 @@ sub _detect_delimiter_and_quote { my %quote_count; foreach my $line (@lines) { - foreach my $char ( ',', '\t', ';', '|' ) { + foreach my $char ( ",", "\t", ";", "|" ) { my $count = () = $line =~ /\Q$char\E/g; $delimiter_count{$char} += $count if $count; } diff --git a/koha-tmpl/intranet-tmpl/prog/js/vue/components/ERM/EHoldingsLocalTitlesKBARTImport.vue b/koha-tmpl/intranet-tmpl/prog/js/vue/components/ERM/EHoldingsLocalTitlesKBARTImport.vue index d2d18bb194e..4edb78ee277 100644 --- a/koha-tmpl/intranet-tmpl/prog/js/vue/components/ERM/EHoldingsLocalTitlesKBARTImport.vue +++ b/koha-tmpl/intranet-tmpl/prog/js/vue/components/ERM/EHoldingsLocalTitlesKBARTImport.vue @@ -2,21 +2,6 @@

{{ $__("Import from a KBART file") }}

-

{{ $__("Requirements:") }}

-
    -
  • {{ $__("The file must be in TSV or CSV format") }}
  • -
  • - {{ - $__( - "The file should not contain any additional information / header rows, e.g. a file with a single title would be structured as follows:" - ) - }} -
      -
    1. {{ $__("Column headings row") }}
    2. -
    3. {{ $__("Title data row") }}
    4. -
    -
  • -

{{ $__("Select file for upload") }}:

    @@ -174,7 +159,7 @@ export default { } if (success.warnings.invalid_filetype) { message += `

    ${this.$__( - "The file must be in .tsv or .csv format, please convert your file and try again." + "Could not detect whether the file is TSV or CSV, please check the file." )}

    ` this.setWarning(message) } -- 2.39.5 (Apple Git-154)