diff --git a/app/utilities/protocol_importers/protocols_io/v3/step_components.rb b/app/utilities/protocol_importers/protocols_io/v3/step_components.rb index 04207462e..9641917d2 100644 --- a/app/utilities/protocol_importers/protocols_io/v3/step_components.rb +++ b/app/utilities/protocol_importers/protocols_io/v3/step_components.rb @@ -118,9 +118,9 @@ module ProtocolImporters { type: 'reagent', name: desc_component[:source][:name], + link: desc_component[:source][:url], details: { catalog_number: desc_component[:source][:sku], - link: desc_component[:source][:vendor][:link], linear_formula: desc_component[:source][:linfor], mol_weight: desc_component[:source][:mol_weight] } diff --git a/app/views/protocol_importers/templates/_command.html.erb b/app/views/protocol_importers/templates/_command.html.erb index 21ab069e0..b260ec714 100644 --- a/app/views/protocol_importers/templates/_command.html.erb +++ b/app/views/protocol_importers/templates/_command.html.erb @@ -1,5 +1,11 @@

<%= t('protocol_importers.templates.command.title') %>
- <%= "#{t('protocol_importers.templates.command.name')}: #{item[:name]}" %> - <%= "#{t('protocol_importers.templates.command.code')}: #{item[:command]}" %> + <% if item[:name].present? %> + <%= "#{t('protocol_importers.templates.command.name')}: #{item[:name]}" %>
+ <% end %> + + <% if item[:command].present? %> + <%= t('protocol_importers.templates.command.code') %>:
+ <%= item[:command] %> +<% end %>

<%= render partial: 'protocol_importers/templates/details', locals: { item: item } %> diff --git a/app/views/protocol_importers/templates/_dataset.html.erb b/app/views/protocol_importers/templates/_dataset.html.erb index 0ff510b15..80002ba29 100644 --- a/app/views/protocol_importers/templates/_dataset.html.erb +++ b/app/views/protocol_importers/templates/_dataset.html.erb @@ -1,5 +1,9 @@

<%= t('protocol_importers.templates.dataset.title') %>
- <%= "#{t('protocol_importers.templates.dataset.name')}: #{item[:name]}" %> - <%= "#{t('protocol_importers.templates.dataset.link')}: #{item[:source]}" if item[:source] %> + <% if item[:name].present? %> + <%= "#{t('protocol_importers.templates.dataset.name')}: #{item[:name]}" %>
+ <% end %> + <% if item[:source].present? %> + <%= t('protocol_importers.templates.dataset.link') %>: <%= item[:source] %> + <% end %>

<%= render partial: 'protocol_importers/templates/details', locals: { item: item } %> diff --git a/app/views/protocol_importers/templates/_details.html.erb b/app/views/protocol_importers/templates/_details.html.erb index 99b88b066..2d0ce0ce9 100644 --- a/app/views/protocol_importers/templates/_details.html.erb +++ b/app/views/protocol_importers/templates/_details.html.erb @@ -1,8 +1,9 @@

- <% if item[:details]&.any? %> - <%= t('protocol_importers.templates.details.title')%>: + <% items = item[:details]&.reject { |_,v| v.blank? } %> + <% if items&.any? %> + <%= t('protocol_importers.templates.details.title')%>:
- <% item[:details].reject { |_,v| v.blank? }.each do |k, v| %> + <% items.each do |k, v| %> <%= "#{k.humanize}: #{v.to_s}" %>
<% end %> diff --git a/app/views/protocol_importers/templates/_gotostep.html.erb b/app/views/protocol_importers/templates/_gotostep.html.erb index 56a77ea2c..fa9f0e042 100644 --- a/app/views/protocol_importers/templates/_gotostep.html.erb +++ b/app/views/protocol_importers/templates/_gotostep.html.erb @@ -1,4 +1,5 @@

<%= t('protocol_importers.templates.gotostep.title') %>
<%= "#{t('protocol_importers.templates.gotostep.number')}: #{item[:step_id]}" %>
<%= "#{t('protocol_importers.templates.gotostep.reason')}: #{item[:value]}" %>
- <%= render partial: 'protocol_importers/templates/details', locals: { item: item } %> +

+<%= render partial: 'protocol_importers/templates/details', locals: { item: item } %> diff --git a/app/views/protocol_importers/templates/_note.html.erb b/app/views/protocol_importers/templates/_note.html.erb index cda54ec2b..943cc0076 100644 --- a/app/views/protocol_importers/templates/_note.html.erb +++ b/app/views/protocol_importers/templates/_note.html.erb @@ -1,4 +1,10 @@

<%= t('protocol_importers.templates.note.title') %>
- <%= "#{t('protocol_importers.templates.note.author')}: #{item[:author]}" %>
- <%= item[:body] %>

+ <% if item[:author].present? %> + <%= "#{t('protocol_importers.templates.note.author')}: #{item[:author]}" %>
+ <% end %> + + <% if item[:body].present? %> + <%= item[:body] %> + <% end %> +

<%= render partial: 'protocol_importers/templates/details', locals: { item: item } %> diff --git a/app/views/protocol_importers/templates/_reagent.html.erb b/app/views/protocol_importers/templates/_reagent.html.erb index fcf991475..2a76866e8 100644 --- a/app/views/protocol_importers/templates/_reagent.html.erb +++ b/app/views/protocol_importers/templates/_reagent.html.erb @@ -1,11 +1,11 @@

<%= t('protocol_importers.templates.reagent.title') %>
- <%= "#{t('protocol_importers.templates.reagent.name')}: #{item[:name]}" %> - <% if item[:source] %> + <%= "#{t('protocol_importers.templates.reagent.name')}: #{item[:name]}" %>
+ <% if item[:link].present? %> <%= t('protocol_importers.templates.reagent.link') %>: - <%= "#{item[:source]}" %> - <% end -%> + <%= item[:link] %> + <% end %>

<%= render( partial: 'protocol_importers/templates/details', diff --git a/app/views/protocol_importers/templates/_software.html.erb b/app/views/protocol_importers/templates/_software.html.erb index 995d0cc5a..f40cfbffe 100644 --- a/app/views/protocol_importers/templates/_software.html.erb +++ b/app/views/protocol_importers/templates/_software.html.erb @@ -1,6 +1,11 @@

<%= t('protocol_importers.templates.software.title') %>
- <%= "#{t('protocol_importers.templates.software.name')}: #{item[:name]}" %> - <%= "#{t('protocol_importers.templates.software.link')}: #{ActionController::Base.helpers.link_to(item[:source], item[:source])}" %> + <% if item[:name].present? %> + <%= "#{t('protocol_importers.templates.software.name')}: #{item[:name]}" %> + <% end %> +
+ <% if item[:source].present? %> + <%= t('protocol_importers.templates.software.link') %>: <%= item[:source] %> + <% end %>

<%= render partial: 'protocol_importers/templates/details', locals: { item: item } %> diff --git a/app/views/protocol_importers/templates/_warning.html.erb b/app/views/protocol_importers/templates/_warning.html.erb index 8d20de5e2..200be2283 100644 --- a/app/views/protocol_importers/templates/_warning.html.erb +++ b/app/views/protocol_importers/templates/_warning.html.erb @@ -1,3 +1,3 @@ -

<%= t('protocol_importers.templates.warning.title') %>
+

<%= t('protocol_importers.templates.warning.title') %>
<%= item[:body] %>

<%= render partial: 'protocol_importers/templates/details', locals: { item: item } %> diff --git a/app/views/protocol_importers/templates/protocol_description.html.erb b/app/views/protocol_importers/templates/protocol_description.html.erb index 4c7e89cf7..961596dee 100644 --- a/app/views/protocol_importers/templates/protocol_description.html.erb +++ b/app/views/protocol_importers/templates/protocol_description.html.erb @@ -1,8 +1,8 @@ -<% if @description[:body] %> +<% if @description[:body].present? %>

<%= sanitize(@description[:body], tags: Constants::PROTOCOLS_DESC_TAGS) %>


<% end %> -<% if @description[:image] %> +<% if @description[:image].present? %>

diff --git a/app/views/protocol_importers/templates/step_description.html.erb b/app/views/protocol_importers/templates/step_description.html.erb index 679fec4ac..7752797e2 100644 --- a/app/views/protocol_importers/templates/step_description.html.erb +++ b/app/views/protocol_importers/templates/step_description.html.erb @@ -1,4 +1,4 @@ -<% if @step_description[:body] %> +<% if @step_description[:body].present? %>

<%= sanitize(@step_description[:body], tags: Constants::PROTOCOLS_DESC_TAGS) %>

<% end %> diff --git a/spec/fixtures/files/protocol_importers/normalized_single_protocol.json b/spec/fixtures/files/protocol_importers/normalized_single_protocol.json index 70b5892b0..29b823e1b 100644 --- a/spec/fixtures/files/protocol_importers/normalized_single_protocol.json +++ b/spec/fixtures/files/protocol_importers/normalized_single_protocol.json @@ -72,9 +72,9 @@ { "type": "reagent", "name": "2 mg Gastrin I, human", + "link": "https://www.biorbyt.com/gastrin-i-human-orb321073", "details": { "catalog_number": "", - "link": "https://www.biorbyt.com/gastrin-i-human-orb321073", "linear_formula": "C130H204N38O31S", "mol_weight": 0.1 } diff --git a/spec/fixtures/files/protocol_importers/protocols_io/v3/single_protocol.json b/spec/fixtures/files/protocol_importers/protocols_io/v3/single_protocol.json index df91692ca..db9046602 100644 --- a/spec/fixtures/files/protocol_importers/protocols_io/v3/single_protocol.json +++ b/spec/fixtures/files/protocol_importers/protocols_io/v3/single_protocol.json @@ -486,7 +486,7 @@ "mol_weight": 0.1, "name": "2 mg Gastrin I, human", "linfor": "C130H204N38O31S", - "url": "", + "url": "https://www.biorbyt.com/gastrin-i-human-orb321073", "sku": "", "public": 0, "vendor": {