From 835ac6910f58a68490da4f1a8a024a128ee01cb0 Mon Sep 17 00:00:00 2001 From: Zanz2 Date: Sat, 2 Dec 2017 00:29:47 +0100 Subject: [PATCH] Code refactor part 1 --- app/controllers/protocols_controller.rb | 290 ---------------- app/helpers/protocols_io_helper.rb | 312 ++++++++++++++++++ .../_import_json_protocol_p_desc.html.erb | 76 ++--- .../_import_json_protocol_s_desc.html.erb | 150 +++------ 4 files changed, 382 insertions(+), 446 deletions(-) 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..66c1305d3 100644 --- a/app/helpers/protocols_io_helper.rb +++ b/app/helpers/protocols_io_helper.rb @@ -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 = '
' + 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 + 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..d448dfa60 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 @@ -22,78 +22,52 @@ <% 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 %>
+ <%= prepare_for_view(json_object['description'],'medium').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 %>
+ <%= prepare_for_view(json_object['before_start'],'medium').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%>
+ <%= prepare_for_view(json_object['warning'],'medium').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 %>
+ <%= prepare_for_view(json_object['guidelines'],'medium').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 %>
+ <%= prepare_for_view(json_object['manuscript_citation'],'medium').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 %>
+ <%= prepare_for_view(json_object['publish_date'],'small').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 %>
+ <%= prepare_for_view(json_object['vendor_name'],'medium').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 %>
+ <%= prepare_for_view(json_object['vendor_link'],'big').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 %>
+ <%= prepare_for_view(json_object['keywords'],'medium').html_safe %> +
<% end %> <% if json_object['tags'].present? %> <%= t('protocols.protocols_io_import.preview.tags') %> @@ -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 %>
+ <%= prepare_for_view(string_of_tags,'medium').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 %>
+ <%= prepare_for_view(json_object['link'],'big').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..14527f809 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'],'small').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'],'small').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'],'small').html_safe %> +
+ <%= t('protocols.protocols_io_import.preview.dev') %> + <%= prepare_for_view(key['source_data']['developer'],'small').html_safe %> +
+ <%= t('protocols.protocols_io_import.preview.vers') %> + <%= prepare_for_view(key['source_data']['version'],'small').html_safe %> +
+ <%= t('protocols.protocols_io_import.preview.s_link') %> + <%= prepare_for_view(key['source_data']['link'],'small').html_safe %> +
+ <%= t('protocols.protocols_io_import.preview.repo') %> + <%= prepare_for_view(key['source_data']['repository'],'small').html_safe %> +
+ <%= 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']) %>
<%= 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'],'small').html_safe %> +
+ <%= 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']) %>
<%= 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'],'small').html_safe %> +
+ <%= t('protocols.protocols_io_import.preview.s_desc') %> + <%= prepare_for_view(key['source_data']['description'],'small').html_safe %> +
+ <%= 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'%> -
<%= 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'],'small').html_safe %> +
+ <%= t('protocols.protocols_io_import.preview.auth') %> + <%= prepare_for_view(key['source_data']['full_name'],'small').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'],'small').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'],'small').html_safe %> +
+ <%= 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%>