Sha256: a5ab92a4be177a0ee85e1a1177a64558c1bc2ac41728db471e76a43e19f408fa

Contents?: true

Size: 1.14 KB

Versions: 12

Compression:

Stored size: 1.14 KB

Contents

# frozen_string_literal: true

module Decidim
  module Plans
    module Admin
      # A form object to be used when admin users want to export a collection of
      # plans into the budgeting projects component.
      class PlanExportBudgetsForm < Decidim::Form
        mimic :budgets_export

        attribute :target_component_id, Integer
        attribute :default_budget, Integer
        attribute :export_all_closed_plans, Boolean

        validates :target_component_id, :target_component, :current_component, presence: true
        validates :export_all_closed_plans, allow_nil: false, acceptance: true
        validates :default_budget, presence: true, numericality: { greater_than: 0 }

        def target_component
          @target_component ||= target_components.find_by(id: target_component_id)
        end

        def target_components
          @target_components ||= current_participatory_space.components.where(manifest_name: :budgets)
        end

        def target_components_collection
          target_components.map do |component|
            [component.name[I18n.locale.to_s], component.id]
          end
        end
      end
    end
  end
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
decidim-plans-0.18.2 app/forms/decidim/plans/admin/plan_export_budgets_form.rb
decidim-plans-0.18.1 app/forms/decidim/plans/admin/plan_export_budgets_form.rb
decidim-plans-0.18.0 app/forms/decidim/plans/admin/plan_export_budgets_form.rb
decidim-plans-0.17.0 app/forms/decidim/plans/admin/plan_export_budgets_form.rb
decidim-plans-0.16.9 app/forms/decidim/plans/admin/plan_export_budgets_form.rb
decidim-plans-0.16.8 app/forms/decidim/plans/admin/plan_export_budgets_form.rb
decidim-plans-0.16.7 app/forms/decidim/plans/admin/plan_export_budgets_form.rb
decidim-plans-0.16.6 app/forms/decidim/plans/admin/plan_export_budgets_form.rb
decidim-plans-0.16.5 app/forms/decidim/plans/admin/plan_export_budgets_form.rb
decidim-plans-0.16.4 app/forms/decidim/plans/admin/plan_export_budgets_form.rb
decidim-plans-0.16.3 app/forms/decidim/plans/admin/plan_export_budgets_form.rb
decidim-plans-0.16.2 app/forms/decidim/plans/admin/plan_export_budgets_form.rb