Class: Decidim::Proposals::ProposalForm
- Inherits:
-
ProposalWizardCreateStepForm
- Object
- Form
- ProposalWizardCreateStepForm
- Decidim::Proposals::ProposalForm
- Defined in:
- app/forms/decidim/proposals/proposal_form.rb
Overview
A form object to be used when public users want to create a proposal.
Direct Known Subclasses
Instance Method Summary collapse
-
#category ⇒ Object
Finds the Category from the category_id.
- #component_automatic_hashtags ⇒ Object
- #component_suggested_hashtags ⇒ Object
- #extra_hashtags ⇒ Object
- #has_address? ⇒ Boolean
- #map_model(model) ⇒ Object
-
#scope ⇒ Object
Finds the Scope from the given decidim_scope_id, uses participatory space scope if missing.
-
#scope_id ⇒ Object
Scope identifier.
- #suggested_hashtag_checked?(hashtag) ⇒ Boolean
- #suggested_hashtags ⇒ Object
Instance Method Details
#category ⇒ Object
Finds the Category from the category_id.
Returns a Decidim::Category
38 39 40 |
# File 'app/forms/decidim/proposals/proposal_form.rb', line 38 def category @category ||= categories.find_by(id: category_id) end |
#component_automatic_hashtags ⇒ Object
73 74 75 |
# File 'app/forms/decidim/proposals/proposal_form.rb', line 73 def @component_automatic_hashtags ||= ordered_hashtag_list(current_component.current_settings.) end |
#component_suggested_hashtags ⇒ Object
77 78 79 |
# File 'app/forms/decidim/proposals/proposal_form.rb', line 77 def @component_suggested_hashtags ||= ordered_hashtag_list(current_component.current_settings.) end |
#extra_hashtags ⇒ Object
60 61 62 |
# File 'app/forms/decidim/proposals/proposal_form.rb', line 60 def @extra_hashtags ||= ( + ).uniq end |
#has_address? ⇒ Boolean
56 57 58 |
# File 'app/forms/decidim/proposals/proposal_form.rb', line 56 def has_address? current_component.settings.geocoding_enabled? && has_address end |
#map_model(model) ⇒ Object
29 30 31 32 33 |
# File 'app/forms/decidim/proposals/proposal_form.rb', line 29 def map_model(model) super @suggested_hashtags = Decidim::ContentRenderers::HashtagRenderer.new(model.body)..map(&:name).map(&:downcase) end |
#scope ⇒ Object
Finds the Scope from the given decidim_scope_id, uses participatory space scope if missing.
Returns a Decidim::Scope
45 46 47 |
# File 'app/forms/decidim/proposals/proposal_form.rb', line 45 def scope @scope ||= @scope_id ? current_participatory_space.scopes.find_by(id: @scope_id) : current_participatory_space.scope end |
#scope_id ⇒ Object
Scope identifier
Returns the scope identifier related to the proposal
52 53 54 |
# File 'app/forms/decidim/proposals/proposal_form.rb', line 52 def scope_id @scope_id || scope&.id end |
#suggested_hashtag_checked?(hashtag) ⇒ Boolean
69 70 71 |
# File 'app/forms/decidim/proposals/proposal_form.rb', line 69 def suggested_hashtag_checked?(hashtag) .member?(hashtag) end |
#suggested_hashtags ⇒ Object
64 65 66 67 |
# File 'app/forms/decidim/proposals/proposal_form.rb', line 64 def = Array(@suggested_hashtags&.map(&:downcase)).to_set .select { |hashtag| .member?(hashtag.downcase) } end |