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/ingredients_helper.rb
2019-11-01 21:43:56 +01:00

36 lines
742 B
Ruby

module IngredientsHelper
def quantity_options
nested_set_options(@project.quantities.diet) do |q|
raw("#{' ' * q.level}#{q.name}")
end
end
def nutrient_column_options
disabled = []
options = nested_set_options(@project.quantities.diet) do |q|
disabled << q.id if q.primary
raw("#{'&ensp;' * q.level}#{q.name}")
end
options_for_select(options, disabled: disabled)
end
def unit_options
@project.units.map do |u|
[u.shortname, u.id]
end
end
def source_options
@project.sources.map do |s|
[s.name, s.id]
end
end
def group_options
translations = t('.groups')
Ingredient.groups.map do |k,v|
[translations[k.to_sym], k]
end
end
end