Class: Decidim::Proposals::Admin::ProposalsForkForm

Inherits:
Form show all
Defined in:
decidim-proposals/app/forms/decidim/proposals/admin/proposals_fork_form.rb

Overview

A common abstract to be used by the Merge and Split proposals forms.

Direct Known Subclasses

ProposalsMergeForm, ProposalsSplitForm

Constant Summary

Constants included from AttributeObject::TypeMap

AttributeObject::TypeMap::Boolean, AttributeObject::TypeMap::Decimal

Instance Attribute Summary

Attributes inherited from AttributeObject::Form

#context

Instance Method Summary collapse

Methods inherited from AttributeObject::Form

ensure_hash, from_model, from_params, hash_from, infer_model_name, #map_model, mimic, mimicked_model_name, model_name, #persisted?, #to_key, #to_model, #to_param, #valid?, #with_context

Methods included from AttributeObject::Model

#[], #[]=, #attributes, #attributes_with_values, #initialize, #to_h

Instance Method Details

#proposalsObject


17
18
19
# File 'decidim-proposals/app/forms/decidim/proposals/admin/proposals_fork_form.rb', line 17

def proposals
  @proposals ||= Decidim::Proposals::Proposal.where(component: current_component, id: proposal_ids).uniq
end

#same_component?Boolean

Returns:


27
28
29
# File 'decidim-proposals/app/forms/decidim/proposals/admin/proposals_fork_form.rb', line 27

def same_component?
  target_component == current_component
end

#target_componentObject


21
22
23
24
25
# File 'decidim-proposals/app/forms/decidim/proposals/admin/proposals_fork_form.rb', line 21

def target_component
  return current_component if clean_target_component_id == current_component.id

  @target_component ||= current_component.siblings.find_by(id: target_component_id)
end