1
0
This repository has been archived on 2023-12-07. You can view files and clone it, but cannot push or open issues or pull requests.
body_tracking/app/views/meals/_index.html.erb
2020-05-01 23:44:37 +02:00

62 lines
2.2 KiB
Plaintext

<% if @meals_by_date.any? %>
<%= render partial: 'meals/options' %>
<% formulas = @quantities.map { |q| q.formula } %>
<% formulas.unshift(@filter_q.formula) if @filter_q %>
<%= error_messages_for *formulas %>
<table id="meals" class="list odd-even">
<tbody>
<% total_width = 4 + @quantities.length %>
<% @meals_by_date.reverse_each do |date, meals| %>
<tr id="date-<%= date.strftime('%Y%m%d') %>" class="date">
<td colspan="2" rowspan="2" style="width:<%= 3 * 100/total_width %>%"></td>
<td class="quantityhead" style="width:<%= 100/total_width %>%;">
<%= l(:field_amount) %>
</td>
<% @quantities.each do |q| %>
<td class="quantityhead" style="width: <%= 100/total_width %>%;"
title="<%= q.description %>">
<%= q.name %>
</td>
<% end %>
<td style="width:<%= 100/total_width %>%"></td>
</tr>
<tr>
<td class="quantityhead"><%= "[#{@amount_mfu_unit.shortname}]" %></td>
<% @quantities.each do |q| %>
<% mfu_unit = @nutrients[q][:mfu_unit] %>
<td class="quantityhead"><%= "[#{mfu_unit ? mfu_unit.shortname : '-'}]" %></td>
<% end %>
</tr>
<tr style="border: solid 2px #d9ead3;">
<td class="date" colspan="2" style="background-color: #d9ead3;">
<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>
<% meals.each_with_index do |m, index| %>
<%= render partial: 'meals/show', locals: {
m: m, index: index,
color: cycle('#d0e0e3', '#c9daf8', '#cfe2f3', '#d9d2e9', '#ead1dc')
} %>
<% end %>
<% reset_cycle %>
<% end %>
</tbody>
</table>
<% else %>
<p class="nodata"><%= l(:label_no_data) %></p>
<% end %>