mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2025-01-31 03:59:51 +08:00
re-pushing this, this got merged into master already but i accidentally deleted it when merging two branches
This commit is contained in:
parent
4389c110cf
commit
367eff6401
3 changed files with 15 additions and 0 deletions
|
@ -601,6 +601,14 @@ class ProtocolsController < ApplicationController
|
||||||
def protocolsio_import_create
|
def protocolsio_import_create
|
||||||
@protocolsio_too_big = false
|
@protocolsio_too_big = false
|
||||||
@protocolsio_invalid_file = 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)
|
extension = File.extname(params[:json_file].path)
|
||||||
file_size = File.size(params[:json_file].path)
|
file_size = File.size(params[:json_file].path)
|
||||||
if extension != '.txt' && extension != '.json'
|
if extension != '.txt' && extension != '.json'
|
||||||
|
|
|
@ -18,6 +18,7 @@
|
||||||
<div class="modal-body">
|
<div class="modal-body">
|
||||||
|
|
||||||
<%= file_field_tag 'json_file', accept: '.txt,.json' %>
|
<%= file_field_tag 'json_file', accept: '.txt,.json' %>
|
||||||
|
<div id="pio_no_file_error_span"></div>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
<div class="modal-footer">
|
<div class="modal-footer">
|
||||||
|
|
|
@ -1,3 +1,6 @@
|
||||||
|
$('#modal-import-json-protocol').on('hidden.bs.modal', function () {
|
||||||
|
$('#pio_no_file_error_span').empty();
|
||||||
|
})
|
||||||
<% if @protocolsio_too_big %>
|
<% if @protocolsio_too_big %>
|
||||||
$('#modal-import-json-protocol').modal('hide');
|
$('#modal-import-json-protocol').modal('hide');
|
||||||
HelperModule.flashAlertMsg(' <%= t('my_modules.protocols.load_from_file_size_error',
|
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 %>
|
<% elsif @protocolsio_invalid_file %>
|
||||||
$('#modal-import-json-protocol').modal('hide');
|
$('#modal-import-json-protocol').modal('hide');
|
||||||
HelperModule.flashAlertMsg(' <%= t('my_modules.protocols.load_from_file_invalid_error') %>','danger');
|
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 %>
|
<% else %>
|
||||||
$('#modal-import-json-protocol').modal('hide');
|
$('#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 %>
|
<% if remotipart_submitted? %> <%# a workaround to a bug with remotipart, that caused alot of headache, courtesy of github.com/dhampik %>
|
||||||
|
|
Loading…
Reference in a new issue