Code refactor part 1

This commit is contained in:
Zanz2 2017-12-02 00:29:47 +01:00
parent 205d3b3d8f
commit 835ac6910f
4 changed files with 382 additions and 446 deletions

View file

@ -968,296 +968,6 @@ class ProtocolsController < ApplicationController
return false
end
# pio_stp_x means protocols io step (id of component) parser
def pio_stp_1(iterating_key) # protocols io description parser
br = '<br>'
append =
if iterating_key.present?
br +
pio_eval_len(
sanitize_input(iterating_key),
ProtocolsIoHelper::PIO_ELEMENT_RESERVED_LENGTH_SMALL
) +
br
else
t('protocols.protocols_io_import.comp_append.missing_desc')
end
append
end
def pio_stp_6(iterating_key) # protocols io section(title) parser
return pio_eval_title_len(sanitize_input(iterating_key)) if iterating_key.present?
t('protocols.protocols_io_import.comp_append.missing_step')
end
def pio_stp_17(iterating_key) # protocols io expected result parser
if iterating_key.present?
append =
t('protocols.protocols_io_import.comp_append.expected_result') +
pio_eval_len(
sanitize_input(iterating_key),
ProtocolsIoHelper::PIO_ELEMENT_RESERVED_LENGTH_SMALL
) +
'<br>'
return append
end
''
end
def pio_stp_8(iterating_key) # protocols io software package parser
if iterating_key['name'] &&
iterating_key['developer'] &&
iterating_key['version'] &&
iterating_key['link'] &&
iterating_key['repository'] &&
iterating_key['os_name'] &&
iterating_key['os_version']
append = t('protocols.protocols_io_import.comp_append.soft_packg.title') +
pio_eval_len(
sanitize_input(iterating_key['name']),
ProtocolsIoHelper::PIO_ELEMENT_RESERVED_LENGTH_SMALL
) +
t('protocols.protocols_io_import.comp_append.soft_packg.dev') +
pio_eval_len(
sanitize_input(iterating_key['developer']),
ProtocolsIoHelper::PIO_ELEMENT_RESERVED_LENGTH_SMALL
) +
t('protocols.protocols_io_import.comp_append.soft_packg.vers') +
pio_eval_len(
sanitize_input(iterating_key['version']),
ProtocolsIoHelper::PIO_ELEMENT_RESERVED_LENGTH_SMALL
) +
t('protocols.protocols_io_import.comp_append.general_link') +
pio_eval_len(
sanitize_input(iterating_key['link']),
ProtocolsIoHelper::PIO_ELEMENT_RESERVED_LENGTH_SMALL
) +
t('protocols.protocols_io_import.comp_append.soft_packg.repo') +
pio_eval_len(
sanitize_input(iterating_key['repository']),
ProtocolsIoHelper::PIO_ELEMENT_RESERVED_LENGTH_SMALL
) +
t('protocols.protocols_io_import.comp_append.soft_packg.os') +
pio_eval_len(
sanitize_input(iterating_key['os_name']),
ProtocolsIoHelper::PIO_ELEMENT_RESERVED_LENGTH_SMALL
) + ' , ' +
pio_eval_len(
sanitize_input(iterating_key['os_version']),
ProtocolsIoHelper::PIO_ELEMENT_RESERVED_LENGTH_SMALL
)
return append
end
''
end
def pio_stp_9(iterating_key) # protocols io dataset parser
if iterating_key['name'].present? &&
iterating_key['link']
append = t('protocols.protocols_io_import.comp_append.dataset.title') +
pio_eval_len(
sanitize_input(iterating_key['name']),
ProtocolsIoHelper::PIO_ELEMENT_RESERVED_LENGTH_SMALL
) +
t('protocols.protocols_io_import.comp_append.general_link') +
pio_eval_len(
sanitize_input(iterating_key['link']),
ProtocolsIoHelper::PIO_ELEMENT_RESERVED_LENGTH_SMALL
)
return append
end
''
end
def pio_stp_15(iterating_key) # protocols io commands parser
if iterating_key['name'].present? &&
iterating_key['description'] &&
iterating_key['os_name'] &&
iterating_key['os_version']
append = t('protocols.protocols_io_import.comp_append.command.title') +
pio_eval_len(
sanitize_input(iterating_key['name']),
ProtocolsIoHelper::PIO_ELEMENT_RESERVED_LENGTH_SMALL
) +
t('protocols.protocols_io_import.comp_append.command.desc') +
pio_eval_len(
sanitize_input(iterating_key['description']),
ProtocolsIoHelper::PIO_ELEMENT_RESERVED_LENGTH_SMALL
) +
t('protocols.protocols_io_import.comp_append.command.os') +
pio_eval_len(
sanitize_input(iterating_key['os_name']),
ProtocolsIoHelper::PIO_ELEMENT_RESERVED_LENGTH_SMALL
) +
' , ' +
pio_eval_len(
sanitize_input(iterating_key['os_version']),
ProtocolsIoHelper::PIO_ELEMENT_RESERVED_LENGTH_SMALL
)
return append
end
''
end
def pio_stp_18(iterating_key) # protocols io sub protocol parser
if iterating_key['protocol_name'].present? &&
iterating_key['full_name'] &&
iterating_key['link']
append =
t(
'protocols.protocols_io_import.comp_append.sub_protocol.title'
) +
pio_eval_len(
sanitize_input(iterating_key['protocol_name']),
ProtocolsIoHelper::PIO_ELEMENT_RESERVED_LENGTH_SMALL
) +
t(
'protocols.protocols_io_import.comp_append.sub_protocol.author'
) +
pio_eval_len(
sanitize_input(iterating_key['full_name']),
ProtocolsIoHelper::PIO_ELEMENT_RESERVED_LENGTH_SMALL
) +
t('protocols.protocols_io_import.comp_append.general_link') +
pio_eval_len(
sanitize_input(iterating_key['link']),
ProtocolsIoHelper::PIO_ELEMENT_RESERVED_LENGTH_SMALL
)
return append
end
''
end
def pio_stp_19(iterating_key) # protocols io safety information parser
if iterating_key['body'].present? &&
iterating_key['link']
append =
t(
'protocols.protocols_io_import.comp_append.safety_infor.title'
) +
pio_eval_len(
sanitize_input(iterating_key['body']),
ProtocolsIoHelper::PIO_ELEMENT_RESERVED_LENGTH_SMALL
) +
t('protocols.protocols_io_import.comp_append.general_link') +
pio_eval_len(
sanitize_input(iterating_key['link']),
ProtocolsIoHelper::PIO_ELEMENT_RESERVED_LENGTH_SMALL
)
return append
end
''
end
def protocols_io_fill_desc(json_hash)
description_array = %w[
( before_start warning guidelines manuscript_citation publish_date
vendor_name vendor_link keywords tags link created_on )
]
description_string =
if json_hash['description'].present?
'<strong>' + t('protocols.protocols_io_import.preview.prot_desc') +
'</strong>' + pio_eval_len(
sanitize_input(json_hash['description']),
ProtocolsIoHelper::PIO_ELEMENT_RESERVED_LENGTH_MEDIUM
).html_safe
else
'<strong>' + t('protocols.protocols_io_import.preview.prot_desc') +
'</strong>' + t('protocols.protocols_io_import.comp_append.missing_desc')
end
description_string += '<br>'
description_array.each do |e|
if e == 'created_on' && json_hash[e].present?
new_e = '<strong>' + e.humanize + '</strong>'
description_string +=
new_e.to_s + ': ' + pio_eval_len(
sanitize_input(params['protocol']['created_at'].to_s),
ProtocolsIoHelper::PIO_ELEMENT_RESERVED_LENGTH_SMALL
) + '<br>'
elsif e == 'tags' && json_hash[e].any? && json_hash[e] != ''
new_e = '<strong>' + e.humanize + '</strong>'
description_string +=
new_e.to_s + ': '
tags_length_checker = ''
json_hash[e].each do |tag|
tags_length_checker +=
sanitize_input(tag['tag_name']) + ' , '
end
description_string += pio_eval_len(
tags_length_checker,
ProtocolsIoHelper::PIO_ELEMENT_RESERVED_LENGTH_MEDIUM
)
description_string += '<br>'
elsif json_hash[e].present?
new_e = '<strong>' + e.humanize + '</strong>'
description_string +=
new_e.to_s + ': ' +
pio_eval_prot_desc(
sanitize_input(json_hash[e]),
e
).html_safe + '<br>'
end
end
description_string
end
def protocols_io_fill_step(original_json, newj)
# newj = new json
# (simple to map) id 1= step description, id 6= section (title),
# id 17= expected result
# (complex mapping with nested hashes) id 8 = software package,
# id 9 = dataset, id 15 = command, id 18 = attached sub protocol
# id 19= safety information ,
# id 20= regents (materials, like scinote samples kind of)
newj['0'] = {}
newj['0']['position'] = 0
newj['0']['name'] = 'Protocol info'
@remaining = ProtocolsIoHelper::PIO_P_AVAILABLE_LENGTH
newj['0']['tables'], table_str = protocolsio_string_to_table_element(
sanitize_input(protocols_io_fill_desc(original_json).html_safe)
)
newj['0']['description'] = table_str
original_json['steps'].each_with_index do |step, pos_orig| # loop over steps
i = pos_orig + 1
@remaining = ProtocolsIoHelper::PIO_S_AVAILABLE_LENGTH
# position of step (first, second.... etc),
newj[i.to_s] = {} # the json we will insert into db
newj[i.to_s]['position'] = i
newj[i.to_s]['description'] = '' unless newj[i.to_s].key?('description')
newj[i.to_s]['name'] = '' unless newj[i.to_s].key?('name')
step['components'].each do |key, value|
# 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
# append is the string that we append values into for description
# pio_stp_x means protocols io step (id of component) parser
case key['component_type_id']
when '1'
newj[i.to_s]['description'] += pio_stp_1(key['data'])
when '6'
newj[i.to_s]['name'] = pio_stp_6(key['data'])
when '17'
newj[i.to_s]['description'] += pio_stp_17(key['data'])
when '8'
newj[i.to_s]['description'] += pio_stp_8(key['source_data'])
when '9'
newj[i.to_s]['description'] += pio_stp_9(key['source_data'])
when '15'
newj[i.to_s]['description'] += pio_stp_15(key['source_data'])
when '18'
newj[i.to_s]['description'] += pio_stp_18(key['source_data'])
when '19'
newj[i.to_s]['description'] += pio_stp_19(key['source_data'])
end # case end
end # finished looping over step components
newj[i.to_s]['tables'], table_str = protocolsio_string_to_table_element(
newj[i.to_s]['description']
)
newj[i.to_s]['description'] = table_str
end # steps
newj
end
def move_protocol(action)
rollbacked = false
results = []

