Sha256: 5f83bf2f874931cb09bf0dc4821269710ce2804d2f320b71a111b5645e0bea33

Contents?: true

Size: 916 Bytes

Versions: 7

Compression:

Stored size: 916 Bytes

Contents

# frozen_string_literal: true

module Decidim
  module Elections
    module Admin
      # This class holds a form to perform an action on the BB.
      class ActionForm < Decidim::Form
        validates :pending_action, absence: true

        def messages
          @messages ||= {}
        end

        def current_step
          @current_step ||= election.bb_status
        end

        def election
          @election ||= context[:election]
        end

        def pending_action
          return @pending_action if defined?(@pending_action)

          @pending_action = election.actions.pending.first
        end

        def bulletin_board
          @bulletin_board ||= context[:bulletin_board] || Decidim::Elections.bulletin_board
        end

        def refresh
          remove_instance_variable(:@pending_action)
          remove_instance_variable(:@current_step)
        end
      end
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
decidim-elections-0.25.2 app/forms/decidim/elections/admin/action_form.rb
decidim-elections-0.25.1 app/forms/decidim/elections/admin/action_form.rb
decidim-elections-0.25.0 app/forms/decidim/elections/admin/action_form.rb
decidim-elections-0.25.0.rc4 app/forms/decidim/elections/admin/action_form.rb
decidim-elections-0.25.0.rc3 app/forms/decidim/elections/admin/action_form.rb
decidim-elections-0.25.0.rc2 app/forms/decidim/elections/admin/action_form.rb
decidim-elections-0.25.0.rc1 app/forms/decidim/elections/admin/action_form.rb