Sha256: 2ced45451d1ba4c7b61d1e55c4fde3663f6dca83d3d9e09526bb6fab03845ddc

Contents?: true

Size: 1.18 KB

Versions: 8

Compression:

Stored size: 1.18 KB

Contents

# Displays available cpd_cycles that the current_user may complete

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

    col :start_at, visible: false

    col(:title, label: cpd_cycle_label)
    col :available_date, label: 'Available'

    col :required_score, label: 'Required' do |cpd_cycle|
      cpd_statement = EffectiveCpd.CpdStatement.new(cpd_cycle: cpd_cycle, user: current_user)
      cpd_score(cpd_statement.required_score || cpd_statement.targeted_score)
    end

    actions_col(actions: []) do |cpd_cycle|
      statement = cpd_cycle.cpd_statements.where(user: current_user).first

      if statement.blank?
        dropdown_link_to('Start', effective_cpd.cpd_cycle_cpd_statement_build_path(cpd_cycle, :new, :start))
      else
        dropdown_link_to('Continue', effective_cpd.cpd_cycle_cpd_statement_build_path(cpd_cycle, statement, statement.next_step))
      end
    end
  end

  collection do
    raise('expected a current_user') unless current_user.present?
    completed = EffectiveCpd.CpdStatement.completed.where(user: current_user)
    Effective::CpdCycle.available.where.not(id: completed.select('cpd_cycle_id as id'))
  end

end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
effective_cpd-1.3.7 app/datatables/effective_cpd_available_cycles_datatable.rb
effective_cpd-1.3.6 app/datatables/effective_cpd_available_cycles_datatable.rb
effective_cpd-1.3.5 app/datatables/effective_cpd_available_cycles_datatable.rb
effective_cpd-1.3.4 app/datatables/effective_cpd_available_cycles_datatable.rb
effective_cpd-1.3.3 app/datatables/effective_cpd_available_cycles_datatable.rb
effective_cpd-1.3.2 app/datatables/effective_cpd_available_cycles_datatable.rb
effective_cpd-1.3.1 app/datatables/effective_cpd_available_cycles_datatable.rb
effective_cpd-1.3.0 app/datatables/effective_cpd_available_cycles_datatable.rb