View file

@ -145,4 +145,316 @@ module ProtocolsIoHelper
def close_open_html_tags(text)
Nokogiri::HTML::DocumentFragment.parse(text).to_html
end
def prepare_for_view(attribute_text, size)
case(size)
when 'small'
pio_eval_len(
sanitize_input(string_html_table_remove(not_null(attribute_text))),
ProtocolsIoHelper::PIO_ELEMENT_RESERVED_LENGTH_SMALL
)
when 'medium'
pio_eval_len(
sanitize_input(string_html_table_remove(not_null(attribute_text))),
ProtocolsIoHelper::PIO_ELEMENT_RESERVED_LENGTH_MEDIUM
)
when 'big'
pio_eval_len(
sanitize_input(string_html_table_remove(not_null(attribute_text))),
ProtocolsIoHelper::PIO_ELEMENT_RESERVED_LENGTH_BIG
)
else
end
end
# pio_stp_x means protocols io step (id of component) parser
def pio_stp_1(iterating_key) # protocols io description parser
br = '<br>'
append =
if iterating_key.present?
br +
pio_eval_len(
sanitize_input(iterating_key),
ProtocolsIoHelper::PIO_ELEMENT_RESERVED_LENGTH_SMALL
) +
br
else
t('protocols.protocols_io_import.comp_append.missing_desc')
end
append
end
def pio_stp_6(iterating_key) # protocols io section(title) parser
return pio_eval_title_len(sanitize_input(iterating_key)) if iterating_key.present?
t('protocols.protocols_io_import.comp_append.missing_step')
end
def pio_stp_17(iterating_key) # protocols io expected result parser
if iterating_key.present?
append =
t('protocols.protocols_io_import.comp_append.expected_result') +
pio_eval_len(
sanitize_input(iterating_key),
ProtocolsIoHelper::PIO_ELEMENT_RESERVED_LENGTH_SMALL
) +
'<br>'
return append
end
''
end
def pio_stp_8(iterating_key) # protocols io software package parser
if iterating_key['name'] &&
iterating_key['developer'] &&
iterating_key['version'] &&
iterating_key['link'] &&
iterating_key['repository'] &&
iterating_key['os_name'] &&
iterating_key['os_version']
append = t('protocols.protocols_io_import.comp_append.soft_packg.title') +
pio_eval_len(
sanitize_input(iterating_key['name']),
ProtocolsIoHelper::PIO_ELEMENT_RESERVED_LENGTH_SMALL
) +
t('protocols.protocols_io_import.comp_append.soft_packg.dev') +
pio_eval_len(
sanitize_input(iterating_key['developer']),
ProtocolsIoHelper::PIO_ELEMENT_RESERVED_LENGTH_SMALL
) +
t('protocols.protocols_io_import.comp_append.soft_packg.vers') +
pio_eval_len(
sanitize_input(iterating_key['version']),
ProtocolsIoHelper::PIO_ELEMENT_RESERVED_LENGTH_SMALL
) +
t('protocols.protocols_io_import.comp_append.general_link') +
pio_eval_len(
sanitize_input(iterating_key['link']),
ProtocolsIoHelper::PIO_ELEMENT_RESERVED_LENGTH_SMALL
) +
t('protocols.protocols_io_import.comp_append.soft_packg.repo') +
pio_eval_len(
sanitize_input(iterating_key['repository']),
ProtocolsIoHelper::PIO_ELEMENT_RESERVED_LENGTH_SMALL
) +
t('protocols.protocols_io_import.comp_append.soft_packg.os') +
pio_eval_len(
sanitize_input(iterating_key['os_name']),
ProtocolsIoHelper::PIO_ELEMENT_RESERVED_LENGTH_SMALL
) + ' , ' +
pio_eval_len(
sanitize_input(iterating_key['os_version']),
ProtocolsIoHelper::PIO_ELEMENT_RESERVED_LENGTH_SMALL
)
return append
end
''
end
def pio_stp_9(iterating_key) # protocols io dataset parser
if iterating_key['name'].present? &&
iterating_key['link']
append = t('protocols.protocols_io_import.comp_append.dataset.title') +
pio_eval_len(
sanitize_input(iterating_key['name']),
ProtocolsIoHelper::PIO_ELEMENT_RESERVED_LENGTH_SMALL
) +
t('protocols.protocols_io_import.comp_append.general_link') +
pio_eval_len(
sanitize_input(iterating_key['link']),
ProtocolsIoHelper::PIO_ELEMENT_RESERVED_LENGTH_SMALL
)
return append
end
''
end
def pio_stp_15(iterating_key) # protocols io commands parser
if iterating_key['name'].present? &&
iterating_key['description'] &&
iterating_key['os_name'] &&
iterating_key['os_version']
append = t('protocols.protocols_io_import.comp_append.command.title') +
pio_eval_len(
sanitize_input(iterating_key['name']),
ProtocolsIoHelper::PIO_ELEMENT_RESERVED_LENGTH_SMALL
) +
t('protocols.protocols_io_import.comp_append.command.desc') +
pio_eval_len(
sanitize_input(iterating_key['description']),
ProtocolsIoHelper::PIO_ELEMENT_RESERVED_LENGTH_SMALL
) +
t('protocols.protocols_io_import.comp_append.command.os') +
pio_eval_len(
sanitize_input(iterating_key['os_name']),
ProtocolsIoHelper::PIO_ELEMENT_RESERVED_LENGTH_SMALL
) +
' , ' +
pio_eval_len(
sanitize_input(iterating_key['os_version']),
ProtocolsIoHelper::PIO_ELEMENT_RESERVED_LENGTH_SMALL
)
return append
end
''
end
def pio_stp_18(iterating_key) # protocols io sub protocol parser
if iterating_key['protocol_name'].present? &&
iterating_key['full_name'] &&
iterating_key['link']
append =
t(
'protocols.protocols_io_import.comp_append.sub_protocol.title'
) +
pio_eval_len(
sanitize_input(iterating_key['protocol_name']),
ProtocolsIoHelper::PIO_ELEMENT_RESERVED_LENGTH_SMALL
) +
t(
'protocols.protocols_io_import.comp_append.sub_protocol.author'
) +
pio_eval_len(
sanitize_input(iterating_key['full_name']),
ProtocolsIoHelper::PIO_ELEMENT_RESERVED_LENGTH_SMALL
) +
t('protocols.protocols_io_import.comp_append.general_link') +
pio_eval_len(
sanitize_input(iterating_key['link']),
ProtocolsIoHelper::PIO_ELEMENT_RESERVED_LENGTH_SMALL
)
return append
end
''
end
def pio_stp_19(iterating_key) # protocols io safety information parser
if iterating_key['body'].present? &&
iterating_key['link']
append =
t(
'protocols.protocols_io_import.comp_append.safety_infor.title'
) +
pio_eval_len(
sanitize_input(iterating_key['body']),
ProtocolsIoHelper::PIO_ELEMENT_RESERVED_LENGTH_SMALL
) +
t('protocols.protocols_io_import.comp_append.general_link') +
pio_eval_len(
sanitize_input(iterating_key['link']),
ProtocolsIoHelper::PIO_ELEMENT_RESERVED_LENGTH_SMALL
)
return append
end
''
end
def protocols_io_fill_desc(json_hash)
description_array = %w[
( before_start warning guidelines manuscript_citation publish_date
vendor_name vendor_link keywords tags link created_on )
]
description_string =
if json_hash['description'].present?
'<strong>' + t('protocols.protocols_io_import.preview.prot_desc') +
'</strong>' + pio_eval_len(
sanitize_input(json_hash['description']),
ProtocolsIoHelper::PIO_ELEMENT_RESERVED_LENGTH_MEDIUM
).html_safe
else
'<strong>' + t('protocols.protocols_io_import.preview.prot_desc') +
'</strong>' + t('protocols.protocols_io_import.comp_append.missing_desc')
end
description_string += '<br>'
description_array.each do |e|
if e == 'created_on' && json_hash[e].present?
new_e = '<strong>' + e.humanize + '</strong>'
description_string +=
new_e.to_s + ': ' + pio_eval_len(
sanitize_input(params['protocol']['created_at'].to_s),
ProtocolsIoHelper::PIO_ELEMENT_RESERVED_LENGTH_SMALL
) + '<br>'
elsif e == 'tags' && json_hash[e].any? && json_hash[e] != ''
new_e = '<strong>' + e.humanize + '</strong>'
description_string +=
new_e.to_s + ': '
tags_length_checker = ''
json_hash[e].each do |tag|
tags_length_checker +=
sanitize_input(tag['tag_name']) + ' , '
end
description_string += pio_eval_len(
tags_length_checker,
ProtocolsIoHelper::PIO_ELEMENT_RESERVED_LENGTH_MEDIUM
)
description_string += '<br>'
elsif json_hash[e].present?
new_e = '<strong>' + e.humanize + '</strong>'
description_string +=
new_e.to_s + ': ' +
pio_eval_prot_desc(
sanitize_input(json_hash[e]),
e
).html_safe + '<br>'
end
end
description_string
end
def protocols_io_fill_step(original_json, newj)
# newj = new json
# (simple to map) id 1= step description, id 6= section (title),
# id 17= expected result
# (complex mapping with nested hashes) id 8 = software package,
# id 9 = dataset, id 15 = command, id 18 = attached sub protocol
# id 19= safety information ,
# id 20= regents (materials, like scinote samples kind of)
newj['0'] = {}
newj['0']['position'] = 0
newj['0']['name'] = 'Protocol info'
@remaining = ProtocolsIoHelper::PIO_P_AVAILABLE_LENGTH
newj['0']['tables'], table_str = protocolsio_string_to_table_element(
sanitize_input(protocols_io_fill_desc(original_json).html_safe)
)
newj['0']['description'] = table_str
original_json['steps'].each_with_index do |step, pos_orig| # loop over steps
i = pos_orig + 1
@remaining = ProtocolsIoHelper::PIO_S_AVAILABLE_LENGTH
# position of step (first, second.... etc),
newj[i.to_s] = {} # the json we will insert into db
newj[i.to_s]['position'] = i
newj[i.to_s]['description'] = '' unless newj[i.to_s].key?('description')
newj[i.to_s]['name'] = '' unless newj[i.to_s].key?('name')
step['components'].each do |key, value|
# 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
# append is the string that we append values into for description
# pio_stp_x means protocols io step (id of component) parser
case key['component_type_id']
when '1'
newj[i.to_s]['description'] += pio_stp_1(key['data'])
when '6'
newj[i.to_s]['name'] = pio_stp_6(key['data'])
when '17'
newj[i.to_s]['description'] += pio_stp_17(key['data'])
when '8'
newj[i.to_s]['description'] += pio_stp_8(key['source_data'])
when '9'
newj[i.to_s]['description'] += pio_stp_9(key['source_data'])
when '15'
newj[i.to_s]['description'] += pio_stp_15(key['source_data'])
when '18'
newj[i.to_s]['description'] += pio_stp_18(key['source_data'])
when '19'
newj[i.to_s]['description'] += pio_stp_19(key['source_data'])
end # case end
end # finished looping over step components
newj[i.to_s]['tables'], table_str = protocolsio_string_to_table_element(
newj[i.to_s]['description']
)
newj[i.to_s]['description'] = table_str
end # steps
newj
end
end

