Class: Decidim::Budgets::Admin::ProjectForm
- Inherits:
-
Form
- Object
- Form
- Decidim::Budgets::Admin::ProjectForm
- Includes:
- ApplicationHelper, 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
-
#category ⇒ Object
Finds the Category from the decidim_category_id.
-
#decidim_scope_id ⇒ Object
Scope identifier.
- #map_model(model) ⇒ Object
- #proposals ⇒ Object
-
#scope ⇒ Object
Finds the Scope from the given decidim_scope_id, uses participatory space scope if missing.
Instance Method Details
#category ⇒ Object
Finds the Category from the decidim_category_id.
Returns a Decidim::Category
49 50 51 |
# File 'app/forms/decidim/budgets/admin/project_form.rb', line 49 def category @category ||= categories.find_by(id: decidim_category_id) end |
#decidim_scope_id ⇒ Object
Scope identifier
Returns the scope identifier related to the project
63 64 65 |
# File 'app/forms/decidim/budgets/admin/project_form.rb', line 63 def decidim_scope_id @decidim_scope_id || scope&.id end |
#map_model(model) ⇒ Object
31 32 33 34 35 36 37 |
# File 'app/forms/decidim/budgets/admin/project_form.rb', line 31 def map_model(model) self.proposal_ids = model.linked_resources(:proposals, "included_proposals").pluck(:id) return unless model.categorization self.decidim_category_id = model.categorization.decidim_category_id end |
#proposals ⇒ Object
39 40 41 42 43 44 |
# File 'app/forms/decidim/budgets/admin/project_form.rb', line 39 def proposals @proposals ||= Decidim.find_resource_manifest(:proposals).try(:resource_scope, current_component) &.published &.order(title: :asc) &.map { |proposal| [present(proposal).title, proposal.id] } end |
#scope ⇒ Object
Finds the Scope from the given decidim_scope_id, uses participatory space scope if missing.
Returns a Decidim::Scope
56 57 58 |
# File 'app/forms/decidim/budgets/admin/project_form.rb', line 56 def scope @scope ||= @decidim_scope_id ? current_participatory_space.scopes.find_by(id: @decidim_scope_id) : current_participatory_space.scope end |