Skip to content

Commit

Permalink
Merge pull request #4891 from avalonmediasystem/fileupload-block
Browse files Browse the repository at this point in the history
Block file upload form while upload is in progress
  • Loading branch information
cjcolvar authored Sep 26, 2022
2 parents c7e8bb4 + ca3eaf9 commit 36fa7f8
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
6 changes: 3 additions & 3 deletions app/assets/javascripts/direct_upload.js.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ $ ->
form = $(file_input.parents('form:first'))
submit_button = form.find('input[type="submit"], *[data-trigger="submit"]')
submit_button.on 'click', ->
form.addClass('form-disabled')
$('.directupload input:file').fileupload 'send',
files: $('.directupload input:file').prop('files')
return false
Expand All @@ -37,15 +38,14 @@ $ ->
progress = parseInt(data.loaded / data.total * 100, 10)
progress_bar.css('width', "#{progress}%")
start: (e)->
submit_button.prop('disabled', true)
progress_bar.
css('background', 'green').
css('display', 'block').
css('width', '0%').
css('padding', '7px').
text("Loading...")
done: (e, data)->
submit_button.prop('disabled', false)
form.removeClass('form-disabled')
progress_bar.text("Uploading done")

# extract key and generate URL from response
Expand All @@ -61,7 +61,7 @@ $ ->
file_input.replaceWith(input)
form.submit()
fail: (e, data)->
submit_button.prop('disabled', false)
form.removeClass('form-disabled')
progress_bar.
css("background", "red").
text("Failed")
5 changes: 5 additions & 0 deletions app/assets/stylesheets/avalon.scss
Original file line number Diff line number Diff line change
Expand Up @@ -1111,6 +1111,11 @@ h5.card-title {
padding-top: 5px;
}

.form-disabled {
pointer-events: none;
opacity: 0.4;
}

.fileinput-close {
padding-top: 5px;
float: none;
Expand Down

0 comments on commit 36fa7f8

Please sign in to comment.