From ab038ffdf71d04214d13f5657440070f0adfd564 Mon Sep 17 00:00:00 2001 From: Miha Mencin Date: Tue, 2 Jul 2019 19:47:05 +0200 Subject: [PATCH 1/6] SCI-3649 adding catalog number, fixing up the design a bit --- .../protocols_io/v3/step_components.rb | 1 + .../protocol_importers/templates/_details.html.erb | 10 +++++++--- 2 files changed, 8 insertions(+), 3 deletions(-) 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 f8c83547d..31ba4bf9e 100644 --- a/app/utilities/protocol_importers/protocols_io/v3/step_components.rb +++ b/app/utilities/protocol_importers/protocols_io/v3/step_components.rb @@ -117,6 +117,7 @@ module ProtocolImporters name: desc_component[:source][:name], mol_weight: desc_component[:source][:mol_weight], details: { + catalog_number: desc_component[:source][:sku], link: desc_component[:source][:vendor][:link], linear_formula: desc_component[:source][:linfor] } diff --git a/app/views/protocol_importers/templates/_details.html.erb b/app/views/protocol_importers/templates/_details.html.erb index 40fee2b91..35c9eb462 100644 --- a/app/views/protocol_importers/templates/_details.html.erb +++ b/app/views/protocol_importers/templates/_details.html.erb @@ -1,6 +1,10 @@

- <%= item[:details]&.any? ? "#{t('protocol_importers.templates.details.title') }" : '' %> - <% item[:details]&.each do |k, v| %> - <%= "#{k.camelize.to_s}: #{v.to_s}" %> + <% if item[:details]&.any? %> + <%= t('protocol_importers.templates.details.title')%>: +
+ <% item[:details]&.each do |k, v| %> + <%= "#{k.humanize}: #{v.to_s}" %> +
+ <% end %> <% end %>

From 611c417b43be043895cf6f0cf7f7b8e37e9590a1 Mon Sep 17 00:00:00 2001 From: Miha Mencin Date: Wed, 3 Jul 2019 09:21:41 +0200 Subject: [PATCH 2/6] code review changes --- .../protocol_importers/protocols_io/v3/step_components.rb | 4 ++-- app/views/protocol_importers/templates/_details.html.erb | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) 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 31ba4bf9e..36400d80e 100644 --- a/app/utilities/protocol_importers/protocols_io/v3/step_components.rb +++ b/app/utilities/protocol_importers/protocols_io/v3/step_components.rb @@ -115,11 +115,11 @@ module ProtocolImporters { type: 'reagent', name: desc_component[:source][:name], - mol_weight: desc_component[:source][:mol_weight], details: { catalog_number: desc_component[:source][:sku], link: desc_component[:source][:vendor][:link], - linear_formula: desc_component[:source][:linfor] + linear_formula: desc_component[:source][:linfor], + mol_weight: desc_component[:source][:mol_weight] } } when :gotostep diff --git a/app/views/protocol_importers/templates/_details.html.erb b/app/views/protocol_importers/templates/_details.html.erb index 35c9eb462..a47f11402 100644 --- a/app/views/protocol_importers/templates/_details.html.erb +++ b/app/views/protocol_importers/templates/_details.html.erb @@ -2,7 +2,7 @@ <% if item[:details]&.any? %> <%= t('protocol_importers.templates.details.title')%>:
- <% item[:details]&.each do |k, v| %> + <% item[:details]&.compact.each do |k, v| %> <%= "#{k.humanize}: #{v.to_s}" %>
<% end %> From b709c0ec3c73d279c78f665efe4842029bd5d0d9 Mon Sep 17 00:00:00 2001 From: Miha Mencin Date: Wed, 3 Jul 2019 11:49:01 +0200 Subject: [PATCH 3/6] fix the normalized protocol fixture --- .../files/protocol_importers/normalized_single_protocol.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/spec/fixtures/files/protocol_importers/normalized_single_protocol.json b/spec/fixtures/files/protocol_importers/normalized_single_protocol.json index 9ade81ca8..ed84e621b 100644 --- a/spec/fixtures/files/protocol_importers/normalized_single_protocol.json +++ b/spec/fixtures/files/protocol_importers/normalized_single_protocol.json @@ -72,10 +72,11 @@ { "type": "reagent", "name": "2 mg Gastrin I, human", - "mol_weight": 0.1, "details": { + "catalog_number": "", "link": "https://www.biorbyt.com/gastrin-i-human-orb321073", - "linear_formula": "C130H204N38O31S" + "linear_formula": "C130H204N38O31S", + "mol_weight": 0.1 } }, { From 012b828708def71783ffe8634f4a46666d0c43ee Mon Sep 17 00:00:00 2001 From: Miha Mencin Date: Wed, 3 Jul 2019 14:13:55 +0200 Subject: [PATCH 4/6] additional filters for blank string when displaying the reagent details --- app/views/protocol_importers/templates/_details.html.erb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/protocol_importers/templates/_details.html.erb b/app/views/protocol_importers/templates/_details.html.erb index a47f11402..99b88b066 100644 --- a/app/views/protocol_importers/templates/_details.html.erb +++ b/app/views/protocol_importers/templates/_details.html.erb @@ -2,7 +2,7 @@ <% if item[:details]&.any? %> <%= t('protocol_importers.templates.details.title')%>:
- <% item[:details]&.compact.each do |k, v| %> + <% item[:details].reject { |_,v| v.blank? }.each do |k, v| %> <%= "#{k.humanize}: #{v.to_s}" %>
<% end %> From 964e91e1d222a332168e27b9c612d47c82dd514b Mon Sep 17 00:00:00 2001 From: Miha Mencin Date: Wed, 3 Jul 2019 15:16:47 +0200 Subject: [PATCH 5/6] removi mol weight from general section --- app/views/protocol_importers/templates/_reagent.html.erb | 1 - 1 file changed, 1 deletion(-) diff --git a/app/views/protocol_importers/templates/_reagent.html.erb b/app/views/protocol_importers/templates/_reagent.html.erb index 589e8598a..72b7db94f 100644 --- a/app/views/protocol_importers/templates/_reagent.html.erb +++ b/app/views/protocol_importers/templates/_reagent.html.erb @@ -1,6 +1,5 @@

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

<%= render partial: 'protocol_importers/templates/details', locals: { item: item } %> From 5a437c0a0f5c008822652e6ad67e90feacf54b7e Mon Sep 17 00:00:00 2001 From: Miha Mencin Date: Wed, 3 Jul 2019 15:32:55 +0200 Subject: [PATCH 6/6] coding style fixes --- .../templates/_reagent.html.erb | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/app/views/protocol_importers/templates/_reagent.html.erb b/app/views/protocol_importers/templates/_reagent.html.erb index 72b7db94f..fcf991475 100644 --- a/app/views/protocol_importers/templates/_reagent.html.erb +++ b/app/views/protocol_importers/templates/_reagent.html.erb @@ -1,6 +1,15 @@ -

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

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

-<%= render partial: 'protocol_importers/templates/details', locals: { item: item } %> +<%= render( + partial: 'protocol_importers/templates/details', + locals: { item: item } + ) +%>