From 5d6cc341ed30beafec934d718be8bb2055fb058b Mon Sep 17 00:00:00 2001 From: Zanz2 Date: Thu, 14 Sep 2017 14:42:04 +0200 Subject: [PATCH] added first half of inputs, working on scroller next, page now refreshes after you cancel out of import window, to update the data, will look for alternate way after im done --- app/controllers/protocols_controller.rb | 7 +++-- ...mport_json_protocol_preview_modal.html.erb | 28 ++++++++++++++----- .../protocolsio_import_create.js.erb | 2 +- 3 files changed, 26 insertions(+), 11 deletions(-) diff --git a/app/controllers/protocols_controller.rb b/app/controllers/protocols_controller.rb index 760a96a9f..0a3d85203 100644 --- a/app/controllers/protocols_controller.rb +++ b/app/controllers/protocols_controller.rb @@ -606,13 +606,14 @@ def protocolsio_import_new end def protocolsio_import_create - + json_file_contents=File.read(params[:json_file].path) @json_object=JSON.parse(json_file_contents) - + @protocol=Protocol.new + respond_to do |format| format.html - format.js + format.js {} end end diff --git a/app/views/protocols/import_export/_import_json_protocol_preview_modal.html.erb b/app/views/protocols/import_export/_import_json_protocol_preview_modal.html.erb index f49a618f5..2d4cffa26 100644 --- a/app/views/protocols/import_export/_import_json_protocol_preview_modal.html.erb +++ b/app/views/protocols/import_export/_import_json_protocol_preview_modal.html.erb @@ -12,32 +12,39 @@
<% #puts json_object %> - <% #byebug %> +
+ <%= form_for(protocol, :remote => true) do |f| %> - + + <%= f.text_field :name, :value => json_object['protocol_name'], class: "form-control" %>
- + <%= f.text_field :authors, :value => json_object['username'], class: "form-control" %> + +
- - + --> + + <%= f.text_area :description, :value => json_object['description'], class: "form-control" %>
- + + <%= f.text_field :doesnt_exist, :value => json_object['created_on']+" (Protocols.io value)", class: "form-control" %>
- + + <%= f.text_field :doesnt_exist, :value => json_object['last_modified']+" (Protocols.io value)", class: "form-control" %>
@@ -53,6 +60,7 @@
+ <% end %> + + diff --git a/app/views/protocols/protocolsio_import_create.js.erb b/app/views/protocols/protocolsio_import_create.js.erb index 3373fa9da..39d924710 100644 --- a/app/views/protocols/protocolsio_import_create.js.erb +++ b/app/views/protocols/protocolsio_import_create.js.erb @@ -1,3 +1,3 @@ $('#modal-import-json-protocol').modal('hide'); -$('#protocolsio_preview_modal_target').append("<%= j render(:partial => "protocols/import_export/import_json_protocol_preview_modal", :locals => {:json_object => @json_object}) %>") +$('#protocolsio_preview_modal_target').append("<%= j render(:partial => "protocols/import_export/import_json_protocol_preview_modal", :locals => {:json_object => @json_object,:protocol => @protocol}) %>") $('#modal-import-json-protocol-preview').modal('show');