mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2025-02-14 19:04:21 +08:00
Fixed bug, seems like unconssistent indexes instead of hash values can also happen in steps that arent first
This commit is contained in:
parent
11b2ef3112
commit
292c1e3c31
2 changed files with 13 additions and 11 deletions
|
@ -700,16 +700,17 @@ class ProtocolsController < ApplicationController
|
||||||
|
|
||||||
step['components'].each do |key,value|
|
step['components'].each do |key,value|
|
||||||
element_string = nil
|
element_string = nil
|
||||||
if counter <= 1
|
|
||||||
# here i made an if to distinguish the first step from the others,
|
|
||||||
# because the first step
|
# sometimes there are random index values as keys
|
||||||
# sometimes has index values as keys instead of hashes, for no good reason
|
# instead of hashes, this is a workaround to that buggy json format
|
||||||
key = value if value.class == Hash
|
key = value if value.class == Hash
|
||||||
end
|
|
||||||
if whitelist_simple.include?(key['component_type_id'])
|
if whitelist_simple.include?(key['component_type_id'])
|
||||||
|
|
||||||
case key['component_type_id']
|
case key['component_type_id']
|
||||||
when '1'
|
when '1'
|
||||||
|
|
||||||
if !key['data'].nil? && key['data'] != ''
|
if !key['data'].nil? && key['data'] != ''
|
||||||
element_string = '<br>' + (key['data']) + '<br>'
|
element_string = '<br>' + (key['data']) + '<br>'
|
||||||
if @import_object['steps'][step_pos.to_s]['description']
|
if @import_object['steps'][step_pos.to_s]['description']
|
||||||
|
@ -718,7 +719,8 @@ class ProtocolsController < ApplicationController
|
||||||
@import_object['steps'][step_pos.to_s]['description'] = element_string
|
@import_object['steps'][step_pos.to_s]['description'] = element_string
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
@import_object['steps'][step_pos.to_s]['description'] ||= 'Description missing!'
|
|
||||||
|
@import_object['steps'][step_pos.to_s]['description'] = 'Description missing!'
|
||||||
end
|
end
|
||||||
when '6'
|
when '6'
|
||||||
if !key['data'].nil? && key['data'] != ''
|
if !key['data'].nil? && key['data'] != ''
|
||||||
|
|
|
@ -121,11 +121,11 @@ CGI.parse(URI.parse(request.referrer).query).fetch("type") %>
|
||||||
<% title=nil %>
|
<% title=nil %>
|
||||||
<% step["components"].each do |key1,value1| #finding section (title of step) %>
|
<% step["components"].each do |key1,value1| #finding section (title of step) %>
|
||||||
|
|
||||||
<% if counter <=1 %>
|
|
||||||
<% if value1.class==Hash %>
|
<% if value1.class==Hash %>
|
||||||
<% key1=value1 %>
|
<% key1=value1 %>
|
||||||
<% end %>
|
<% end %>
|
||||||
<% end %>
|
|
||||||
<% if(key1["component_type_id"]=="6") %>
|
<% if(key1["component_type_id"]=="6") %>
|
||||||
<% if(!key1["data"].nil? && key1["data"]!="") %>
|
<% if(!key1["data"].nil? && key1["data"]!="") %>
|
||||||
<% title ||=key1["data"] %>
|
<% title ||=key1["data"] %>
|
||||||
|
@ -146,14 +146,14 @@ CGI.parse(URI.parse(request.referrer).query).fetch("type") %>
|
||||||
<div data-val="description" class="ql-editor">
|
<div data-val="description" class="ql-editor">
|
||||||
|
|
||||||
<% step["components"].each do |key,value| %>
|
<% step["components"].each do |key,value| %>
|
||||||
<% if counter<=1 %>
|
|
||||||
<%#here i made an if to distinguish the first step from the
|
<%#here i made an if to distinguish the first step from the
|
||||||
others, because the first step #sometimes has index values as keys instead of
|
others, because the first step #sometimes has index values as keys instead of
|
||||||
hashes, you might see this elsewhere %>
|
hashes, you might see this elsewhere %>
|
||||||
<% if value.class==Hash %>
|
<% if value.class==Hash %>
|
||||||
<% key=value %>
|
<% key=value %>
|
||||||
<% end %>
|
<% end %>
|
||||||
<% end %>
|
|
||||||
<% # the below blocks of code output the various attributes if they exist and arent null or "" from the json object %>
|
<% # the below blocks of code output the various attributes if they exist and arent null or "" from the json object %>
|
||||||
<% if whitelist_simple.include?(key["component_type_id"]) && key["data"]!="" && key["data"] %>
|
<% if whitelist_simple.include?(key["component_type_id"]) && key["data"]!="" && key["data"] %>
|
||||||
<br>
|
<br>
|
||||||
|
|
Loading…
Reference in a new issue