mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2025-10-27 14:37:35 +08:00
Fixed protocols.io import for multiple-step cases. [SCI-7843] (#4946)
* Fix attachments for protocols.io importer [SCI-7843] * Fix protocols io import for multiple step cases [SCI-7843]
This commit is contained in:
parent
054c8c476d
commit
5dd9a7adaf
2 changed files with 8 additions and 3 deletions
|
|
@ -53,7 +53,10 @@ module ProtocolImporters
|
|||
end
|
||||
next_step_id = protocol_hash[:steps].find { |s| s[:previous_id] == first_step_id }.try(:[], :id)
|
||||
steps = normalized_data[:steps].map { |s| [s[:source_id], s] }.to_h
|
||||
original_order = protocol_hash[:steps].map { |m| [m[:previous_id], m[:id]] }.to_h
|
||||
original_order = protocol_hash[:steps].map { |m| [m[:previous_id], m[:id]] }
|
||||
|
||||
# Always select minimal id value for next step in case if protocol has multiple steps paths.
|
||||
original_order = original_order.sort_by { |ids| ids[1] }.reverse!.to_h
|
||||
|
||||
current_position = 0
|
||||
steps[first_step_id][:position] = current_position
|
||||
|
|
@ -66,11 +69,13 @@ module ProtocolImporters
|
|||
original_order[next_step_id]
|
||||
end
|
||||
end
|
||||
|
||||
# Remove steps without position
|
||||
steps = steps.reject { |_, step| step[:position].nil? }
|
||||
# Check if step name are valid
|
||||
steps.each do |step|
|
||||
step[1][:name] = "Step #{(step[1][:position] + 1)}" if step[1][:name].blank?
|
||||
end
|
||||
normalized_data[:steps] = steps.present? ? steps.values : []
|
||||
else
|
||||
normalized_data[:steps] = []
|
||||
end
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@
|
|||
|
||||
<div class="col-xs-12 attachments">
|
||||
<% attachments.each do |a| %>
|
||||
<%= render partial: 'steps/attachments/new_attachment.html.erb',
|
||||
<%= render partial: 'assets/new_asset.html.erb',
|
||||
locals: { file_url: a[:url], file_name: a[:name] } %>
|
||||
<% end %>
|
||||
</div>
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue