Sha256: b4c7c52873b0f852ecbebe03a79e03d7332b08718eac4a92dc440f5caebf18fc

Contents?: true

Size: 828 Bytes

Versions: 11

Compression:

Stored size: 828 Bytes

Contents

# Displays available polls that the current_user may complete

class EffectivePollsDatatable < Effective::Datatable
  datatable do
    order :start_at

    col :start_at, visible: false

    col :title
    col :available_date, label: 'Date'

    actions_col(actions: []) do |poll|
      ballot = poll.ballots.where(user: current_user).first

      if ballot.blank?
        dropdown_link_to('Start', effective_polls.poll_ballot_build_path(poll, :new, :start))
      elsif ballot.completed?
        'Complete'
      else
        dropdown_link_to('Continue', effective_polls.poll_ballot_build_path(poll, ballot, ballot.next_step))
      end
    end
  end

  collection do
    raise('expected a current_user') unless current_user.present?
    Effective::Poll.available.select { |poll| poll.available_for?(current_user) }
  end

end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
effective_polls-0.3.0 app/datatables/effective_polls_datatable.rb
effective_polls-0.2.0 app/datatables/effective_polls_datatable.rb
effective_polls-0.1.6 app/datatables/effective_polls_datatable.rb
effective_polls-0.1.5 app/datatables/effective_polls_datatable.rb
effective_polls-0.1.4 app/datatables/effective_polls_datatable.rb
effective_polls-0.1.3 app/datatables/effective_polls_datatable.rb
effective_polls-0.1.2 app/datatables/effective_polls_datatable.rb
effective_polls-0.1.1 app/datatables/effective_polls_datatable.rb
effective_polls-0.1.0 app/datatables/effective_polls_datatable.rb
effective_polls-0.0.2 app/datatables/effective_polls_datatable.rb
effective_polls-0.0.1 app/datatables/effective_polls_datatable.rb