Class: Decidim::Proposals::Admin::ProposalsImportForm

Inherits:
Form
  • Object
show all
Defined in:
app/forms/decidim/proposals/admin/proposals_import_form.rb

Overview

A form object to be used when admin users want to import a collection of proposals from another component.

Constant Summary collapse

VALID_STATES =
%w(accepted not_answered evaluating rejected withdrawn).freeze

Instance Method Summary collapse

Instance Method Details

#origin_componentObject



35
36
37
# File 'app/forms/decidim/proposals/admin/proposals_import_form.rb', line 35

def origin_component
  @origin_component ||= origin_components.find_by(id: origin_component_id)
end

#origin_componentsObject



39
40
41
# File 'app/forms/decidim/proposals/admin/proposals_import_form.rb', line 39

def origin_components
  @origin_components ||= current_participatory_space.components.where.not(id: current_component.id).where(manifest_name: :proposals)
end

#origin_components_collectionObject



43
44
45
46
47
# File 'app/forms/decidim/proposals/admin/proposals_import_form.rb', line 43

def origin_components_collection
  origin_components.map do |component|
    [component.name[I18n.locale.to_s], component.id]
  end
end

#statesObject



31
32
33
# File 'app/forms/decidim/proposals/admin/proposals_import_form.rb', line 31

def states
  super.reject(&:blank?)
end

#states_collectionObject



22
23
24
25
26
27
28
29
# File 'app/forms/decidim/proposals/admin/proposals_import_form.rb', line 22

def states_collection
  VALID_STATES.map do |state|
    OpenStruct.new(
      name: I18n.t(state, scope: "decidim.proposals.answers"),
      value: state
    )
  end
end