View file

@ -22,78 +22,52 @@
<% if json_object['description'].present? %>
<% prot_info_string += (json_object['description']) %>
<strong><%= t('protocols.protocols_io_import.preview.prot_desc') %></strong>
<% description = pio_eval_len(
sanitize_input(string_html_table_remove(json_object['description'])),
ProtocolsIoHelper::PIO_ELEMENT_RESERVED_LENGTH_MEDIUM) %>
<%= description.html_safe %><br>
<%= prepare_for_view(json_object['description'],'medium').html_safe %>
<br>
<% end %>
<% if json_object['before_start'].present? %>
<% prot_info_string += (json_object['before_start']) %>
<strong><%= t('protocols.protocols_io_import.preview.b_s_p') %></strong>
<% before_start = pio_eval_len(
sanitize_input(string_html_table_remove(json_object['before_start'])),
ProtocolsIoHelper::PIO_ELEMENT_RESERVED_LENGTH_MEDIUM
) %>
<%= before_start.html_safe %><br>
<%= prepare_for_view(json_object['before_start'],'medium').html_safe %>
<br>
<% end %>
<% if json_object['warning'].present? %>
<% prot_info_string += (json_object['warning']) %>
<strong><%= t('protocols.protocols_io_import.preview.warn') %></strong>
<% sft_warning = pio_eval_len(
sanitize_input(string_html_table_remove(json_object['warning'])),
ProtocolsIoHelper::PIO_ELEMENT_RESERVED_LENGTH_MEDIUM
) %>
<%= sft_warning.html_safe%><br>
<%= prepare_for_view(json_object['warning'],'medium').html_safe %>
<br>
<% end %>
<% if json_object['guidelines'].present? %>
<% prot_info_string += (json_object['guidelines']) %>
<strong><%= t('protocols.protocols_io_import.preview.guideln') %></strong>
<% guidelines = pio_eval_len(
sanitize_input(string_html_table_remove(json_object['guidelines'])),
ProtocolsIoHelper::PIO_ELEMENT_RESERVED_LENGTH_MEDIUM
) %>
<%= guidelines.html_safe %><br>
<%= prepare_for_view(json_object['guidelines'],'medium').html_safe %>
<br>
<% end %>
<% if json_object['manuscript_citation'].present? %>
<% prot_info_string += (json_object['manuscript_citation']) %>
<strong><%= t('protocols.protocols_io_import.preview.manu_cit') %></strong>
<% manu_cit = pio_eval_len(
sanitize_input(string_html_table_remove(json_object['manuscript_citation'])),
ProtocolsIoHelper::PIO_ELEMENT_RESERVED_LENGTH_MEDIUM
) %>
<%= manu_cit.html_safe %><br>
<%= prepare_for_view(json_object['manuscript_citation'],'medium').html_safe %>
<br>
<% end %>
<% if json_object['publish_date'].present? %>
<strong><%= t('protocols.protocols_io_import.preview.pbl_date') %></strong>
<% pbl_date = pio_eval_len(
sanitize_input(json_object['publish_date']),
ProtocolsIoHelper::PIO_ELEMENT_RESERVED_LENGTH_SMALL
) %>
<%= pbl_date.html_safe %><br>
<%= prepare_for_view(json_object['publish_date'],'small').html_safe %>
<br>
<% end %>
<% if json_object['vendor_name'].present? %>
<strong><%= t('protocols.protocols_io_import.preview.vnd_name') %></strong>
<% vnd_name = pio_eval_len(
sanitize_input(json_object['vendor_name']),
ProtocolsIoHelper::PIO_ELEMENT_RESERVED_LENGTH_MEDIUM
) %>
<%= vnd_name.html_safe %><br>
<%= prepare_for_view(json_object['vendor_name'],'medium').html_safe %>
<br>
<% end %>
<% if json_object['vendor_link'].present? %>
<strong><%= t('protocols.protocols_io_import.preview.vnd_link') %></strong>
<% vnd_link = pio_eval_len(
sanitize_input(json_object['vendor_link']),
ProtocolsIoHelper::PIO_ELEMENT_RESERVED_LENGTH_BIG
) %>
<%= vnd_link.html_safe %><br>
<%= prepare_for_view(json_object['vendor_link'],'big').html_safe %>
<br>
<% end %>
<% if json_object['keywords'].present? %>
<strong><%= t('protocols.protocols_io_import.preview.key_wrd') %></strong>
<% keywords = pio_eval_len(
sanitize_input(json_object['keywords']),
ProtocolsIoHelper::PIO_ELEMENT_RESERVED_LENGTH_MEDIUM
) %>
<%= keywords.html_safe %><br>
<%= prepare_for_view(json_object['keywords'],'medium').html_safe %>
<br>
<% end %>
<% if json_object['tags'].present? %>
<strong><%= t('protocols.protocols_io_import.preview.tags') %></strong>
@ -101,19 +75,13 @@
<% json_object['tags'].each do |tag| %>
<% string_of_tags += tag['tag_name']+' , ' %>
<% end %>
<% tags = pio_eval_len(
sanitize_input(string_of_tags),
ProtocolsIoHelper::PIO_ELEMENT_RESERVED_LENGTH_MEDIUM
)%>
<%= tags.html_safe %><br>
<%= prepare_for_view(string_of_tags,'medium').html_safe %>
<br>
<% end %>
<% if json_object['link'].present? %>
<strong><%= t('protocols.protocols_io_import.preview.p_link') %></strong>
<% link = pio_eval_len(
sanitize_input(json_object['link']).html_safe,
ProtocolsIoHelper::PIO_ELEMENT_RESERVED_LENGTH_BIG
) %>
<%= link.html_safe %><br>
<%= prepare_for_view(json_object['link'],'big').html_safe %>
<br>
<% end %>
<% tables, garbage = protocolsio_string_to_table_element(prot_info_string) %>
<% if tables.present? %>

