ActiveAdmin.register Channel do
  menu :priority => 5 #,:parent => "Bots"

  index do
    column :id
    column :bot, :sortable => :bot_id do |c|
      link_to "ID:" +  c.bot_id.to_s + " N:" + Bot.find(c.bot_id).botnick, "bots/" + c.bot_id.to_s
    end
    column :name
    column :activate
    column :created_at
    column :updated_at
    default_actions
  end

  show :title => :name do
    attributes_table do
      row :id
      row :bot do |c|
        link_to "ID:" +  c.bot_id.to_s + " N:" + Bot.find(c.bot_id).botnick, "../bots/" + c.bot_id.to_s
      end
      row :name
      row :activate
      row :created_at
      row :updated_at

    end
    active_admin_comments
  end

  filter :id
  filter :bot, :as => :select, :member_label => :botnick
  filter :name
  filter :activate, :as => :select
  filter :created_at
  filter :updated_at

  form do |f|

    #@user = User.new(:email => params[:email])


    f.inputs "Details" do
      f.input :bot, :as => :select, :member_label => :botnick  # https://github.com/justinfrench/formtastic/blob/master/lib/formtastic/inputs/select_input.rb
      f.input :name, :label => "Channelname"
      f.input :activate
    end
    f.buttons
  end

end
