Class: Decidim::Problems::Admin::ProblemsForm
- Inherits:
-
Form
- Object
- Form
- Decidim::Problems::Admin::ProblemsForm
- Includes:
- TranslatableAttributes
- Defined in:
- app/forms/decidim/problems/admin/problems_form.rb
Overview
A form object used to create problems from the admin dashboard.
Instance Method Summary collapse
-
#challenge ⇒ Object
Finds the Challenge from the given decidim_challenges_challenge_id.
- #map_model(model) ⇒ Object
-
#sectorial_scope ⇒ Object
Finds the Sectorial Scope from the given decidim_sectorial_scope_id.
-
#select_challenge_collection ⇒ Object
Return a challenge’s list filtered by participatory’s space component.
-
#select_states_collection ⇒ Object
Return a problem’s valid states list.
-
#technological_scope ⇒ Object
Finds the Technological Scope from the given decidim_technological_scope_id.
Instance Method Details
#challenge ⇒ Object
Finds the Challenge from the given decidim_challenges_challenge_id
Returns a Decidim::Challenges::Challenge
74 75 76 |
# File 'app/forms/decidim/problems/admin/problems_form.rb', line 74 def challenge @challenge ||= @decidim_challenges_challenge_id ? Decidim::Challenges::Challenge.find(@decidim_challenges_challenge_id) : false end |
#map_model(model) ⇒ Object
78 |
# File 'app/forms/decidim/problems/admin/problems_form.rb', line 78 def map_model(model); end |
#sectorial_scope ⇒ Object
Finds the Sectorial Scope from the given decidim_sectorial_scope_id
Returns a Decidim::Scope
60 61 62 |
# File 'app/forms/decidim/problems/admin/problems_form.rb', line 60 def sectorial_scope @sectorial_scope ||= current_organization.scopes.find_by(id: decidim_sectorial_scope_id) end |
#select_challenge_collection ⇒ Object
Return a challenge’s list filtered by participatory’s space component
49 50 51 52 53 54 55 |
# File 'app/forms/decidim/problems/admin/problems_form.rb', line 49 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 |ch| [translated_attribute(ch.title), ch.id] end end |
#select_states_collection ⇒ Object
Return a problem’s valid states list
42 43 44 45 46 |
# File 'app/forms/decidim/problems/admin/problems_form.rb', line 42 def select_states_collection Decidim::Problems::Problem::VALID_STATES.map.with_index do |state, idx| [I18n.t(state, scope: "decidim.problems.states"), idx] end end |
#technological_scope ⇒ Object
Finds the Technological Scope from the given decidim_technological_scope_id
Returns a Decidim::Scope
67 68 69 |
# File 'app/forms/decidim/problems/admin/problems_form.rb', line 67 def technological_scope @technological_scope ||= current_organization.scopes.find_by(id: decidim_technological_scope_id) end |