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,9 +1,18 @@
module MealsHelper
def meal_links(m)
delete_link(meal_path(m), {remote: true, data: {}}) if m.persisted?
link_to(l(:button_edit), edit_meal_path(m),
{remote: true, class: "icon icon-edit"}) +
delete_link(meal_path(m), {remote: true, data: {}})
end
def adjust_ingredient_link(i, adjustment)
link_to "%+d" % adjustment, adjust_ingredient_path(i, adjustment: adjustment),
{remote: true, method: :post}
def adjust_ingredient_links(i)
[-10, -1, 0, 1, 10].map do |v|
if v != 0
link_to "%+d" % v, adjust_ingredient_path(i, adjustment: v),
{remote: true, method: :post, class: "button #{v>0 ? 'green' : 'red'}"}
else
yield.to_s
end
end.reduce(:+)
end
end

View File

@@ -1,4 +1,23 @@
module QuantitiesHelper
def order_links(q)
[:up, :down, :left, :right].map 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.reduce(:+)
end
def action_links(q)
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: {}})
end
def domain_options
translations = t('quantities.form.domains')
Quantity.domains.map do |k,v|