Bug 27869: let user know something went wrong with csv upload

To test:
-attempt to upload a malformed CSV file
-nothing happens, check the console and see the error: Uncaught TypeError: arrData[(arrData.length - 1)] is undefined
-apply patch
-try again
-now you should at least see a warning that something went wrong
-attempt to upload a good CSV file, it should work

Signed-off-by: David Nind <david@davidnind.com>
Signed-off-by: Joonas Kylmälä <joonas.kylmala@helsinki.fi>

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
This commit is contained in:
Lucas Gass 2021-03-04 19:37:10 +00:00 committed by Jonathan Druart
parent cb03909af6
commit 5aa24a6a47

View file

@ -30,6 +30,7 @@
<div class="import_errors dialog alert" style="display: none;"></div>
</div>
<div id="csv_error" class="alert" style="visibility: hidden;">Something went wrong, check your CSV file.</div>
<div id="instructions">
<fieldset id="file_uploader_help" class="rows">
<legend>Instructions</legend>
@ -217,7 +218,11 @@
// Now that we have our value string, let's add
// it to the data array.
arrData[ arrData.length - 1 ].push( strMatchedValue );
if ( arrData[ arrData.length - 1 ] ) {
arrData[ arrData.length - 1 ].push( strMatchedValue );
} else {
$('#csv_error').css( 'visibility' , 'visible' );
}
}
// Return the parsed data.