mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2025-02-11 17:36:13 +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|
|
||||
element_string = nil
|
||||
if counter <= 1
|
||||
# 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 hashes, for no good reason
|
||||
key = value if value.class == Hash
|
||||
end
|
||||
|
||||
|
||||
# sometimes there are random index values as keys
|
||||
# instead of hashes, this is a workaround to that buggy json format
|
||||
key = value if value.class == Hash
|
||||
|
||||
if whitelist_simple.include?(key['component_type_id'])
|
||||
|
||||
case key['component_type_id']
|
||||
when '1'
|
||||
|
||||
if !key['data'].nil? && key['data'] != ''
|
||||
element_string = '<br>' + (key['data']) + '<br>'
|
||||
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
|
||||
end
|
||||
else
|
||||
@import_object['steps'][step_pos.to_s]['description'] ||= 'Description missing!'
|
||||
|
||||
@import_object['steps'][step_pos.to_s]['description'] = 'Description missing!'
|
||||
end
|
||||
when '6'
|
||||
if !key['data'].nil? && key['data'] != ''
|
||||
|
|
|
@ -121,11 +121,11 @@ CGI.parse(URI.parse(request.referrer).query).fetch("type") %>
|
|||
<% title=nil %>
|
||||
<% step["components"].each do |key1,value1| #finding section (title of step) %>
|
||||
|
||||
<% if counter <=1 %>
|
||||
|
||||
<% if value1.class==Hash %>
|
||||
<% key1=value1 %>
|
||||
<% end %>
|
||||
<% end %>
|
||||
|
||||
<% if(key1["component_type_id"]=="6") %>
|
||||
<% if(!key1["data"].nil? && 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">
|
||||
|
||||
<% 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 index values as keys instead of
|
||||
hashes, you might see this elsewhere %>
|
||||
<% if value.class==Hash %>
|
||||
<% key=value %>
|
||||
<% end %>
|
||||
<% end %>
|
||||
|
||||
<% # 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"] %>
|
||||
<br>
|
||||
|
|
Loading…
Reference in a new issue