mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2025-10-03 10:24:30 +08:00
Merge branch 'master' into images_not_imported_SCI1807
This commit is contained in:
commit
98b3ddbdb0
4 changed files with 40 additions and 7 deletions
|
@ -99,7 +99,7 @@ class AssetsController < ApplicationController
|
|||
|
||||
def load_vars
|
||||
@asset = Asset.find_by_id(params[:id])
|
||||
render_404 unless @asset
|
||||
return render_404 unless @asset
|
||||
|
||||
step_assoc = @asset.step
|
||||
result_assoc = @asset.result
|
||||
|
|
|
@ -632,6 +632,11 @@ class ProtocolsController < ApplicationController
|
|||
return 0 # return 0 stops the rest of the controller code from executing
|
||||
end
|
||||
@json_object = JSON.parse(json_file_contents)
|
||||
|
||||
@json_object['steps'] = protocols_io_guid_reorder_step_json(
|
||||
@json_object['steps']
|
||||
)
|
||||
|
||||
@protocol = Protocol.new
|
||||
respond_to do |format|
|
||||
format.js {} # go to the js.erb file named the same as this controller,
|
||||
|
|
|
@ -183,9 +183,13 @@ module ProtocolsIoHelper
|
|||
else
|
||||
' , '
|
||||
end
|
||||
output_string += prepare_for_view(
|
||||
attribute_text, ProtocolsIoHelper::PIO_ELEMENT_RESERVED_LENGTH_SMALL
|
||||
)
|
||||
if attribute_name == 'protocol_name'
|
||||
output_string += pio_eval_title_len(attribute_text)
|
||||
else
|
||||
output_string += prepare_for_view(
|
||||
attribute_text, ProtocolsIoHelper::PIO_ELEMENT_RESERVED_LENGTH_SMALL
|
||||
)
|
||||
end
|
||||
output_string
|
||||
end
|
||||
|
||||
|
@ -210,8 +214,10 @@ module ProtocolsIoHelper
|
|||
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?
|
||||
if iterating_key.present?
|
||||
# protocols io section(title) parser
|
||||
return pio_eval_title_len(CGI.unescapeHTML(sanitize_input(iterating_key)))
|
||||
end
|
||||
t('protocols.protocols_io_import.comp_append.missing_step')
|
||||
end
|
||||
|
||||
|
@ -309,6 +315,24 @@ module ProtocolsIoHelper
|
|||
description_string
|
||||
end
|
||||
|
||||
def protocols_io_guid_reorder_step_json(unordered_step_json)
|
||||
base_step = unordered_step_json.find { |step| step['previous_guid'].nil? }
|
||||
number_of_steps = unordered_step_json.size
|
||||
step_order = []
|
||||
step_counter = 0
|
||||
step_order[step_counter] = base_step
|
||||
step_counter += 1
|
||||
while step_order.length != number_of_steps
|
||||
step_order[step_counter] =
|
||||
unordered_step_json.find do |step|
|
||||
step['previous_guid'] == base_step['guid']
|
||||
end
|
||||
base_step = step_order[step_counter]
|
||||
step_counter += 1
|
||||
end
|
||||
step_order
|
||||
end
|
||||
|
||||
def protocols_io_fill_step(original_json, newj)
|
||||
# newj = new json
|
||||
# (simple to map) id 1= step description, id 6= section (title),
|
||||
|
@ -317,6 +341,10 @@ module ProtocolsIoHelper
|
|||
# id 9 = dataset, id 15 = command, id 18 = attached sub protocol
|
||||
# id 19= safety information ,
|
||||
# id 20= regents (materials, like scinote samples kind of)
|
||||
|
||||
original_json['steps'] = protocols_io_guid_reorder_step_json(
|
||||
original_json['steps']
|
||||
)
|
||||
newj['0'] = {}
|
||||
newj['0']['position'] = 0
|
||||
newj['0']['name'] = 'Protocol info'
|
||||
|
|
|
@ -98,7 +98,7 @@
|
|||
<% when '18'%>
|
||||
<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 %>
|
||||
<%= pio_eval_title_len(sanitize_input(key['source_data']['protocol_name'])).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 %>
|
||||
|
|
Loading…
Add table
Reference in a new issue