Merge pull request #901 from Zanz2/code_refactor

Protocols.io code beautification and refactoring [SCI-1929]
This commit is contained in:
Zanz2 2018-01-12 12:34:00 +01:00 committed by GitHub
commit b105920d4e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 330 additions and 506 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,231 @@ module ProtocolsIoHelper
def close_open_html_tags(text)
Nokogiri::HTML::DocumentFragment.parse(text).to_html
end
def prepare_for_view(attribute_text1, size, table = 'no_table')
if table == 'no_table'
attribute_text = sanitize_input(not_null(attribute_text1))
elsif table == 'table'
attribute_text = sanitize_input(
string_html_table_remove(not_null(attribute_text1))
)
end
pio_eval_len(
attribute_text,
size
)
end
def fill_attributes(attribute_name, attribute_text, step_component)
output_string = ''
trans_string = step_component
trans_string +=
if attribute_name != 'os_name' && attribute_name != 'os_version'
attribute_name
else
'os'
end
output_string +=
if attribute_name != 'os_version'
t(trans_string)
else
' , '
end
output_string += prepare_for_view(
attribute_text, ProtocolsIoHelper::PIO_ELEMENT_RESERVED_LENGTH_SMALL
)
output_string
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 +
prepare_for_view(
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') +
prepare_for_view(
iterating_key, ProtocolsIoHelper::PIO_ELEMENT_RESERVED_LENGTH_SMALL
) +
'<br>'
return append
end
''
end
# protocols io software package,dataset,commands,sub_protocol and safety_information parser
def pio_stp(iterating_key, parse_elements_array, en_local_text)
append = ''
parse_elements_array.each do |element|
return '' unless iterating_key[element]
append += fill_attributes(
element,
iterating_key[element],
en_local_text
)
end
append
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.description') +
'</strong>' +
prepare_for_view(
json_hash['description'],
ProtocolsIoHelper::PIO_ELEMENT_RESERVED_LENGTH_MEDIUM
).html_safe
else
'<strong>' + t('protocols.protocols_io_import.preview.description') +
'</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 + ': ' +
prepare_for_view(
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 += prepare_for_view(
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'
pe_array = %w(
name developer version link repository os_name os_version
)
trans_text = 'protocols.protocols_io_import.comp_append.soft_packg.'
newj[i.to_s]['description'] += pio_stp(
key['source_data'], pe_array, trans_text
)
when '9'
pe_array = %w(
name link
)
trans_text = 'protocols.protocols_io_import.comp_append.dataset.'
newj[i.to_s]['description'] += pio_stp(
key['source_data'], pe_array, trans_text
)
when '15'
pe_array = %w(
name description os_name os_version
)
trans_text = 'protocols.protocols_io_import.comp_append.command.'
newj[i.to_s]['description'] += pio_stp(
key['source_data'], pe_array, trans_text
)
when '18'
pe_array = %w(
protocol_name full_name link
)
trans_text = 'protocols.protocols_io_import.comp_append.sub_protocol.'
newj[i.to_s]['description'] += pio_stp(
key['source_data'], pe_array, trans_text
)
when '19'
pe_array = %w(
body link
)
trans_text = 'protocols.protocols_io_import.comp_append.safety_infor.'
newj[i.to_s]['description'] += pio_stp(
key['source_data'], pe_array, trans_text
)
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

@ -19,101 +19,38 @@
<% prot_info_string = '' %>
<% @remaining = ProtocolsIoHelper::PIO_P_AVAILABLE_LENGTH %>
<% protocol_table_elements_array = [] %>
<% 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>
<% 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>
<% 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>
<% 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>
<% 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>
<% 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>
<% 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>
<% 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>
<% 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>
<% end %>
<% if json_object['tags'].present? %>
<strong><%= t('protocols.protocols_io_import.preview.tags') %></strong>
<% add_to_info_string_elements = ['description','before_start','warning','guidelines','manuscript_citation']%>
<% protocol_attr_len_hash = {
description: ProtocolsIoHelper::PIO_ELEMENT_RESERVED_LENGTH_MEDIUM,
before_start: ProtocolsIoHelper::PIO_ELEMENT_RESERVED_LENGTH_MEDIUM,
warning: ProtocolsIoHelper::PIO_ELEMENT_RESERVED_LENGTH_MEDIUM,
guidelines: ProtocolsIoHelper::PIO_ELEMENT_RESERVED_LENGTH_MEDIUM,
manuscript_citation: ProtocolsIoHelper::PIO_ELEMENT_RESERVED_LENGTH_MEDIUM,
vendor_name: ProtocolsIoHelper::PIO_ELEMENT_RESERVED_LENGTH_MEDIUM,
keywords: ProtocolsIoHelper::PIO_ELEMENT_RESERVED_LENGTH_MEDIUM,
tags: ProtocolsIoHelper::PIO_ELEMENT_RESERVED_LENGTH_MEDIUM,
publish_date: ProtocolsIoHelper::PIO_ELEMENT_RESERVED_LENGTH_SMALL,
link: ProtocolsIoHelper::PIO_ELEMENT_RESERVED_LENGTH_BIG,
vendor_link: ProtocolsIoHelper::PIO_ELEMENT_RESERVED_LENGTH_BIG } %>
<% protocol_attr_len_hash.each do |element, value|%>
<% element = element.to_s %>
<% if(json_object[element].present?) %>
<% if element == 'tags' %>
<% translation_string = 'protocols.protocols_io_import.preview.' + element %>
<strong><%= t(translation_string) %></strong>
<% string_of_tags='' %>
<% 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, ProtocolsIoHelper::PIO_ELEMENT_RESERVED_LENGTH_MEDIUM,'table').html_safe %>
<% else %>
<% prot_info_string += not_null(json_object[element]) if add_to_info_string_elements.include? element %>
<% translation_string = 'protocols.protocols_io_import.preview.' + element %>
<strong><%= t(translation_string) %></strong>
<%= prepare_for_view(json_object[element],protocol_attr_len_hash[element.to_sym],'table').html_safe %>
<% end %>
<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>
<% 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'],ProtocolsIoHelper::PIO_ELEMENT_RESERVED_LENGTH_SMALL,'table').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'],ProtocolsIoHelper::PIO_ELEMENT_RESERVED_LENGTH_SMALL,'table').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'],ProtocolsIoHelper::PIO_ELEMENT_RESERVED_LENGTH_SMALL,'table').html_safe %>
<br>
<%= t('protocols.protocols_io_import.preview.dev') %>
<%= prepare_for_view(key['source_data']['developer'],ProtocolsIoHelper::PIO_ELEMENT_RESERVED_LENGTH_SMALL,'table').html_safe %>
<br>
<%= t('protocols.protocols_io_import.preview.vers') %>
<%= prepare_for_view(key['source_data']['version'],ProtocolsIoHelper::PIO_ELEMENT_RESERVED_LENGTH_SMALL,'table').html_safe %>
<br>
<%= t('protocols.protocols_io_import.preview.s_link') %>
<%= prepare_for_view(key['source_data']['link'],ProtocolsIoHelper::PIO_ELEMENT_RESERVED_LENGTH_SMALL,'table').html_safe %>
<br>
<%= t('protocols.protocols_io_import.preview.repo') %>
<%= prepare_for_view(key['source_data']['repository'],ProtocolsIoHelper::PIO_ELEMENT_RESERVED_LENGTH_SMALL,'table').html_safe %>
<br>
<%= t('protocols.protocols_io_import.preview.os') %>
<%= prepare_for_view(key['source_data']['os_name'],ProtocolsIoHelper::PIO_ELEMENT_RESERVED_LENGTH_SMALL,'table').html_safe + ' , ' +
prepare_for_view(key['source_data']['os_version'],ProtocolsIoHelper::PIO_ELEMENT_RESERVED_LENGTH_SMALL,'table').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'],ProtocolsIoHelper::PIO_ELEMENT_RESERVED_LENGTH_SMALL,'table').html_safe %>
<br>
<%= t('protocols.protocols_io_import.preview.s_link') %>
<%= prepare_for_view(key['source_data']['link'],ProtocolsIoHelper::PIO_ELEMENT_RESERVED_LENGTH_SMALL,'table').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'],ProtocolsIoHelper::PIO_ELEMENT_RESERVED_LENGTH_SMALL,'table').html_safe %>
<br>
<%= t('protocols.protocols_io_import.preview.s_desc') %>
<%= prepare_for_view(key['source_data']['description'],ProtocolsIoHelper::PIO_ELEMENT_RESERVED_LENGTH_SMALL,'table').html_safe %>
<br>
<%= t('protocols.protocols_io_import.preview.os') %>
<%= prepare_for_view(key['source_data']['os_name'],ProtocolsIoHelper::PIO_ELEMENT_RESERVED_LENGTH_SMALL,'table').html_safe + ' , ' +
prepare_for_view(key['source_data']['os_version'],ProtocolsIoHelper::PIO_ELEMENT_RESERVED_LENGTH_SMALL,'table').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'],ProtocolsIoHelper::PIO_ELEMENT_RESERVED_LENGTH_SMALL,'table').html_safe %>
<br>
<%= t('protocols.protocols_io_import.preview.auth') %>
<%= prepare_for_view(key['source_data']['full_name'],ProtocolsIoHelper::PIO_ELEMENT_RESERVED_LENGTH_SMALL,'table').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'],ProtocolsIoHelper::PIO_ELEMENT_RESERVED_LENGTH_SMALL,'table').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'],ProtocolsIoHelper::PIO_ELEMENT_RESERVED_LENGTH_SMALL,'table').html_safe %>
<br>
<%= t('protocols.protocols_io_import.preview.s_link') %>
<%= prepare_for_view(key['source_data']['link'],ProtocolsIoHelper::PIO_ELEMENT_RESERVED_LENGTH_SMALL,'table').html_safe %>
<% else %>
<% end #case if%>
<% end #inner if%>

