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/helpers/meals_helper.rb
2020-04-20 21:43:12 +02:00

25 lines
758 B
Ruby

module MealsHelper
def meal_links(m)
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_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)
content_tag(:span, m.notes) +
link_to(l(:button_notes), edit_notes_meal_path(m),
{remote: true, class: "icon icon-wiki-page", style: "float: right"})
end
end