Meals index, WIP
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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|
|
||||
|
||||
Reference in New Issue
Block a user