Class: Decidim::Proposals::Admin::ProposalsImportForm
- Inherits:
-
Form
- Object
- Form
- Decidim::Proposals::Admin::ProposalsImportForm
- 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
- #origin_feature ⇒ Object
- #origin_features ⇒ Object
- #origin_features_collection ⇒ Object
- #states ⇒ Object
- #states_collection ⇒ Object
Instance Method Details
#origin_feature ⇒ Object
34 35 36 |
# File 'app/forms/decidim/proposals/admin/proposals_import_form.rb', line 34 def origin_feature @origin_feature ||= origin_features.find_by(id: origin_feature_id) end |
#origin_features ⇒ Object
38 39 40 |
# File 'app/forms/decidim/proposals/admin/proposals_import_form.rb', line 38 def origin_features @origin_features ||= current_participatory_space.features.where.not(id: current_feature.id).where(manifest_name: :proposals) end |
#origin_features_collection ⇒ Object
42 43 44 45 46 |
# File 'app/forms/decidim/proposals/admin/proposals_import_form.rb', line 42 def origin_features_collection origin_features.map do |feature| [feature.name[I18n.locale.to_s], feature.id] end end |
#states ⇒ Object
30 31 32 |
# File 'app/forms/decidim/proposals/admin/proposals_import_form.rb', line 30 def states super.reject(&:blank?) end |
#states_collection ⇒ Object
21 22 23 24 25 26 27 28 |
# File 'app/forms/decidim/proposals/admin/proposals_import_form.rb', line 21 def states_collection VALID_STATES.map do |state| OpenStruct.new( name: I18n.t(state, scope: "decidim.proposals.answers"), value: state ) end end |