From 526a4b1fe694e7eb4a4e63ec68fbd48b3a60ece0 Mon Sep 17 00:00:00 2001 From: cryptogopher Date: Thu, 31 Oct 2019 23:00:40 +0100 Subject: [PATCH] Better expanding of extra nutrients --- app/views/ingredients/nutrients.html.erb | 28 ++++++++++++++++++++++-- assets/stylesheets/body_tracking.css | 4 ++-- 2 files changed, 28 insertions(+), 4 deletions(-) diff --git a/app/views/ingredients/nutrients.html.erb b/app/views/ingredients/nutrients.html.erb index 6094c57..411bad6 100644 --- a/app/views/ingredients/nutrients.html.erb +++ b/app/views/ingredients/nutrients.html.erb @@ -25,11 +25,12 @@ <% @primary_nutrients.each do |i, values| %> + <% row_class = "ingredient#{' hidden' if i.hidden} #{cycle('odd', 'even')}" %> <%= link_to '', '#', { - onclick: "$(this).closest('tr').nextUntil('tr.primary', 'tr').toggle(); $(this).toggleClass('icon-bullet-closed'); $(this).toggleClass('icon-bullet-open'); return false;", + onclick: "$(this).closest('tr').toggle(); $(this).closest('tr').nextUntil('tr.primary', 'tr').toggle(); return false;", class: "icon icon-bullet-closed" } %> <%= i.name %> @@ -40,6 +41,29 @@ <% end %> + + + + <%= link_to '', '#', { + onclick: "$(this).closest('tr').prev('tr.primary').toggle(); $(this).closest('tr').prev('tr.primary').nextUntil('tr.primary', 'tr').toggle(); return false;", + class: "icon icon-bullet-open" + } %> + <%= i.name %> + + <% @primary_quantities.each do |q| %> + + <%= q.name %> + + <% end %> + + + <% @primary_quantities.each do |q| %> + + <%= values[q.id] || '-' %> + + <% end %> + + <% extras = @extra_nutrients[i].keys %> <% extras.each_slice(@primary_quantities.length).with_index do |names, index| %> @@ -59,13 +83,13 @@ <% names.each do |name| %> - <% title = %> <%= @extra_nutrients[i][name] %> <% end %> <% end %> + <% end %> diff --git a/assets/stylesheets/body_tracking.css b/assets/stylesheets/body_tracking.css index bc01a58..c5639d6 100644 --- a/assets/stylesheets/body_tracking.css +++ b/assets/stylesheets/body_tracking.css @@ -1,8 +1,8 @@ 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.quantity {text-align: left; border-bottom: none;} table.nutrients.list td.space, -table.list td.value.extra {border-top: none;} +table.nutrients.list td.value {border-top: none;} table.list tr.ingredient.hidden {opacity: 0.4} table.list td.action, table.list td.value {text-align: right;}