Skip to content

Commit

Permalink
Provide info about which file is empty to user
Browse files Browse the repository at this point in the history
  • Loading branch information
Splines committed Oct 30, 2023
1 parent b1ac009 commit 4af005a
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 4 deletions.
10 changes: 6 additions & 4 deletions app/assets/javascripts/upload.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -310,10 +310,12 @@ bulkCorrectionUpload = (fileInput) ->
# Disable upload if uploaded (zip)-file is empty
# Temporary fix for ":type option required" error in the
# app/controllers/submissions_controller.rb -> show_correction
fileSizes = dataAll.map((data) => data.metadata.size)
if fileSizes.includes(0)
console.log('empty file encountered during bulk upload')
alert($('#bulk-uploadButton-button-actual').data('tr-failure-empty-file'))
for data in dataAll
if data.metadata.size > 0
continue
console.log('empty file encountered during bulk upload: ' + data.metadata.filename)
alert(data.metadata.filename + ' ' +
$('#bulk-uploadButton-button-actual').data('tr-failure-empty-file-bulk'))
$('#bulk-uploadButton-button-actual').hide()
$(metaData).empty()
return
Expand Down
1 change: 1 addition & 0 deletions app/views/tutorials/_bulk_correction_form.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
data-tr-failure="<%= t('submission.upload_failure')%>"
data-tr-missing-consent="<%= t('submission.missing_consent')%>"
data-tr-failure-empty-file="<%= t('submission.upload_failure_empty_file')%>"
data-tr-failure-empty-file-bulk="<%= t('submission.upload_failure_empty_file_bulk')%>"
data-tr-post-processing="<%= t('basics.post_processing')%>"
class="btn btn-sm btn-outline-secondary"
>
Expand Down
3 changes: 3 additions & 0 deletions config/locales/de.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2667,6 +2667,9 @@ de:
upload_failure_empty_file: >
Die hochgeladene Datei ist leer.
Bitte vergewissere dich, dass die Datei nicht beschädigt ist.
upload_failure_empty_file_bulk: >
ist leer.
Bitte vergewissere dich, dass die Datei nicht beschädigt ist.
file_size_too_big: Die Datei ist eigentlich zu groß, kann aber hochgeladen werden.
file_size_way_too_big: Die Dateigröße überschreitet das Limit. Bitte optimiere sie.
optimization_help_html: >
Expand Down
3 changes: 3 additions & 0 deletions config/locales/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2514,6 +2514,9 @@ en:
upload_failure_empty_file: >
The uploaded file is empty.
Please make sure that the file is not corrupted.
upload_failure_empty_file_bulk: >
is empty.
Please make sure that the file is not corrupted.
file_size_too_big: The filesize exceeds the limit, nevertheless it is uploadable.
file_size_way_too_big: The filesize exceeds the limit. Please optimize it.
optimization_help_html: >
Expand Down

0 comments on commit 4af005a

Please sign in to comment.