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-04-18 20:36:09 +02:00

43 lines
1.7 KiB
Plaintext

<% if @meals.any? { |m| m.persisted? } %>
<table id="meals" class="odd-even list">
<tbody>
<% @meals.group_by { |m| m.eaten_at.date if m.eaten_at }.each do |d, meals| %>
<% meals.each_with_index do |m, index| %>
<% next if m.new_record? %>
<tr id="meal-<%= m.id %>" class="primary meal">
<td class="name" colspan="2">
<b><%= "#{t '.label_meal'} ##{index+1}" %></b>
<% if m.eaten_at %>
<%= " - #{m.eaten_at.time}" %>
<%= link_to '', toggle_eaten_meal_path(m),
{remote: true, class: "icon icon-close"} %>
<% else %>
<%= link_to l(:button_eat), toggle_eaten_meal_path(m),
{remote: true, class: "icon icon-ok"} %>
<% end %>
<%= link_to l(:button_note), note_meal_path(m),
{remote: true, class: "icon icon-wiki-page"} %>
<div style="float: right; position: relative;">
<%= meal_links(m) %>
</div>
</td>
</tr>
<% m.ingredients.each do |i| %>
<tr id="ingredient-<%= i.id %>" class="ingredient project idnt idnt-1 buttonable">
<td class="name unwrappable" style="width: 5%;">
<%= i.food.name %>
</td>
<td style="text-align: left;" class="unwrappable">
<%= adjust_ingredient_links(i) { raw "&emsp;#{i.amount}&emsp;" } %>
</td>
</tr>
<% end %>
</tr>
<% end %>
<% end %>
</tbody>
</table>
<% else %>
<p class="nodata"><%= l(:label_no_data) %></p>
<% end %>