Class: Decidim::Proposals::ProposalForm
- Inherits:
-
Form
- Object
- Form
- Decidim::Proposals::ProposalForm
- Includes:
- AttachmentAttributes, HasTaxonomyFormAttributes, HasUploadValidations, TranslatableAttributes
- 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
- #component_automatic_hashtags ⇒ Object
- #component_suggested_hashtags ⇒ Object
- #extra_hashtags ⇒ Object
- #geocoded? ⇒ Boolean
- #geocoding_enabled? ⇒ Boolean
- #has_address? ⇒ Boolean
- #map_model(model) ⇒ Object
- #participatory_space_manifest ⇒ Object
- #suggested_hashtag_checked?(hashtag) ⇒ Boolean
- #suggested_hashtags ⇒ Object
Instance Method Details
#component_automatic_hashtags ⇒ Object
81 82 83 |
# File 'app/forms/decidim/proposals/proposal_form.rb', line 81 def @component_automatic_hashtags ||= ordered_hashtag_list(current_component.current_settings.) end |
#component_suggested_hashtags ⇒ Object
85 86 87 |
# File 'app/forms/decidim/proposals/proposal_form.rb', line 85 def @component_suggested_hashtags ||= ordered_hashtag_list(current_component.current_settings.) end |
#extra_hashtags ⇒ Object
68 69 70 |
# File 'app/forms/decidim/proposals/proposal_form.rb', line 68 def @extra_hashtags ||= ( + ).uniq end |
#geocoded? ⇒ Boolean
64 65 66 |
# File 'app/forms/decidim/proposals/proposal_form.rb', line 64 def geocoded? latitude.present? && longitude.present? end |
#geocoding_enabled? ⇒ Boolean
56 57 58 |
# File 'app/forms/decidim/proposals/proposal_form.rb', line 56 def geocoding_enabled? Decidim::Map.available?(:geocoding) && current_component.settings.geocoding_enabled? end |
#has_address? ⇒ Boolean
60 61 62 |
# File 'app/forms/decidim/proposals/proposal_form.rb', line 60 def has_address? geocoding_enabled? && address.present? end |
#map_model(model) ⇒ Object
40 41 42 43 44 45 46 47 48 49 50 |
# File 'app/forms/decidim/proposals/proposal_form.rb', line 40 def map_model(model) self.title = translated_attribute(model.title) self.body = translated_attribute(model.body) @suggested_hashtags = Decidim::ContentRenderers::HashtagRenderer.new(body)..map(&:name).map(&:downcase) presenter = ProposalPresenter.new(model) self.body = presenter.editor_body(all_locales: body.is_a?(Hash)) self.user_group_id = model.user_groups.first&.id self.documents = model. end |
#participatory_space_manifest ⇒ Object
52 53 54 |
# File 'app/forms/decidim/proposals/proposal_form.rb', line 52 def participatory_space_manifest @participatory_space_manifest ||= current_component.participatory_space.manifest.name end |
#suggested_hashtag_checked?(hashtag) ⇒ Boolean
77 78 79 |
# File 'app/forms/decidim/proposals/proposal_form.rb', line 77 def suggested_hashtag_checked?(hashtag) .member?(hashtag) end |
#suggested_hashtags ⇒ Object
72 73 74 75 |
# File 'app/forms/decidim/proposals/proposal_form.rb', line 72 def = super.to_set(&:downcase) .select { |hashtag| .member?(hashtag.downcase) } end |