diff --git a/app/controllers/protocols_controller.rb b/app/controllers/protocols_controller.rb
index 9d017982f..ba024c3ec 100644
--- a/app/controllers/protocols_controller.rb
+++ b/app/controllers/protocols_controller.rb
@@ -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 = '
'
- 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
- ) +
- '
'
- 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?
- '' + t('protocols.protocols_io_import.preview.prot_desc') +
- '' + pio_eval_len(
- sanitize_input(json_hash['description']),
- ProtocolsIoHelper::PIO_ELEMENT_RESERVED_LENGTH_MEDIUM
- ).html_safe
- else
- '' + t('protocols.protocols_io_import.preview.prot_desc') +
- '' + t('protocols.protocols_io_import.comp_append.missing_desc')
- end
- description_string += '
'
- description_array.each do |e|
- if e == 'created_on' && json_hash[e].present?
- new_e = '' + e.humanize + ''
- description_string +=
- new_e.to_s + ': ' + pio_eval_len(
- sanitize_input(params['protocol']['created_at'].to_s),
- ProtocolsIoHelper::PIO_ELEMENT_RESERVED_LENGTH_SMALL
- ) + '
'
- elsif e == 'tags' && json_hash[e].any? && json_hash[e] != ''
- new_e = '' + e.humanize + ''
- 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 += '
'
- elsif json_hash[e].present?
- new_e = '' + e.humanize + ''
- description_string +=
- new_e.to_s + ': ' +
- pio_eval_prot_desc(
- sanitize_input(json_hash[e]),
- e
- ).html_safe + '
'
- 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 = []
diff --git a/app/helpers/protocols_io_helper.rb b/app/helpers/protocols_io_helper.rb
index be72de36d..e4eb5f70a 100644
--- a/app/helpers/protocols_io_helper.rb
+++ b/app/helpers/protocols_io_helper.rb
@@ -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 = '
'
+ 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
+ ) +
+ '
'
+ 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?
+ '' + t('protocols.protocols_io_import.preview.description') +
+ '' +
+ prepare_for_view(
+ json_hash['description'],
+ ProtocolsIoHelper::PIO_ELEMENT_RESERVED_LENGTH_MEDIUM
+ ).html_safe
+ else
+ '' + t('protocols.protocols_io_import.preview.description') +
+ '' + t('protocols.protocols_io_import.comp_append.missing_desc')
+ end
+ description_string += '
'
+ description_array.each do |e|
+ if e == 'created_on' && json_hash[e].present?
+ new_e = '' + e.humanize + ''
+ description_string +=
+ new_e.to_s + ': ' +
+ prepare_for_view(
+ params['protocol']['created_at'].to_s,
+ ProtocolsIoHelper::PIO_ELEMENT_RESERVED_LENGTH_SMALL
+ ) +
+ + '
'
+ elsif e == 'tags' && json_hash[e].any? && json_hash[e] != ''
+ new_e = '' + e.humanize + ''
+ 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 += '
'
+ elsif json_hash[e].present?
+ new_e = '' + e.humanize + ''
+ description_string +=
+ new_e.to_s + ': ' +
+ pio_eval_prot_desc(
+ sanitize_input(json_hash[e]),
+ e
+ ).html_safe + '
'
+ 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
diff --git a/app/views/protocols/import_export/_import_json_protocol_p_desc.html.erb b/app/views/protocols/import_export/_import_json_protocol_p_desc.html.erb
index 5693e4029..dae8b49f6 100644
--- a/app/views/protocols/import_export/_import_json_protocol_p_desc.html.erb
+++ b/app/views/protocols/import_export/_import_json_protocol_p_desc.html.erb
@@ -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']) %>
- <%= t('protocols.protocols_io_import.preview.prot_desc') %>
- <% description = pio_eval_len(
- sanitize_input(string_html_table_remove(json_object['description'])),
- ProtocolsIoHelper::PIO_ELEMENT_RESERVED_LENGTH_MEDIUM) %>
- <%= description.html_safe %>
- <% end %>
- <% if json_object['before_start'].present? %>
- <% prot_info_string += (json_object['before_start']) %>
- <%= t('protocols.protocols_io_import.preview.b_s_p') %>
- <% 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 %>
- <% end %>
- <% if json_object['warning'].present? %>
- <% prot_info_string += (json_object['warning']) %>
- <%= t('protocols.protocols_io_import.preview.warn') %>
- <% sft_warning = pio_eval_len(
- sanitize_input(string_html_table_remove(json_object['warning'])),
- ProtocolsIoHelper::PIO_ELEMENT_RESERVED_LENGTH_MEDIUM
- ) %>
- <%= sft_warning.html_safe%>
- <% end %>
- <% if json_object['guidelines'].present? %>
- <% prot_info_string += (json_object['guidelines']) %>
- <%= t('protocols.protocols_io_import.preview.guideln') %>
- <% guidelines = pio_eval_len(
- sanitize_input(string_html_table_remove(json_object['guidelines'])),
- ProtocolsIoHelper::PIO_ELEMENT_RESERVED_LENGTH_MEDIUM
- ) %>
- <%= guidelines.html_safe %>
- <% end %>
- <% if json_object['manuscript_citation'].present? %>
- <% prot_info_string += (json_object['manuscript_citation']) %>
- <%= t('protocols.protocols_io_import.preview.manu_cit') %>
- <% 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 %>
- <% end %>
- <% if json_object['publish_date'].present? %>
- <%= t('protocols.protocols_io_import.preview.pbl_date') %>
- <% pbl_date = pio_eval_len(
- sanitize_input(json_object['publish_date']),
- ProtocolsIoHelper::PIO_ELEMENT_RESERVED_LENGTH_SMALL
- ) %>
- <%= pbl_date.html_safe %>
- <% end %>
- <% if json_object['vendor_name'].present? %>
- <%= t('protocols.protocols_io_import.preview.vnd_name') %>
- <% vnd_name = pio_eval_len(
- sanitize_input(json_object['vendor_name']),
- ProtocolsIoHelper::PIO_ELEMENT_RESERVED_LENGTH_MEDIUM
- ) %>
- <%= vnd_name.html_safe %>
- <% end %>
- <% if json_object['vendor_link'].present? %>
- <%= t('protocols.protocols_io_import.preview.vnd_link') %>
- <% vnd_link = pio_eval_len(
- sanitize_input(json_object['vendor_link']),
- ProtocolsIoHelper::PIO_ELEMENT_RESERVED_LENGTH_BIG
- ) %>
- <%= vnd_link.html_safe %>
- <% end %>
- <% if json_object['keywords'].present? %>
- <%= t('protocols.protocols_io_import.preview.key_wrd') %>
- <% keywords = pio_eval_len(
- sanitize_input(json_object['keywords']),
- ProtocolsIoHelper::PIO_ELEMENT_RESERVED_LENGTH_MEDIUM
- ) %>
- <%= keywords.html_safe %>
- <% end %>
- <% if json_object['tags'].present? %>
- <%= t('protocols.protocols_io_import.preview.tags') %>
- <% string_of_tags='' %>
- <% json_object['tags'].each do |tag| %>
- <% string_of_tags += tag['tag_name']+' , ' %>
+ <% 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 %>
+ <%= t(translation_string) %>
+ <% string_of_tags='' %>
+ <% json_object['tags'].each do |tag| %>
+ <% string_of_tags += tag['tag_name']+' , ' %>
+ <% end %>
+ <%= 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 %>
+ <%= t(translation_string) %>
+ <%= prepare_for_view(json_object[element],protocol_attr_len_hash[element.to_sym],'table').html_safe %>
+ <% end %>
+
<% end %>
- <% tags = pio_eval_len(
- sanitize_input(string_of_tags),
- ProtocolsIoHelper::PIO_ELEMENT_RESERVED_LENGTH_MEDIUM
- )%>
- <%= tags.html_safe %>
- <% end %>
- <% if json_object['link'].present? %>
- <%= t('protocols.protocols_io_import.preview.p_link') %>
- <% link = pio_eval_len(
- sanitize_input(json_object['link']).html_safe,
- ProtocolsIoHelper::PIO_ELEMENT_RESERVED_LENGTH_BIG
- ) %>
- <%= link.html_safe %>
<% end %>
<% tables, garbage = protocolsio_string_to_table_element(prot_info_string) %>
<% if tables.present? %>
diff --git a/app/views/protocols/import_export/_import_json_protocol_s_desc.html.erb b/app/views/protocols/import_export/_import_json_protocol_s_desc.html.erb
index 12f43a41f..7c3c82092 100644
--- a/app/views/protocols/import_export/_import_json_protocol_s_desc.html.erb
+++ b/app/views/protocols/import_export/_import_json_protocol_s_desc.html.erb
@@ -41,20 +41,15 @@
<% case key['component_type_id']
when '1' %>
<% step_info_string += (key['data']) %>
-
<%= t('protocols.protocols_io_import.preview.strng_s_desc') %>
- <% s_desc = pio_eval_len(
- sanitize_input(string_html_table_remove(key['data'])),
- ProtocolsIoHelper::PIO_ELEMENT_RESERVED_LENGTH_SMALL
- )%>
- <%= s_desc.html_safe %>
+
+ <%= t('protocols.protocols_io_import.preview.strng_s_desc') %>
+ <%= prepare_for_view(key['data'],ProtocolsIoHelper::PIO_ELEMENT_RESERVED_LENGTH_SMALL,'table').html_safe %>
+
<% when '17' %>
<% step_info_string += (key['data']) %>
-
<%= t('protocols.protocols_io_import.preview.s_exp_res') %>
- <% 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 %>
+
+ <%= t('protocols.protocols_io_import.preview.s_exp_res') %>
+ <%= prepare_for_view(key['data'],ProtocolsIoHelper::PIO_ELEMENT_RESERVED_LENGTH_SMALL,'table').html_safe %>
<% end %>
<% elsif key && whitelist_complex.include?(key['component_type_id']) %>
@@ -63,112 +58,63 @@
<% step_info_string += not_null(key['source_data']['name']) %>
<%= not_null(key['name'])+': ' %>
- <%= 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 %>
-
<%= 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 %>
-
<%= 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 %>
-
<%= 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 %>
-
<%= 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 %>
-
<%= 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 %>
+
+ <%= t('protocols.protocols_io_import.preview.dev') %>
+ <%= prepare_for_view(key['source_data']['developer'],ProtocolsIoHelper::PIO_ELEMENT_RESERVED_LENGTH_SMALL,'table').html_safe %>
+
+ <%= t('protocols.protocols_io_import.preview.vers') %>
+ <%= prepare_for_view(key['source_data']['version'],ProtocolsIoHelper::PIO_ELEMENT_RESERVED_LENGTH_SMALL,'table').html_safe %>
+
+ <%= t('protocols.protocols_io_import.preview.s_link') %>
+ <%= prepare_for_view(key['source_data']['link'],ProtocolsIoHelper::PIO_ELEMENT_RESERVED_LENGTH_SMALL,'table').html_safe %>
+
+ <%= t('protocols.protocols_io_import.preview.repo') %>
+ <%= prepare_for_view(key['source_data']['repository'],ProtocolsIoHelper::PIO_ELEMENT_RESERVED_LENGTH_SMALL,'table').html_safe %>
+
+ <%= 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']) %>
<%= not_null(key['name'])+': ' %>
- <%= 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 %>
-
<%= 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 %>
+
+ <%= 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']) %>
<%= key['name']+': ' %>
- <% s_cmd = pio_eval_len(
- sanitize_input(not_null(key['source_data']['name'])),
- ProtocolsIoHelper::PIO_ELEMENT_RESERVED_LENGTH_SMALL
- ) %>
- <%= s_cmd.html_safe %>
-
<%= 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 %>
-
<%= 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 %>
+
+ <%= t('protocols.protocols_io_import.preview.s_desc') %>
+ <%= prepare_for_view(key['source_data']['description'],ProtocolsIoHelper::PIO_ELEMENT_RESERVED_LENGTH_SMALL,'table').html_safe %>
+
+ <%= 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'%>
-
<%= t('protocols.protocols_io_import.preview.sub_prot') %>
- <%= pio_eval_len(
- sanitize_input(not_null(key['source_data']['protocol_name']).html_safe),
- ProtocolsIoHelper::PIO_ELEMENT_RESERVED_LENGTH_SMALL
- ).html_safe %>
-
<%= 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 %>
+
+ <%= t('protocols.protocols_io_import.preview.sub_prot') %>
+ <%= prepare_for_view(key['source_data']['protocol_name'],ProtocolsIoHelper::PIO_ELEMENT_RESERVED_LENGTH_SMALL,'table').html_safe %>
+
+ <%= t('protocols.protocols_io_import.preview.auth') %>
+ <%= prepare_for_view(key['source_data']['full_name'],ProtocolsIoHelper::PIO_ELEMENT_RESERVED_LENGTH_SMALL,'table').html_safe %>
<% 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']) %>
- <%= key['name']+': ' %>
- <% 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 %>
-
<%= 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'%>
+ <%= not_null(key['name'])+': ' %>
+ <%= prepare_for_view(key['source_data']['body'],ProtocolsIoHelper::PIO_ELEMENT_RESERVED_LENGTH_SMALL,'table').html_safe %>
+
+ <%= 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%>
diff --git a/config/locales/en.yml b/config/locales/en.yml
index 592c5aeb5..9aa80d57a 100644
--- a/config/locales/en.yml
+++ b/config/locales/en.yml
@@ -1389,11 +1389,11 @@ en:
too_long: "... Text is too long so we had to cut it off."
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: "
There was a table here, it was moved to the end of this step. "
@@ -1418,22 +1418,26 @@ en:
general_link: "
Link: "
expected_result: "
Expected result: "
soft_packg:
- title: "
Software package: "
- dev: "
Developer: "
- vers: "
Version: "
- repo: "
Repository: "
+ name: "
Software package: "
+ developer: "
Developer: "
+ version: "
Version: "
+ link: "
Link: "
+ repository: "
Repository: "
os: "
OS name , OS version: "
dataset:
- title: "
Dataset: "
+ name: "
Dataset: "
+ link: "
Link: "
command:
- title: "
Command: "
- desc: "
Description: "
+ name: "
Command: "
+ description: "
Description: "
os: "
OS name , OS version: "
sub_protocol:
- title: "
This step also contains an attached sub-protocol: "
- author: "
Author: "
+ protocol_name: "
This step also contains an attached sub-protocol: "
+ full_name: "
Author: "
+ link: "
Link: "
safety_infor:
- title: "
Safety information: "
+ body: "
Safety information: "
+ link: "
Link: "
import_export:
load_file_error: "Failed to load the protocol file."
import_modal: