ActiveAdmin.register JamRuby::TeacherDistribution, :as => 'TeacherDistributions' do

  menu :label => 'Teacher Distributions', :parent => 'JamClass'

  config.sort_order = 'created_at desc'
  config.batch_actions = false
  config.per_page = 100
  config.paginate = true
  config.filters = true

  controller do
    active_admin_config.includes.push :teacher
  end

  filter :teacher_full_name_or_teacher_email_cont, label: 'Name', as: :string

  index do
    column "Actions" do |distribution|
      links = ''.html_safe
      links << link_to("View", resource_path(distribution), :class => "member_link view_link")
      links << link_to("Edit", edit_resource_path(distribution), :class => "member_link edit_link")
      links
    end
    column "Teacher" do |distribution|
      link_to distribution.teacher.name, distribution.teacher.admin_url
    end
    column :amount_in_cents
    column :distributed
    column :ready
    column :teacher_fee_in_cents
    column :reduced_roll_forward_amount_in_cents
    column :created_at
    column :updated_at
  end

  show do
    attributes_table do
      row "Teacher" do |distribution|
        link_to distribution.teacher.name, distribution.teacher.admin_url
      end
      row :amount_in_cents
      row :distributed
      row :ready
      row :teacher_fee_in_cents
      row :reduced_roll_forward_amount_in_cents
      row :created_at
      row :updated_at
    end
  end

end