1
0

Meals index, WIP

This commit is contained in:
cryptogopher
2020-04-18 18:29:53 +02:00
parent 3ff36df168
commit 50b89de904
10 changed files with 90 additions and 55 deletions

View File

@@ -1,35 +1,34 @@
<% if @meals.any? { |m| m.persisted? } %>
<table id="meals" class="odd-even">
<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">
<h4>
<%= "#{t '.label_meal'}" %><%= index ? " ##{index+1}" : " (new)" %>
<%= ", #{m.eaten_at.time}" if m.eaten_at %>
</h4>
<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>
<td class="action unwrappable" style="width:5%"><%= meal_links(m) %></td>
</tr>
<% m.ingredients.each do |i| %>
<tr id="ingredient-<%= i.id %>" class="ingredient">
<td class="name" style="width: 100%;">
<p>
<tr id="ingredient-<%= i.id %>" class="ingredient project idnt idnt-1">
<td class="name unwrappable" style="width: 5%;">
<%= i.food.name %>
</p>
</td>
<td>
<p style='white-space: nowrap;'>
<%= adjust_ingredient_link(i, -5) %>
<%= adjust_ingredient_link(i, -1) %>
<%= i.amount %>
<%= adjust_ingredient_link(i, 1) %>
<%= adjust_ingredient_link(i, 5) %>
</p>
</td>
<td class="action unwrappable" style="width:5%">
<td style="text-align: left;" class="unwrappable">
<%= adjust_ingredient_links(i) { raw "&emsp;#{i.amount}&emsp;" } %>
</td>
</tr>
<% end %>

View File

@@ -27,35 +27,11 @@
<%= q.name %>
</div>
</td>
<td class="order">
<% [:up, :down, :left, :right].each do |direction| %>
<%=
if q.movable?(direction)
link_to '', move_quantity_path(q, direction), {
remote: true,
method: :post,
class: "icon icon-move icon-move-#{direction}"
}
else
link_to '', '', {class: "icon", style: "visibility: hidden;"}
end
%>
<% end %>
</td>
<td class="order"><%= order_links(q) %></td>
<td class="domain"><%= q.domain %></td>
<td class="description"><%= q.description %></td>
<td class="formula"><%= checked_image q.formula %></td>
<td class="action unwrappable">
<%= link_to l(:button_child), new_child_quantity_path(q), {
remote: true,
class: "icon icon-add"
} %>
<%= link_to l(:button_edit), edit_quantity_path(q), {
remote: true,
class: "icon icon-edit"
} %>
<%= delete_link quantity_path(q), {remote: true, data: {}} %>
</td>
<td class="action unwrappable"><%= action_links(q) %></td>
</tr>
<% end %>
</tbody>