View file

@ -1389,11 +1389,11 @@ en:
too_long: "... <span class='label label-warning'>Text is too long so we had to cut it off.</span>"
import_description_notice: "The protocols description is listed below under \"Protocol info\"."
preview:
prot_desc: "Protocol Description: "
b_s_p: "Before starting protocol information:"
warn: "Protocol warning:"
guideln: "Guidelines:"
p_link: "Link:"
description: "Protocol Description: "
before_start: "Before starting protocol information:"
warning: "Protocol warning:"
guidelines: "Guidelines:"
link: "Link:"
s_nobr_link: "Link:"
s_link: "Link:"
s_desc: "Description:"
@ -1405,11 +1405,11 @@ en:
os: "OS name , OS version:"
sub_prot: "This protocol also contains an attached sub-protocol:"
auth: "Author:"
manu_cit: "Manuscript citation:"
pbl_date: "Publish date:"
vnd_name: "Vendor name:"
vnd_link: "Vendor link:"
key_wrd: "Keywords:"
manuscript_citation: "Manuscript citation:"
publish_date: "Publish date:"
vendor_name: "Vendor name:"
vendor_link: "Vendor link:"
keywords: "Keywords:"
tags: "Tags:"
comp_append:
table_moved: "<br><strong><i>There was a table here, it was moved to the end of this step. </i></strong>"
@ -1418,22 +1418,26 @@ en:
general_link: "<br>Link: "
expected_result: "<br><strong>Expected result: </strong>"
soft_packg:
title: "<br><strong>Software package: </strong>"
dev: "<br>Developer: "
vers: "<br>Version: "
repo: "<br>Repository: "
name: "<br><strong>Software package: </strong>"
developer: "<br>Developer: "
version: "<br>Version: "
link: "<br>Link: "
repository: "<br>Repository: "
os: "<br>OS name , OS version: "
dataset:
title: "<br><strong>Dataset: </strong>"
name: "<br><strong>Dataset: </strong>"
link: "<br>Link: "
command:
title: "<br><strong>Command: </strong>"
desc: "<br>Description: "
name: "<br><strong>Command: </strong>"
description: "<br>Description: "
os: "<br>OS name , OS version: "
sub_protocol:
title: "<br><strong>This step also contains an attached sub-protocol: </strong>"
author: "<br>Author: "
protocol_name: "<br><strong>This step also contains an attached sub-protocol: </strong>"
full_name: "<br>Author: "
link: "<br>Link: "
safety_infor:
title: "<br><strong>Safety information: </strong>"
body: "<br><strong>Safety information: </strong>"
link: "<br>Link: "
import_export:
load_file_error: "Failed to load the protocol file."
import_modal: