From df8cbc27415f9b9531b35e9aca12b171a5e7126b Mon Sep 17 00:00:00 2001 From: Zanz2 Date: Thu, 21 Sep 2017 13:46:52 +0200 Subject: [PATCH] vastly improved protocol preview styling to look more like documentation specifications --- ...mport_json_protocol_preview_modal.html.erb | 237 +++++++++++------- 1 file changed, 146 insertions(+), 91 deletions(-) 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 efa469334..7be431f32 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 @@ -63,62 +63,111 @@ -
+
- + <% if @json_object["before_start"]&&@json_object["before_start"]!="" %> - - - + <% end %> <% if @json_object["warning"]&&@json_object["warning"]!="" %> - - - + <% end %> <% if @json_object["guidelines"]&&@json_object["guidelines"]!="" %> - - - + <% end %> - + <% counter=0 %> <% whitelist_simple=["1","6","17"] %> <% whitelist_complex=["8","9","15","18","19","20"]%> <% @json_object["steps"].each do |step| %> - - - + + +
+ + + + + <%# div od blocka %> <% end #step loop%> - + + + <% if @json_object["manuscript_citation"]&&@json_object["manuscript_citation"]!="" %> - - - + <% end %> <% if @json_object["publish_date"]&&@json_object["publish_date"]!="" %> - - - + <% end %> <% if @json_object["vendor_name"]&&@json_object["vendor_name"]!="" %> - - - + <% end %> <% if @json_object["vendor_link"]&&@json_object["vendor_link"]!="" %> - - - + <% end %> <% if @json_object["keywords"]&&@json_object["keywords"]!="" %> - - - + <% end %> <% if @json_object["tags"]&&@json_object["tags"]!="" %> - - - + <% end %> -
-

Before starting protocol information

+ +
Before starting protocol information:
<%= (@json_object["before_start"]) %> -
-

Protocol warning

+ +
Protocol warning:
<%= (@json_object["warning"]) %> -
-

Guidelines

+ +
Guidelines:
<%= (@json_object["guidelines"]) %> -


-

Step <%= (counter+=1).to_s %>


