mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2024-12-29 11:45:18 +08:00
A red error messagge is now displayed when selecting no protocol and pressing upload on protocols io import, and after the modal is closed the messagge is gone
This commit is contained in:
parent
ab2955c9bb
commit
fc541147c8
3 changed files with 17 additions and 1 deletions
|
@ -601,8 +601,17 @@ 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'
|
||||
@protocolsio_invalid_file = true
|
||||
respond_to do |format|
|
||||
|
|
|
@ -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">
|
||||
|
|
|
@ -1,4 +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',
|
||||
|
@ -6,6 +8,10 @@ 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 %>
|
||||
<%# no file alert code goes here color: #a94442 %>
|
||||
$('#pio_no_file_error_span').html('<span class="help-block" style="color:#a94442"> <%= 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 %>
|
||||
|
|
Loading…
Reference in a new issue