View file

@ -41,20 +41,15 @@
<% case key['component_type_id']
when '1' %>
<% step_info_string += (key['data']) %>
<br><strong><%= t('protocols.protocols_io_import.preview.strng_s_desc') %></strong>
<% s_desc = pio_eval_len(
sanitize_input(string_html_table_remove(key['data'])),
ProtocolsIoHelper::PIO_ELEMENT_RESERVED_LENGTH_SMALL
)%>
<%= s_desc.html_safe %><br>
<br>
<strong><%= t('protocols.protocols_io_import.preview.strng_s_desc') %></strong>
<%= prepare_for_view(key['data'],'small').html_safe %>
<br>
<% when '17' %>
<% step_info_string += (key['data']) %>
<br><strong><%= t('protocols.protocols_io_import.preview.s_exp_res') %></strong>
<% s_exp_res = pio_eval_len(
sanitize_input(string_html_table_remove(key['data'])),
ProtocolsIoHelper::PIO_ELEMENT_RESERVED_LENGTH_SMALL
)%>
<%= s_exp_res.html_safe %>
<br>
<strong><%= t('protocols.protocols_io_import.preview.s_exp_res') %></strong>
<%= prepare_for_view(key['data'],'small').html_safe %>
<br>
<% end %>
<% elsif key && whitelist_complex.include?(key['component_type_id']) %>
@ -63,112 +58,63 @@
<% step_info_string += not_null(key['source_data']['name']) %>
<br>
<strong><%= not_null(key['name'])+': ' %></strong>
<%= pio_eval_len(
sanitize_input(string_html_table_remove(not_null(key['source_data']['name'])).html_safe),
ProtocolsIoHelper::PIO_ELEMENT_RESERVED_LENGTH_SMALL
).html_safe %>
<br><%= t('protocols.protocols_io_import.preview.dev') %>
<%= pio_eval_len(
sanitize_input(not_null(key['source_data']['developer']).html_safe),
ProtocolsIoHelper::PIO_ELEMENT_RESERVED_LENGTH_SMALL
).html_safe %>
<br><%= t('protocols.protocols_io_import.preview.vers') %>
<%= pio_eval_len(
sanitize_input(not_null(key['source_data']['version']).html_safe),
ProtocolsIoHelper::PIO_ELEMENT_RESERVED_LENGTH_SMALL
).html_safe %>
<br><%= t('protocols.protocols_io_import.preview.s_link') %>
<%= pio_eval_len(
sanitize_input(not_null(key['source_data']['link']).html_safe),
ProtocolsIoHelper::PIO_ELEMENT_RESERVED_LENGTH_SMALL
).html_safe %>
<br><%= t('protocols.protocols_io_import.preview.repo') %>
<%= pio_eval_len(
sanitize_input(not_null(key['source_data']['repository']).html_safe),
ProtocolsIoHelper::PIO_ELEMENT_RESERVED_LENGTH_SMALL
).html_safe %>
<br><%= t('protocols.protocols_io_import.preview.os') %>
<%= pio_eval_len(
sanitize_input(not_null(key['source_data']['os_name']).html_safe),
ProtocolsIoHelper::PIO_ELEMENT_RESERVED_LENGTH_SMALL
).html_safe+
' , '+
pio_eval_len(
sanitize_input(not_null(key['source_data']['os_version']).html_safe),
ProtocolsIoHelper::PIO_ELEMENT_RESERVED_LENGTH_SMALL
).html_safe %>
<%= prepare_for_view(key['source_data']['name'],'small').html_safe %>
<br>
<%= t('protocols.protocols_io_import.preview.dev') %>
<%= prepare_for_view(key['source_data']['developer'],'small').html_safe %>
<br>
<%= t('protocols.protocols_io_import.preview.vers') %>
<%= prepare_for_view(key['source_data']['version'],'small').html_safe %>
<br>
<%= t('protocols.protocols_io_import.preview.s_link') %>
<%= prepare_for_view(key['source_data']['link'],'small').html_safe %>
<br>
<%= t('protocols.protocols_io_import.preview.repo') %>
<%= prepare_for_view(key['source_data']['repository'],'small').html_safe %>
<br>
<%= t('protocols.protocols_io_import.preview.os') %>
<%= prepare_for_view(key['source_data']['os_name'],'small').html_safe + ' , ' +
prepare_for_view(key['source_data']['os_version'],'small').html_safe %>
<% when '9'%>
<% step_info_string += not_null(key['source_data']['name']) %>
<br>
<strong><%= not_null(key['name'])+': ' %></strong>
<%= pio_eval_len(
sanitize_input(string_html_table_remove(not_null(key['source_data']['name'])).html_safe),
ProtocolsIoHelper::PIO_ELEMENT_RESERVED_LENGTH_SMALL
).html_safe %>
<br><%= t('protocols.protocols_io_import.preview.s_link') %>
<%= pio_eval_len(
sanitize_input(not_null(key['source_data']['link']).html_safe),
ProtocolsIoHelper::PIO_ELEMENT_RESERVED_LENGTH_SMALL
).html_safe %>
<%= prepare_for_view(key['source_data']['name'],'small').html_safe %>
<br>
<%= t('protocols.protocols_io_import.preview.s_link') %>
<%= prepare_for_view(key['source_data']['link'],'small').html_safe %>
<% when '15'%>
<% step_info_string += not_null(key['source_data']['description']) %>
<br>
<strong><%= key['name']+': ' %></strong>
<% s_cmd = pio_eval_len(
sanitize_input(not_null(key['source_data']['name'])),
ProtocolsIoHelper::PIO_ELEMENT_RESERVED_LENGTH_SMALL
) %>
<%= s_cmd.html_safe %>
<br><%= t('protocols.protocols_io_import.preview.s_desc') %>
<% s_cmd_desc = pio_eval_len(
sanitize_input(string_html_table_remove(not_null(key['source_data']['description']))),
ProtocolsIoHelper::PIO_ELEMENT_RESERVED_LENGTH_SMALL
) %>
<% s_cmd_desc.html_safe %>
<br><%= t('protocols.protocols_io_import.preview.os') %>
<%= pio_eval_len(
sanitize_input(not_null(key['source_data']['os_name']).html_safe),
ProtocolsIoHelper::PIO_ELEMENT_RESERVED_LENGTH_SMALL
).html_safe +
' , '+
pio_eval_len(
sanitize_input(not_null(key['source_data']['os_version']).html_safe),
ProtocolsIoHelper::PIO_ELEMENT_RESERVED_LENGTH_SMALL
).html_safe %>
<%= prepare_for_view(key['source_data']['name'],'small').html_safe %>
<br>
<%= t('protocols.protocols_io_import.preview.s_desc') %>
<%= prepare_for_view(key['source_data']['description'],'small').html_safe %>
<br>
<%= t('protocols.protocols_io_import.preview.os') %>
<%= prepare_for_view(key['source_data']['os_name'],'small').html_safe + ' , ' +
prepare_for_view(key['source_data']['os_version'],'small').html_safe %>
<% when '18'%>
<br><strong><%= t('protocols.protocols_io_import.preview.sub_prot') %></strong>
<%= pio_eval_len(
sanitize_input(not_null(key['source_data']['protocol_name']).html_safe),
ProtocolsIoHelper::PIO_ELEMENT_RESERVED_LENGTH_SMALL
).html_safe %>
<br><%= t('protocols.protocols_io_import.preview.auth') %>
<%= pio_eval_len(
sanitize_input(not_null(key['source_data']['full_name']).html_safe),
ProtocolsIoHelper::PIO_ELEMENT_RESERVED_LENGTH_SMALL
).html_safe %>
<br>
<strong><%= t('protocols.protocols_io_import.preview.sub_prot') %></strong>
<%= prepare_for_view(key['source_data']['protocol_name'],'small').html_safe %>
<br>
<%= t('protocols.protocols_io_import.preview.auth') %>
<%= prepare_for_view(key['source_data']['full_name'],'small').html_safe %>
<br>
<% if key['source_data']['link'].present? %>
<%= t('protocols.protocols_io_import.preview.s_nobr_link') %>
<%= pio_eval_len(
sanitize_input(key['source_data']['link'].html_safe),
ProtocolsIoHelper::PIO_ELEMENT_RESERVED_LENGTH_SMALL
).html_safe %>
<%= prepare_for_view(key['source_data']['link'],'small').html_safe %>
<% end %>
<% when '19'%>
<% step_info_string += not_null(key['source_data']['body']) %>
<br>
<strong><%= key['name']+': ' %></strong>
<% s_safety = pio_eval_len(
sanitize_input(string_html_table_remove(not_null(key['source_data']['body']))),
ProtocolsIoHelper::PIO_ELEMENT_RESERVED_LENGTH_SMALL
) %>
<%= s_safety.html_safe %>
<br><%= t('protocols.protocols_io_import.preview.s_link') %>
<%= pio_eval_len(
sanitize_input(not_null(key['source_data']['link']).html_safe),
ProtocolsIoHelper::PIO_ELEMENT_RESERVED_LENGTH_SMALL
).html_safe %>
<% when '20'%>
<strong><%= not_null(key['name'])+': ' %></strong>
<%= prepare_for_view(key['source_data']['body'],'small').html_safe %>
<br>
<%= t('protocols.protocols_io_import.preview.s_link') %>
<%= prepare_for_view(key['source_data']['link'],'small').html_safe %>
<% else %>
<% end #case if%>
<% end #inner if%>