mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2025-01-31 20:19:05 +08:00
Assign name = position if protocolsIO step has no name
This commit is contained in:
parent
5430fb311d
commit
8146a6a42c
1 changed files with 6 additions and 0 deletions
|
@ -50,11 +50,17 @@ module ProtocolImporters
|
|||
original_order = protocol_hash[:steps].map { |m| [m[:previous_id], m[:id]] }.to_h
|
||||
current_position = 0
|
||||
while next_step_id
|
||||
|
||||
current_position += 1
|
||||
steps[next_step_id][:position] = current_position
|
||||
next_step_id = original_order[next_step_id]
|
||||
end
|
||||
|
||||
# Check if step name are valid
|
||||
steps.each do |step|
|
||||
step[1][:name] = (step[1][:position] + 1).to_s if step[1][:name].blank?
|
||||
end
|
||||
|
||||
{ protocol: normalized_data }
|
||||
rescue StandardError => e
|
||||
raise ProtocolImporters::ProtocolsIO::V3::NormalizerError.new(e.class.to_s.downcase.to_sym), e.message
|
||||
|
|
Loading…
Reference in a new issue