Class: Decidim::Results::Admin::ResultForm
Overview
This class holds a Form to create/update results from Decidim’s admin panel.
Instance Method Summary
collapse
multi_translation, #translated_attribute
Methods inherited from Form
#available_locales
Instance Method Details
#category ⇒ Object
47
48
49
|
# File 'decidim-results/app/forms/decidim/results/admin/result_form.rb', line 47
def category
@category ||= context.current_feature.categories.where(id: decidim_category_id).first
end
|
#map_model(model) ⇒ Object
23
24
25
26
27
28
29
|
# File 'decidim-results/app/forms/decidim/results/admin/result_form.rb', line 23
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
|
#organization_scopes ⇒ Object
35
36
37
|
# File 'decidim-results/app/forms/decidim/results/admin/result_form.rb', line 35
def organization_scopes
current_organization.scopes
end
|
#process_scope ⇒ Object
39
40
41
|
# File 'decidim-results/app/forms/decidim/results/admin/result_form.rb', line 39
def process_scope
current_feature.participatory_process.scope
end
|
#proposals ⇒ Object
31
32
33
|
# File 'decidim-results/app/forms/decidim/results/admin/result_form.rb', line 31
def proposals
@proposals ||= Decidim.find_resource_manifest(:proposals).try(:resource_scope, context.current_feature)&.order(title: :asc)&.pluck(:title, :id)
end
|
#scope ⇒ Object
43
44
45
|
# File 'decidim-results/app/forms/decidim/results/admin/result_form.rb', line 43
def scope
@scope ||= organization_scopes.where(id: decidim_scope_id).first || process_scope
end
|