Class: Decidim::Budgets::Admin::ProjectForm
- Inherits:
-
Form
- Object
- Form
- Decidim::Budgets::Admin::ProjectForm
- Includes:
- ApplicationHelper, AttachmentAttributes, HasTaxonomyFormAttributes, TranslatableAttributes, TranslationsHelper
- Defined in:
- app/forms/decidim/budgets/admin/project_form.rb
Overview
This class holds a Form to create/update projects from Decidim's admin panel.
Instance Method Summary collapse
-
#budget ⇒ Object
Finds the Budget from the decidim_budgets_budget_id.
- #geocoded? ⇒ Boolean
- #geocoding_enabled? ⇒ Boolean
- #has_address? ⇒ Boolean
- #map_model(model) ⇒ Object
- #participatory_space_manifest ⇒ Object
- #proposals ⇒ Object
Instance Method Details
#budget ⇒ Object
Finds the Budget from the decidim_budgets_budget_id.
Returns a Decidim::Budgets:Budget
68 69 70 |
# File 'app/forms/decidim/budgets/admin/project_form.rb', line 68 def budget @budget ||= context[:budget] end |
#geocoded? ⇒ Boolean
61 62 63 |
# File 'app/forms/decidim/budgets/admin/project_form.rb', line 61 def geocoded? latitude.present? && longitude.present? end |
#geocoding_enabled? ⇒ Boolean
53 54 55 |
# File 'app/forms/decidim/budgets/admin/project_form.rb', line 53 def geocoding_enabled? Decidim::Map.available?(:geocoding) && current_component.settings.geocoding_enabled? end |
#has_address? ⇒ Boolean
57 58 59 |
# File 'app/forms/decidim/budgets/admin/project_form.rb', line 57 def has_address? geocoding_enabled? && address.present? end |
#map_model(model) ⇒ Object
36 37 38 39 40 41 |
# File 'app/forms/decidim/budgets/admin/project_form.rb', line 36 def map_model(model) self.proposal_ids = model.linked_resources(:proposals, "included_proposals").pluck(:id) self.selected = model.selected? self. = model..ids self. = model..map { |att| { id: att.id, title: att.title } } end |
#participatory_space_manifest ⇒ Object
43 44 45 |
# File 'app/forms/decidim/budgets/admin/project_form.rb', line 43 def participatory_space_manifest @participatory_space_manifest ||= current_component.participatory_space.manifest.name end |
#proposals ⇒ Object
47 48 49 50 51 |
# File 'app/forms/decidim/budgets/admin/project_form.rb', line 47 def proposals @proposals ||= Decidim.find_resource_manifest(:proposals).try(:resource_scope, current_component) &.where(id: proposal_ids) &.order(title: :asc) end |