Sha256: bc7169c2c2ad0117464d417ad3cb28bb0c8a9d4273b19126a0a2430283b6325b

Contents?: true

Size: 1.02 KB

Versions: 5

Compression:

Stored size: 1.02 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

    col :target_score, label: "Required #{cpd_credits_label}" do |cpd_cycle|
      cpd_score(current_user.cpd_target_score(cpd_cycle: cpd_cycle))
    end

    actions_col(actions: []) do |cpd_cycle|
      statement = current_user.cpd_statement(cpd_cycle: cpd_cycle)

      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
    completed = EffectiveCpd.CpdStatement.completed.where(user: attributes[:user] || current_user)
    Effective::CpdCycle.available.where.not(id: completed.select(:cpd_cycle_id))
  end

end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
effective_cpd-1.7.2 app/datatables/effective_cpd_available_cycles_datatable.rb
effective_cpd-1.7.1 app/datatables/effective_cpd_available_cycles_datatable.rb
effective_cpd-1.7.0 app/datatables/effective_cpd_available_cycles_datatable.rb
effective_cpd-1.6.5 app/datatables/effective_cpd_available_cycles_datatable.rb
effective_cpd-1.6.4 app/datatables/effective_cpd_available_cycles_datatable.rb