From 160698296687752d1ad5df56884c1ddfe4125c02 Mon Sep 17 00:00:00 2001 From: Zanz2 Date: Mon, 2 Apr 2018 19:56:25 +0200 Subject: [PATCH 1/4] found a hackish fix by doing a manual ajax call and some other things with jquery --- Gemfile | 2 +- app/assets/javascripts/application.js.erb | 2 +- app/controllers/protocols_controller.rb | 1 - .../_import_json_protocol_modal.html.erb | 31 ++++++++++++++++--- .../protocolsio_import_create.js.erb | 28 +++++++---------- 5 files changed, 39 insertions(+), 25 deletions(-) diff --git a/Gemfile b/Gemfile index 1bea45cc0..ff753246f 100644 --- a/Gemfile +++ b/Gemfile @@ -57,7 +57,7 @@ gem 'roo', '~> 2.7.1' # Spreadsheet parser gem 'wicked_pdf', '~> 1.1.0' gem 'silencer' # Silence certain Rails logs gem 'wkhtmltopdf-heroku' -gem 'remotipart', '~> 1.2' # Async file uploads +# gem 'remotipart', '~> 1.2' # Async file uploads gem 'faker' # Generate fake data gem 'auto_strip_attributes', '~> 2.1' # Removes unnecessary whitespaces from ActiveRecord or ActiveModel attributes gem 'deface', '~> 1.0' diff --git a/app/assets/javascripts/application.js.erb b/app/assets/javascripts/application.js.erb index f5051cee4..b613a1dae 100644 --- a/app/assets/javascripts/application.js.erb +++ b/app/assets/javascripts/application.js.erb @@ -3,7 +3,7 @@ //= require jquery //= require jquery.turbolinks //= require jquery_ujs -//= require jquery.remotipart + //= require jquery.mousewheel.min //= require jquery.scrollTo //= require jquery.autosize diff --git a/app/controllers/protocols_controller.rb b/app/controllers/protocols_controller.rb index 52c2476ed..3d9308618 100644 --- a/app/controllers/protocols_controller.rb +++ b/app/controllers/protocols_controller.rb @@ -645,7 +645,6 @@ class ProtocolsController < ApplicationController @json_object['steps'] ) end - @protocol = Protocol.new respond_to do |format| format.js {} # go to the js.erb file named the same as this controller, 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 f6928dd40..9567d0495 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 @@ -12,22 +12,43 @@ <%= t("protocols.index.modal_import_json_notice") %> - <%= form_tag({ action: "protocolsio_import_create"}, id:"protocols_io_form", - format: :json, multipart: true,remote: true,:method => "post") do %> + <%= form_with url: url_for(controller: 'protocols', action: 'protocolsio_import_create'), remote:true, id:"protocols_io_form", + authenticity_token:true,method:"post",multipart:true do |form| %> + <% end %> - <% end %> + + diff --git a/app/views/protocols/protocolsio_import_create.js.erb b/app/views/protocols/protocolsio_import_create.js.erb index ff8a6439d..ce19440a6 100644 --- a/app/views/protocols/protocolsio_import_create.js.erb +++ b/app/views/protocols/protocolsio_import_create.js.erb @@ -13,21 +13,15 @@ $('#pio_no_file_error_span').addClass('has-error').html(' 'protocols/import_export/import_json_protocol_preview_modal')}" %>" - ); - <% else %> - $('#protocolsio-preview-modal-target').html( - "<%= j render(:partial => 'protocols/import_export/import_json_protocol_preview_modal') %>" - ); - <% end %> - $('#modal-import-json-protocol-preview').modal('show'); - $('.modal').on('hidden.bs.modal', function (e) { - if($('.modal').hasClass('in')) { - $('body').addClass('modal-open'); - } - }); - - + $('#protocolsio-preview-modal-target').html( + "<%= j render(:partial => 'protocols/import_export/import_json_protocol_preview_modal') %>" + ); + $('#modal-import-json-protocol-preview').modal('show'); + $('.modal').on('hidden.bs.modal', function (e) { + if($('.modal').hasClass('in')) { + $('body').addClass('modal-open'); + } + }); <% end %> +$("#protocols_io_form")[0].reset(); +$('#protocols_io_form').trigger("reset"); From 25619e5e01a55e2da90d71e092d4bc416dd4d421 Mon Sep 17 00:00:00 2001 From: Zanz2 Date: Mon, 2 Apr 2018 20:02:59 +0200 Subject: [PATCH 2/4] Overlooked a small change --- app/controllers/protocols_controller.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/app/controllers/protocols_controller.rb b/app/controllers/protocols_controller.rb index 3d9308618..11158eba6 100644 --- a/app/controllers/protocols_controller.rb +++ b/app/controllers/protocols_controller.rb @@ -645,6 +645,7 @@ class ProtocolsController < ApplicationController @json_object['steps'] ) end + @protocol = Protocol.new respond_to do |format| format.js {} # go to the js.erb file named the same as this controller, From 2fab3e4caa3428ed653c9b24f878df95d59710ad Mon Sep 17 00:00:00 2001 From: Zanz2 Date: Mon, 2 Apr 2018 20:05:06 +0200 Subject: [PATCH 3/4] Overlooked a small change #2 --- app/controllers/protocols_controller.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/controllers/protocols_controller.rb b/app/controllers/protocols_controller.rb index 11158eba6..52c2476ed 100644 --- a/app/controllers/protocols_controller.rb +++ b/app/controllers/protocols_controller.rb @@ -645,7 +645,7 @@ class ProtocolsController < ApplicationController @json_object['steps'] ) end - + @protocol = Protocol.new respond_to do |format| format.js {} # go to the js.erb file named the same as this controller, From 7f36ab3e5e440e055f1fe4240eb844a88b72808c Mon Sep 17 00:00:00 2001 From: Zanz2 Date: Wed, 4 Apr 2018 11:12:39 +0200 Subject: [PATCH 4/4] deleted require and gemfile entry for remotipart --- Gemfile | 1 - app/assets/javascripts/application.js.erb | 1 - 2 files changed, 2 deletions(-) diff --git a/Gemfile b/Gemfile index ff753246f..26c075ad6 100644 --- a/Gemfile +++ b/Gemfile @@ -57,7 +57,6 @@ gem 'roo', '~> 2.7.1' # Spreadsheet parser gem 'wicked_pdf', '~> 1.1.0' gem 'silencer' # Silence certain Rails logs gem 'wkhtmltopdf-heroku' -# gem 'remotipart', '~> 1.2' # Async file uploads gem 'faker' # Generate fake data gem 'auto_strip_attributes', '~> 2.1' # Removes unnecessary whitespaces from ActiveRecord or ActiveModel attributes gem 'deface', '~> 1.0' diff --git a/app/assets/javascripts/application.js.erb b/app/assets/javascripts/application.js.erb index b613a1dae..be3b7af97 100644 --- a/app/assets/javascripts/application.js.erb +++ b/app/assets/javascripts/application.js.erb @@ -3,7 +3,6 @@ //= require jquery //= require jquery.turbolinks //= require jquery_ujs - //= require jquery.mousewheel.min //= require jquery.scrollTo //= require jquery.autosize