From fc541147c89e6234cdc4fc6982d16e1a506bab11 Mon Sep 17 00:00:00 2001 From: Zanz2 Date: Thu, 25 Jan 2018 15:54:38 +0100 Subject: [PATCH] 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 --- app/controllers/protocols_controller.rb | 9 +++++++++ .../import_export/_import_json_protocol_modal.html.erb | 1 + app/views/protocols/protocolsio_import_create.js.erb | 8 +++++++- 3 files changed, 17 insertions(+), 1 deletion(-) diff --git a/app/controllers/protocols_controller.rb b/app/controllers/protocols_controller.rb index 09bde5ddf..9bfa26580 100644 --- a/app/controllers/protocols_controller.rb +++ b/app/controllers/protocols_controller.rb @@ -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| diff --git a/app/views/protocols/import_export/_import_json_protocol_modal.html.erb b/app/views/protocols/import_export/_import_json_protocol_modal.html.erb index 1de9272c8..f6928dd40 100644 --- a/app/views/protocols/import_export/_import_json_protocol_modal.html.erb +++ b/app/views/protocols/import_export/_import_json_protocol_modal.html.erb @@ -18,6 +18,7 @@