re-pushing this, this got merged into master already but i accidentally deleted it when merging two branches

This commit is contained in:
Zanz2 2018-02-07 11:17:53 +01:00
parent 4389c110cf
commit 367eff6401
3 changed files with 15 additions and 0 deletions

View file

@ -601,6 +601,14 @@ class ProtocolsController < ApplicationController
def protocolsio_import_create
@protocolsio_too_big = false
@protocolsio_invalid_file = false
@protocolsio_no_file = false
if params[:json_file].nil?
@protocolsio_no_file = true
respond_to do |format|
format.js {}
end
return 0 # return 0 stops the rest of the controller code from executing
end
extension = File.extname(params[:json_file].path)
file_size = File.size(params[:json_file].path)
if extension != '.txt' && extension != '.json'

View file

@ -18,6 +18,7 @@
<div class="modal-body">
<%= file_field_tag 'json_file', accept: '.txt,.json' %>
<div id="pio_no_file_error_span"></div>
</div>
<div class="modal-footer">

View file

@ -1,3 +1,6 @@
$('#modal-import-json-protocol').on('hidden.bs.modal', function () {
$('#pio_no_file_error_span').empty();
})
<% if @protocolsio_too_big %>
$('#modal-import-json-protocol').modal('hide');
HelperModule.flashAlertMsg(' <%= t('my_modules.protocols.load_from_file_size_error',
@ -5,6 +8,9 @@ HelperModule.flashAlertMsg(' <%= t('my_modules.protocols.load_from_file_size_err
<% elsif @protocolsio_invalid_file %>
$('#modal-import-json-protocol').modal('hide');
HelperModule.flashAlertMsg(' <%= t('my_modules.protocols.load_from_file_invalid_error') %>','danger');
<% elsif @protocolsio_no_file %>
$('#pio_no_file_error_span').addClass('has-error').html('<span class="help-block"> <%= t('teams.parse_sheet.errors.no_file_selected') %></span>');
<% @protocolsio_no_file = false %>
<% else %>
$('#modal-import-json-protocol').modal('hide');
<% if remotipart_submitted? %> <%# a workaround to a bug with remotipart, that caused alot of headache, courtesy of github.com/dhampik %>