1
0

Separated show for date/meal/ingredient

This commit is contained in:
cryptogopher 2020-05-02 15:47:08 +02:00
parent 3ac73ac3a8
commit 4397249fa9
4 changed files with 38 additions and 37 deletions

View File

@ -9,7 +9,7 @@
<tbody>
<% total_width = 4 + @quantities.length %>
<% @meals_by_date.reverse_each do |date, meals| %>
<tr id="date-<%= date.strftime('%Y%m%d') %>" class="header">
<tr class="header">
<td colspan="2" rowspan="2"
style="width:<%= 3 * 100/total_width %>%; border: none;"></td>
<td class="quantityhead" style="width:<%= 100/total_width %>%;">
@ -32,23 +32,13 @@
<% end %>
</tr>
<tr class="date" style="background-color: #fff2cc;">
<td class="date" colspan="2">
<h3 style="margin: 0;">
<%= date == Date.current ? 'Today' : date.strftime('%F') %>
</h3>
</td>
<td class="value ellipsible"></td>
<% @quantities.each do |q| %>
<td class="value ellipsible">
<%= format_value(@nutrient_summary[q][date], @nutrients[q][:precision]) %>
</td>
<% end %>
<td></td>
</tr>
<%= 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 %>
</tbody>

View File

@ -1,5 +1,5 @@
<tr id="meal-<%= m.id %>" class="primary meal project idnt idnt-1"
style="background-color: <%= color %>;">
style="background-color: #d0e0e3;">
<td class="name unwrappable">
<b><%= "#{t '.label_meal'} ##{index+1}" %></b>
<% if m.eaten_at %>
@ -33,6 +33,7 @@
<%= notes(m) %>
</td>
<% end %>
<td class="value ellipsible"></td>
<% @quantities.each do |q| %>
<td class="value ellipsible">
@ -42,23 +43,3 @@
<td class="action unwrappable" style="width: 1%;"><%= meal_links(m) %></td>
</tr>
<% m.ingredients.each do |i| %>
<tr id="ingredient-<%= i.id %>" class="ingredient project idnt idnt-2 buttonable">
<td class="name ellipsible" colspan="2"><%= i.food.name %></td>
<td class="value ellipsible">
<span><%= "%g" % i.amount %></span>
<%= "[#{i.food.ref_unit.shortname}]" unless i.food.ref_unit == @amount_mfu_unit %>
</td>
<% @quantities.each do |q| %>
<td class="value ellipsible">
<%= format_value(@nutrients[q][i], @nutrients[q][:precision],
@nutrients[q][:mfu_unit]) %>
</td>
<% end %>
<td class="action unwrappable" style="width: 1%; text-align: right;">
<%# Moved to helper to avoid spaces between buttons %>
<%= adjustment_buttons(i) %>
</td>
</tr>
<% end %>

View File

@ -0,0 +1,14 @@
<tr id="date-<%= date.strftime('%Y%m%d') %>" class="date" style="background-color: #fff2cc;">
<td class="date" colspan="2">
<h3 style="margin: 0;">
<%= date == Date.current ? 'Today' : date.strftime('%F') %>
</h3>
</td>
<td class="value ellipsible"></td>
<% @quantities.each do |q| %>
<td class="value ellipsible">
<%= format_value(@nutrient_summary[q][date], @nutrients[q][:precision]) %>
</td>
<% end %>
<td></td>
</tr>

View File

@ -0,0 +1,16 @@
<tr id="ingredient-<%= i.id %>" class="ingredient project idnt idnt-2 buttonable">
<td class="name ellipsible" colspan="2"><%= i.food.name %></td>
<td class="value ellipsible">
<span><%= "%g" % i.amount %></span>
<%= "[#{i.food.ref_unit.shortname}]" unless i.food.ref_unit == @amount_mfu_unit %>
</td>
<% @quantities.each do |q| %>
<td class="value ellipsible">
<%= format_value(*@nutrients[q].values_at(i, :precision, :mfu_unit)) %>
</td>
<% end %>
<td class="action unwrappable" style="width: 1%; text-align: right;">
<%# Moved to helper to avoid spaces between buttons %>
<%= adjustment_buttons(i) %>
</td>
</tr>