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/foods_helper.rb
cryptogopher 8e8160c41a Renamed Ingredient -> Food
Ingredient is now part of composition (meal/recipe/dish)
2020-04-14 19:44:19 +02:00

42 lines
1.0 KiB
Ruby

module FoodsHelper
def quantity_options
nested_set_options(@project.quantities.diet) do |q|
raw("#{' ' * q.level}#{q.name}")
end
end
def toggle_column_options
disabled = []
enabled_quantities = @project.nutrient_quantities.to_a
options = nested_set_options(@project.quantities.diet) do |q|
disabled << q.id if enabled_quantities.include?(q)
raw("#{'&ensp;' * q.level}#{q.name}")
end
options_for_select(options, disabled: disabled)
end
def visibility_options(selected)
options = [["visible", 1], ["hidden", 0]]
options_for_select(options, selected)
end
def source_options
@project.sources.map do |s|
[s.name, s.id]
end
end
def group_options
translations = t('.groups')
Food.groups.map do |k,v|
[translations[k.to_sym], k]
end
end
def action_links(f, view)
link_to(l(:button_edit), edit_food_path(f, view: view),
{remote: true, class: "icon icon-edit"}) +
delete_link(food_path(f), {remote: true, data: {}})
end
end