Since targets didn't have a title but only a long description, every form allowing to select targets was pretty much unusable: we either displayed just the code or the whole description. Now, with a concise title, it's easier to find and select the desired target. The titles have been copied from The Global Goals page [1]. Note we're using the `short_title` I18n key for the `title` method and the `long_title` I18n key for the `long_title` method. We can't use `title` as I18n key instead of `short_title` because it would affect existing translations. [1] https://www.globalgoals.org/
14 lines
409 B
Ruby
14 lines
409 B
Ruby
module SDG::OptionsForSelect
|
|
extend ActiveSupport::Concern
|
|
|
|
def goal_options(selected_code = nil)
|
|
options_from_collection_for_select(SDG::Goal.order(:code), :code, :code_and_title, selected_code)
|
|
end
|
|
|
|
def target_options(selected_code = nil)
|
|
targets = SDG::Target.all + SDG::LocalTarget.all
|
|
|
|
options_from_collection_for_select(targets.sort, :code, :code_and_title, selected_code)
|
|
end
|
|
end
|