Buttons/amount in separate columns
This commit is contained in:
parent
baaefb2b68
commit
6b5cb85b11
@ -5,17 +5,6 @@ module MealsHelper
|
|||||||
delete_link(meal_path(m), {remote: true, data: {}})
|
delete_link(meal_path(m), {remote: true, data: {}})
|
||||||
end
|
end
|
||||||
|
|
||||||
def adjust_ingredient_links(i)
|
|
||||||
{'- -' => -10, '-' => -1, nil => 0, '+' => 1, '++' => 10}.map do |text, value|
|
|
||||||
if text
|
|
||||||
link_to text, adjust_ingredient_path(i, adjustment: value),
|
|
||||||
{remote: true, method: :post, class: "button #{value>0 ? 'green' : 'red'}"}
|
|
||||||
else
|
|
||||||
yield.to_s
|
|
||||||
end
|
|
||||||
end.reduce(:+)
|
|
||||||
end
|
|
||||||
|
|
||||||
def display_notes(m)
|
def display_notes(m)
|
||||||
content_tag(:span, m.notes) +
|
content_tag(:span, m.notes) +
|
||||||
link_to(l(:button_notes), edit_notes_meal_path(m),
|
link_to(l(:button_notes), edit_notes_meal_path(m),
|
||||||
|
@ -10,20 +10,29 @@
|
|||||||
{remote: true, method: :post, class: "icon icon-time"} %>
|
{remote: true, method: :post, class: "icon icon-time"} %>
|
||||||
<% end %>
|
<% end %>
|
||||||
</td>
|
</td>
|
||||||
<td id="notes-<%= m.id %>" class="notes" style="text-align: left; border-left: none;">
|
<td id="notes-<%= m.id %>" class="notes" style="text-align: left; border-left: none;"
|
||||||
<%= display_notes(m) %>
|
colspan="4"><%= display_notes(m) %></td>
|
||||||
</td>
|
|
||||||
<td class="action" style="width: 5%;"><%= meal_links(m) %></td>
|
<td class="action" style="width: 5%;"><%= meal_links(m) %></td>
|
||||||
</tr>
|
</tr>
|
||||||
|
|
||||||
<% m.ingredients.each do |i| %>
|
<% m.ingredients.each do |i| %>
|
||||||
<tr id="ingredient-<%= i.id %>" class="ingredient project idnt idnt-2 buttonable">
|
<tr id="ingredient-<%= i.id %>" class="ingredient project idnt idnt-2 buttonable">
|
||||||
<td class="name unwrappable" style="width: 5%;">
|
<td class="name unwrappable" style="width: 5%;"><%= i.food.name %></td>
|
||||||
<%= i.food.name %>
|
<td class="unwrappable" style="width: 1%;">
|
||||||
</td>
|
<% {'- -' => -10, '-' => -1, nil => 0, '+' => 1, '++' => 10}.map do |text, value| %>
|
||||||
<td class="amount unwrappable" style="text-align: left;" colspan="2">
|
<% if text %>
|
||||||
<%= adjust_ingredient_links(i) { raw " <span>#{i.amount}</span> " } %>
|
<%= link_to text, adjust_ingredient_path(i, adjustment: value),
|
||||||
|
{remote: true, method: :post, class: "button #{value>0 ? 'green' : 'red'}"} %>
|
||||||
|
<% else %>
|
||||||
|
</td>
|
||||||
|
<td class="amount unwrappable" style="width: 1%; text-align: right;">
|
||||||
|
<span><%= i.amount %></span>[<%= i.food.ref_unit.shortname %>]
|
||||||
|
</td>
|
||||||
|
<td class="unwrappable" style="width: 1%;">
|
||||||
|
<% end %>
|
||||||
|
<% end %>
|
||||||
</td>
|
</td>
|
||||||
|
<td></td>
|
||||||
</tr>
|
</tr>
|
||||||
<% end %>
|
<% end %>
|
||||||
</tr>
|
</tr>
|
||||||
|
Reference in New Issue
Block a user