Class: Decidim::Accountability::Admin::ResultForm
- Inherits:
 - 
      Form
      
        
- Object
 - Form
 - Decidim::Accountability::Admin::ResultForm
 
 
- Includes:
 - TranslatableAttributes, TranslationsHelper
 
- Defined in:
 - app/forms/decidim/accountability/admin/result_form.rb
 
Overview
This class holds a Form to create/update results from Decidim’s admin panel.
Instance Method Summary collapse
- #category ⇒ Object
 - 
  
    
      #decidim_scope_id  ⇒ Object 
    
    
  
  
  
  
  
  
  
  
  
    
Scope identifier.
 - #map_model(model) ⇒ Object
 - #parent ⇒ Object
 - #projects ⇒ Object
 - #proposals ⇒ Object
 - 
  
    
      #scope  ⇒ Object 
    
    
  
  
  
  
  
  
  
  
  
    
Finds the Scope from the given decidim_scope_id, uses participatory space scope if missing.
 - #status ⇒ Object
 
Instance Method Details
#category ⇒ Object
      72 73 74  | 
    
      # File 'app/forms/decidim/accountability/admin/result_form.rb', line 72 def category @category ||= categories.find_by(id: decidim_category_id) end  | 
  
#decidim_scope_id ⇒ Object
Scope identifier
Returns the scope identifier related to the result
      68 69 70  | 
    
      # File 'app/forms/decidim/accountability/admin/result_form.rb', line 68 def decidim_scope_id super || scope&.id end  | 
  
#map_model(model) ⇒ Object
      40 41 42 43 44  | 
    
      # File 'app/forms/decidim/accountability/admin/result_form.rb', line 40 def map_model(model) self.proposal_ids = model.linked_resources(:proposals, "included_proposals").pluck(:id) self.project_ids = model.linked_resources(:projects, "included_projects").pluck(:id) self.decidim_category_id = model.category.try(:id) end  | 
  
#parent ⇒ Object
      76 77 78  | 
    
      # File 'app/forms/decidim/accountability/admin/result_form.rb', line 76 def parent @parent ||= Decidim::Accountability::Result.find_by(component: current_component, id: parent_id) end  | 
  
#projects ⇒ Object
      53 54 55 56  | 
    
      # File 'app/forms/decidim/accountability/admin/result_form.rb', line 53 def projects @projects ||= Decidim.find_resource_manifest(:projects).try(:resource_scope, current_component)&.order(title: :asc) &.select(:title, :id)&.map { |a| [a.title[I18n.locale.to_s], a.id] } end  | 
  
#proposals ⇒ Object
      46 47 48 49 50 51  | 
    
      # File 'app/forms/decidim/accountability/admin/result_form.rb', line 46 def proposals @proposals ||= Decidim.find_resource_manifest(:proposals) .try(:resource_scope, current_component) &.where(id: proposal_ids) &.order(title: :asc) end  | 
  
#scope ⇒ Object
Finds the Scope from the given decidim_scope_id, uses participatory space scope if missing.
Returns a Decidim::Scope
      61 62 63  | 
    
      # File 'app/forms/decidim/accountability/admin/result_form.rb', line 61 def scope @scope ||= @attributes["decidim_scope_id"].value ? current_component.scopes.find_by(id: @attributes["decidim_scope_id"].value) : current_component.scope end  | 
  
#status ⇒ Object
      80 81 82  | 
    
      # File 'app/forms/decidim/accountability/admin/result_form.rb', line 80 def status @status ||= Decidim::Accountability::Status.find_by(component: current_component, id: decidim_accountability_status_id) end  |