From fcec8364bc59d4359c062e9194444660f80f46df Mon Sep 17 00:00:00 2001 From: cryptogopher Date: Thu, 31 Oct 2019 22:13:39 +0100 Subject: [PATCH] Extra quantities styling in Nutrients listing Fixed decimal precision/scale --- app/views/ingredients/nutrients.html.erb | 19 ++++++++++++------- assets/stylesheets/body_tracking.css | 10 +++++++--- db/migrate/001_create_units.rb | 4 ++-- 3 files changed, 21 insertions(+), 12 deletions(-) diff --git a/app/views/ingredients/nutrients.html.erb b/app/views/ingredients/nutrients.html.erb index 3832307..6094c57 100644 --- a/app/views/ingredients/nutrients.html.erb +++ b/app/views/ingredients/nutrients.html.erb @@ -14,7 +14,7 @@

<%= t ".heading" %>

<% if @primary_nutrients.any? %> - +
@@ -25,7 +25,7 @@ <% @primary_nutrients.each do |i, values| %> - <% row_class = "ingredient #{'hidden' if i.hidden}" %> + <% row_class = "ingredient#{' hidden' if i.hidden} #{cycle('odd', 'even')}" %> <% end %> - <% @extra_nutrients[i].keys.each_slice(@primary_quantities.length) do |names| %> + <% extras = @extra_nutrients[i].keys %> + <% extras.each_slice(@primary_quantities.length).with_index do |names, index| %> - + <% if index == 0 %> + + <% end %> <% names.each do |name| %> - <% end %> - <% for index in names.length...@primary_quantities.length do %> - + <% if @primary_quantities.length > names.length %> + <% end %> diff --git a/assets/stylesheets/body_tracking.css b/assets/stylesheets/body_tracking.css index 179683c..bc01a58 100644 --- a/assets/stylesheets/body_tracking.css +++ b/assets/stylesheets/body_tracking.css @@ -1,10 +1,14 @@ table.list tr.quantity.primary td.name {font-weight: bold;} +table.nutrients.list td.name, +table.list td.quantity.extra {text-align: left; border-bottom: none;} +table.nutrients.list td.space, +table.list td.value.extra {border-top: none;} table.list tr.ingredient.hidden {opacity: 0.4} table.list td.action, table.list td.value {text-align: right;} -table.list th, -table.list td.action, -table.list td.name, +table.nutrients.list th, +table.nutrients.list td.name, +table.list td.quantity, table.list td.value { overflow: hidden; text-overflow: ellipsis; diff --git a/db/migrate/001_create_units.rb b/db/migrate/001_create_units.rb index 6516bca..d9d0f14 100644 --- a/db/migrate/001_create_units.rb +++ b/db/migrate/001_create_units.rb @@ -27,7 +27,7 @@ class CreateUnits < ActiveRecord::Migration create_table :ingredients do |t| t.references :project t.string :name - t.decimal :ref_amount + t.decimal :ref_amount, precision: 12, scale: 6 t.references :ref_unit t.integer :group t.references :source @@ -38,7 +38,7 @@ class CreateUnits < ActiveRecord::Migration create_table :nutrients do |t| t.references :ingredient t.references :quantity - t.decimal :amount + t.decimal :amount, precision: 12, scale: 6 t.references :unit end
<%= l(:field_name) %>
<%= link_to '', '#', { @@ -40,16 +40,21 @@