mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2025-03-04 03:36:44 +08:00
moved code from older branch to new master
This commit is contained in:
parent
f67f633562
commit
9b5ddc6789
1 changed files with 34 additions and 19 deletions
|
@ -175,6 +175,7 @@ module ProtocolsIoHelper
|
||||||
else
|
else
|
||||||
' , '
|
' , '
|
||||||
end
|
end
|
||||||
|
# intercept tables here, before they are shortened
|
||||||
if attribute_name == 'protocol_name'
|
if attribute_name == 'protocol_name'
|
||||||
output_string += pio_eval_title_len(attribute_text)
|
output_string += pio_eval_title_len(attribute_text)
|
||||||
else
|
else
|
||||||
|
@ -189,7 +190,7 @@ module ProtocolsIoHelper
|
||||||
def pio_stp_1(iterating_key) # protocols io description parser
|
def pio_stp_1(iterating_key) # protocols io description parser
|
||||||
br = '<br>'
|
br = '<br>'
|
||||||
append =
|
append =
|
||||||
if iterating_key.present?
|
if iterating_key.present? # intercept tables here before cutting
|
||||||
br +
|
br +
|
||||||
prepare_for_view(
|
prepare_for_view(
|
||||||
iterating_key,
|
iterating_key,
|
||||||
|
@ -213,7 +214,7 @@ module ProtocolsIoHelper
|
||||||
if iterating_key.present?
|
if iterating_key.present?
|
||||||
append =
|
append =
|
||||||
t('protocols.protocols_io_import.comp_append.expected_result') +
|
t('protocols.protocols_io_import.comp_append.expected_result') +
|
||||||
prepare_for_view(
|
prepare_for_view( # intercept tables here, before cutting
|
||||||
iterating_key, ProtocolsIoHelper::PIO_ELEMENT_RESERVED_LENGTH_SMALL
|
iterating_key, ProtocolsIoHelper::PIO_ELEMENT_RESERVED_LENGTH_SMALL
|
||||||
) +
|
) +
|
||||||
'<br>'
|
'<br>'
|
||||||
|
@ -228,7 +229,7 @@ module ProtocolsIoHelper
|
||||||
parse_elements_array.each do |element|
|
parse_elements_array.each do |element|
|
||||||
return '' unless iterating_key[element]
|
return '' unless iterating_key[element]
|
||||||
append += fill_attributes(
|
append += fill_attributes(
|
||||||
element,
|
element, # intercept tables here, before cutting
|
||||||
iterating_key[element],
|
iterating_key[element],
|
||||||
en_local_text
|
en_local_text
|
||||||
)
|
)
|
||||||
|
@ -237,22 +238,28 @@ module ProtocolsIoHelper
|
||||||
end
|
end
|
||||||
|
|
||||||
def protocols_io_fill_desc(json_hash)
|
def protocols_io_fill_desc(json_hash)
|
||||||
|
unshortened_string_for_tables = ''
|
||||||
description_array = %w[
|
description_array = %w[
|
||||||
( before_start warning guidelines manuscript_citation publish_date
|
( before_start warning guidelines manuscript_citation publish_date
|
||||||
vendor_name vendor_link keywords tags link created_on )
|
vendor_name vendor_link keywords tags link created_on )
|
||||||
]
|
]
|
||||||
description_string =
|
if json_hash['description'].present?
|
||||||
if json_hash['description'].present?
|
unshortened_string_for_tables += json_hash['description']
|
||||||
'<strong>' + t('protocols.protocols_io_import.preview.description') +
|
description_string =
|
||||||
'</strong>' +
|
'<strong>' +
|
||||||
prepare_for_view(
|
t('protocols.protocols_io_import.preview.description') +
|
||||||
json_hash['description'],
|
'</strong>' +
|
||||||
ProtocolsIoHelper::PIO_ELEMENT_RESERVED_LENGTH_MEDIUM
|
prepare_for_view(
|
||||||
).html_safe
|
json_hash['description'], # intercept tables here, before they are cut
|
||||||
else
|
ProtocolsIoHelper::PIO_ELEMENT_RESERVED_LENGTH_MEDIUM
|
||||||
'<strong>' + t('protocols.protocols_io_import.preview.description') +
|
).html_safe
|
||||||
'</strong>' + t('protocols.protocols_io_import.comp_append.missing_desc')
|
else
|
||||||
end
|
description_string =
|
||||||
|
'<strong>' +
|
||||||
|
t('protocols.protocols_io_import.preview.description') +
|
||||||
|
'</strong>' +
|
||||||
|
t('protocols.protocols_io_import.comp_append.missing_desc')
|
||||||
|
end
|
||||||
description_string += '<br>'
|
description_string += '<br>'
|
||||||
description_array.each do |e|
|
description_array.each do |e|
|
||||||
if e == 'created_on' && json_hash[e].present?
|
if e == 'created_on' && json_hash[e].present?
|
||||||
|
@ -279,16 +286,17 @@ module ProtocolsIoHelper
|
||||||
)
|
)
|
||||||
description_string += '<br>'
|
description_string += '<br>'
|
||||||
elsif json_hash[e].present?
|
elsif json_hash[e].present?
|
||||||
|
unshortened_string_for_tables += json_hash[e]
|
||||||
new_e = '<strong>' + e.humanize + '</strong>'
|
new_e = '<strong>' + e.humanize + '</strong>'
|
||||||
description_string +=
|
description_string +=
|
||||||
new_e.to_s + ': ' +
|
new_e.to_s + ': ' + # intercept tables here, before cut
|
||||||
pio_eval_prot_desc(
|
pio_eval_prot_desc(
|
||||||
sanitize_input(json_hash[e]),
|
sanitize_input(json_hash[e]),
|
||||||
e
|
e
|
||||||
).html_safe + '<br>'
|
).html_safe + '<br>'
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
description_string
|
return description_string, unshortened_string_for_tables
|
||||||
end
|
end
|
||||||
|
|
||||||
def protocols_io_guid_reorder_step_json(unordered_step_json)
|
def protocols_io_guid_reorder_step_json(unordered_step_json)
|
||||||
|
@ -325,9 +333,15 @@ module ProtocolsIoHelper
|
||||||
newj['0']['position'] = 0
|
newj['0']['position'] = 0
|
||||||
newj['0']['name'] = 'Protocol info'
|
newj['0']['name'] = 'Protocol info'
|
||||||
@remaining = ProtocolsIoHelper::PIO_P_AVAILABLE_LENGTH
|
@remaining = ProtocolsIoHelper::PIO_P_AVAILABLE_LENGTH
|
||||||
newj['0']['tables'], table_str = protocolsio_string_to_table_element(
|
shortened_string, unshortened_tables_string = protocols_io_fill_desc(
|
||||||
sanitize_input(protocols_io_fill_desc(original_json).html_safe)
|
original_json
|
||||||
)
|
)
|
||||||
|
newj['0']['tables'] = protocolsio_string_to_table_element(
|
||||||
|
sanitize_input(unshortened_tables_string).html_safe
|
||||||
|
)[0]
|
||||||
|
table_str = protocolsio_string_to_table_element(
|
||||||
|
sanitize_input(shortened_string).html_safe
|
||||||
|
)[1]
|
||||||
newj['0']['description'] = table_str
|
newj['0']['description'] = table_str
|
||||||
original_json['steps'].each_with_index do |step, pos_orig| # loop over steps
|
original_json['steps'].each_with_index do |step, pos_orig| # loop over steps
|
||||||
i = pos_orig + 1
|
i = pos_orig + 1
|
||||||
|
@ -344,6 +358,7 @@ module ProtocolsIoHelper
|
||||||
# append is the string that we append values into for description
|
# append is the string that we append values into for description
|
||||||
# pio_stp_x means protocols io step (id of component) parser
|
# pio_stp_x means protocols io step (id of component) parser
|
||||||
case key['component_type_id']
|
case key['component_type_id']
|
||||||
|
# intercept tables in all of below before cutting
|
||||||
when '1'
|
when '1'
|
||||||
newj[i.to_s]['description'] += pio_stp_1(key['data'])
|
newj[i.to_s]['description'] += pio_stp_1(key['data'])
|
||||||
when '6'
|
when '6'
|
||||||
|
|
Loading…
Reference in a new issue