Class: Decidim::Solutions::Admin::SolutionsForm
- Inherits:
-
Form
- Object
- Form
- Decidim::Solutions::Admin::SolutionsForm
- Includes:
- TranslatableAttributes
- Defined in:
- app/forms/decidim/solutions/admin/solutions_form.rb
Overview
A form object used to create solutions from the admin dashboard.
Instance Method Summary collapse
-
#challenge ⇒ Object
Finds the Challenge from the given decidim_challenges_challenge_id.
- #map_model(model) ⇒ Object
-
#problem ⇒ Object
Finds the Problem from the given decidim_problems_problem_id.
-
#select_challenge_collection ⇒ Object
Return a challenges’s list filtered by participatory’s space component.
-
#select_problem_collection ⇒ Object
Return a problem’s list filtered by participatory’s space component.
Instance Method Details
#challenge ⇒ Object
Finds the Challenge from the given decidim_challenges_challenge_id
Returns a Decidim::Challenges::Challenge
63 64 65 |
# File 'app/forms/decidim/solutions/admin/solutions_form.rb', line 63 def challenge @challenge ||= @problem.present? ? Decidim::Challenges::Challenge.find(@problem.challenge.id) : false end |
#map_model(model) ⇒ Object
67 |
# File 'app/forms/decidim/solutions/admin/solutions_form.rb', line 67 def map_model(model); end |
#problem ⇒ Object
Finds the Problem from the given decidim_problems_problem_id
Returns a Decidim::Problems::Problem
56 57 58 |
# File 'app/forms/decidim/solutions/admin/solutions_form.rb', line 56 def problem @problem ||= decidim_problems_problem_id.present? ? Decidim::Problems::Problem.find(decidim_problems_problem_id) : false end |
#select_challenge_collection ⇒ Object
Return a challenges’s list filtered by participatory’s space component
45 46 47 48 49 50 51 |
# File 'app/forms/decidim/solutions/admin/solutions_form.rb', line 45 def select_challenge_collection participatory_space = Decidim::Component.find(current_component.id).participatory_space challenge_component = Decidim::Component.where(participatory_space:).where(manifest_name: "challenges") Decidim::Challenges::Challenge.where(component: challenge_component).map do |p| [translated_attribute(p.title), p.id] end end |
#select_problem_collection ⇒ Object
Return a problem’s list filtered by participatory’s space component
36 37 38 39 40 41 42 |
# File 'app/forms/decidim/solutions/admin/solutions_form.rb', line 36 def select_problem_collection participatory_space = Decidim::Component.find(current_component.id).participatory_space problem_component = Decidim::Component.where(participatory_space:).where(manifest_name: "problems") Decidim::Problems::Problem.where(component: problem_component).map do |p| [translated_attribute(p.title), p.id] end end |