diff --git a/app/views/meals/_index.html.erb b/app/views/meals/_index.html.erb index eee050b..bd8d279 100644 --- a/app/views/meals/_index.html.erb +++ b/app/views/meals/_index.html.erb @@ -9,7 +9,7 @@ <% total_width = 4 + @quantities.length %> <% @meals_by_date.reverse_each do |date, meals| %> - + @@ -32,23 +32,13 @@ <% end %> - - -

- <%= date == Date.current ? 'Today' : date.strftime('%F') %> -

- - - <% @quantities.each do |q| %> - - <%= format_value(@nutrient_summary[q][date], @nutrients[q][:precision]) %> - - <% end %> - - + <%= render partial: 'meals/show_date', locals: {date: date} %> <% meals.each_with_index do |m, index| %> - <%= render partial: 'meals/show', locals: {m: m, index: index, color: '#d0e0e3'} %> + <%= render partial: 'meals/show', locals: {m: m, index: index} %> + <% m.ingredients.each do |i| %> + <%= render partial: 'meals/show_ingredient', locals: {i: i} %> + <% end %> <% end %> <% end %> diff --git a/app/views/meals/_show.html.erb b/app/views/meals/_show.html.erb index 67224a9..4dac486 100644 --- a/app/views/meals/_show.html.erb +++ b/app/views/meals/_show.html.erb @@ -1,5 +1,5 @@ + style="background-color: #d0e0e3;"> <%= "#{t '.label_meal'} ##{index+1}" %> <% if m.eaten_at %> @@ -33,6 +33,7 @@ <%= notes(m) %> <% end %> + <% @quantities.each do |q| %> @@ -42,23 +43,3 @@ <%= meal_links(m) %> - -<% m.ingredients.each do |i| %> - - <%= i.food.name %> - - <%= "%g" % i.amount %> - <%= "[#{i.food.ref_unit.shortname}]" unless i.food.ref_unit == @amount_mfu_unit %> - - <% @quantities.each do |q| %> - - <%= format_value(@nutrients[q][i], @nutrients[q][:precision], - @nutrients[q][:mfu_unit]) %> - - <% end %> - - <%# Moved to helper to avoid spaces between buttons %> - <%= adjustment_buttons(i) %> - - -<% end %> diff --git a/app/views/meals/_show_date.html.erb b/app/views/meals/_show_date.html.erb new file mode 100644 index 0000000..3ef31eb --- /dev/null +++ b/app/views/meals/_show_date.html.erb @@ -0,0 +1,14 @@ + + +

+ <%= date == Date.current ? 'Today' : date.strftime('%F') %> +

+ + + <% @quantities.each do |q| %> + + <%= format_value(@nutrient_summary[q][date], @nutrients[q][:precision]) %> + + <% end %> + + diff --git a/app/views/meals/_show_ingredient.html.erb b/app/views/meals/_show_ingredient.html.erb new file mode 100644 index 0000000..40a13be --- /dev/null +++ b/app/views/meals/_show_ingredient.html.erb @@ -0,0 +1,16 @@ + + <%= i.food.name %> + + <%= "%g" % i.amount %> + <%= "[#{i.food.ref_unit.shortname}]" unless i.food.ref_unit == @amount_mfu_unit %> + + <% @quantities.each do |q| %> + + <%= format_value(*@nutrients[q].values_at(i, :precision, :mfu_unit)) %> + + <% end %> + + <%# Moved to helper to avoid spaces between buttons %> + <%= adjustment_buttons(i) %> + +