- Step guid (Protocols.io) :<%= step["guid"] %> - <% if counter>1 #only steps after the first one have previous step guid field valid%> -
Guid of previous step (Protocols.io) :<%= step["previous_guid"] %> - <% end %> - <% step["components"].each do |key,value| %> +
+
+
+
+ + <%= (counter+=1) %> + +   +   + + + + + <%#= Step guid (Protocols.io) :%><%#= step["guid"] %> + <%# if counter>1 #only steps after the first one have previous step guid field valid%> + <%#=Guid of previous step (Protocols.io) :%><%#= step["previous_guid"] %> + <%# end %> + <% title=nil %> + <% step["components"].each do |key1,value1| #finding section (title of step) %> + + <% if counter >1 %> + <% if(key1["component_type_id"]=="6") %> + <% if(!key1["data"].nil? && key1["data"]!="") %> + <%# byebug %> + <% title ||=key1["data"] %> + <% end %> + <% end %> + <% else %> + <% unless value1 %> + <% value1=key1 %> + <% end %> + <% if(value1["component_type_id"]=="6") %> + <% if(!value1["data"].nil? && value1["data"]!="") %> + <% #byebug %> + <% title ||=value1["data"] %> + <% end %> + <% end %> + <% end %> + <% end %> + <% if title.nil? %> + <%# byebug %> + <% title ="Protocols.io" %> + <% end %> + <%= title %> + +
+
+ +
+
+
+ + + <% step["components"].each do |key,value| %> <% if counter>1 #here i made an if to distinguish the first step from the others, because the first step #sometimes has weird nesting that makes the below outputs not work - %> - <% if whitelist_simple.include?(key["component_type_id"]) && key["data"]!="" && key["name"] && key["data"]%> -
- <%= (key["name"])+" : "+ (key["data"]) %> + %> + <% #byebug %> + <% if whitelist_simple.include?(key["component_type_id"]) && key["data"]!="" && key["data"] %> +
+ <% case key["component_type_id"]%> + <% when "6" %> + <% when "1" %> +
Description: <%=key["data"]%>
+ <% when "17" %> +
Expected result: <%=key["data"]%>
+ <% else %> + <% end %> <% elsif key && whitelist_complex.include?(key["component_type_id"]) %> + <% case key["component_type_id"]%> <% when "8"%>
- <%= "-"+(key["name"])+" : "+(key["source_data"]["name"]) %> + <%= key["name"]+": " %> <%= (key["source_data"]["name"]) %>
Developer : <%= (key["source_data"]["developer"]) %>
@@ -132,14 +181,14 @@ <% when "9"%>
- <%= "-"+(key["name"])+" : "+(key["source_data"]["name"]) %> + <%= key["name"]+": " %> <%= key["source_data"]["name"] %>
Link : <%= (key["source_data"]["link"]) %> <% when "15"%>
- <%= "-"+(key["name"])+" : "+(key["source_data"]["name"]) %> + <%= key["name"]+": " %> <%= key["source_data"]["name"] %>
Description : <%= (key["source_data"]["description"]) %>
@@ -147,7 +196,7 @@ <% when "18"%>
- -This protocol also contains an attached sub-protocol: <%= (key["source_data"]["protocol_name"]) %> + This protocol also contains an attached sub-protocol: <%= (key["source_data"]["protocol_name"]) %>
Author: <%= (key["source_data"]["full_name"]) %>
@@ -156,7 +205,7 @@ <% end %> <% when "19"%>
- <%= "-"+(key["name"])+" : "+(key["source_data"]["body"]) %> + <%= key["name"]+": " %> <%= key["source_data"]["body"] %>
Link : <%= (key["source_data"]["link"]) %> @@ -167,31 +216,31 @@ <% end %> - - <% end #notranji if št 1%> - - <% else #če ni prvi korak %> + <% else #if first step %> <% unless value %> - <% value=key #json format ima random arraye namest hashov, ta problem je opisan pri if counter > 1 stavku %> + <% value=key #protocols io first step json formating is sometimes broken, this is a workaround%> <% end %> + <% #byebug %> + <% if whitelist_simple.include?(value["component_type_id"]) && value["data"] && value["data"]!="" %> +
+ <% case value["component_type_id"]%> + <% when "6" %> - <% if whitelist_simple.include?(value["component_type_id"])&& value["data"]!="" && value["name"] && value["data"] %> -
- <%= (value["name"])+" : "+(value["data"]) %> - <% - #debug - #comp[counter];counter;@json.file_contents["steps"][3]["components"][0]["name"] - #@json.file_contents["steps"][0]["components"] - %> + <% when "1" %> +
Description: <%=value["data"]%>
+ <% when "17" %> +
Expected result: <%=value["data"]%>
+ <% else %> + <% end %> <% elsif value && whitelist_complex.include?(value["component_type_id"]) %> <% case value["component_type_id"]%> <% when "8"%>
- <%= "-"+(value["name"])+" : "+(value["source_data"]["name"]) %> + <%= value["name"]+": " %> <%= (value["source_data"]["name"]) %>
Developer : <%= (value["source_data"]["developer"]) %>
@@ -205,14 +254,14 @@ <% when "9"%>
- <%= "-"+(value["name"])+" : "+(value["source_data"]["name"]) %> + <%= value["name"]+": " %> <%= value["source_data"]["name"] %>
Link : <%= (value["source_data"]["link"]) %> <% when "15"%>
- <%= "-"+(value["name"])+" : "+(value["source_data"]["name"]) %> + <%= value["name"]+": " %> <%= value["source_data"]["name"] %>
Description : <%= (value["source_data"]["description"]) %>
@@ -220,17 +269,16 @@ <% when "18"%>
- -This protocol also contains an attached sub-protocol: <%= (value["source_data"]["protocol_name"]) %> + This protocol also contains an attached sub-protocol: <%= (value["source_data"]["protocol_name"]) %>
Author: <%= (value["source_data"]["full_name"]) %> - - <% if value["source_data"]["link"]&&value["source_data"]["link"]!="" %>
+ <% if value["source_data"]["link"]&&value["source_data"]["link"]!="" %> Link: <%= (value["source_data"]["link"]) %> <% end %> <% when "19"%>
- <%= "-"+(value["name"])+" : "+(value["source_data"]["body"]) %> + <%= value["name"]+": " %> <%= value["source_data"]["body"] %>
Link : <%= (value["source_data"]["link"]) %> @@ -244,64 +292,71 @@ <% end #inner whitelist if%> <% end #first step if %> <% end #step component loop %> -


-
-

Manuscript citation

+ +
Manuscript citation
<%= (@json_object["manuscript_citation"]) %> -
-

Publish date

+ +
Publish date
<%= (@json_object["publish_date"]) %> -
-

Vendor name

+ +
Vendor name
<%= (@json_object["vendor_name"]) %> -
-

Vendor link

+ +
Vendor link
<%= (@json_object["vendor_link"]) %> -
-

Keywords

+ +
Keywords
<%= (@json_object["keywords"]) %> -
-

Tags

+ +
Tags
<% @json_object["tags"].each do |tag| %> <%= (tag["tag_name"])+" , " %> <% end %> -
+
-
+