channels.rb 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. ActiveAdmin.register Channel do
  2. menu :priority => 5 #,:parent => "Bots"
  3. index do
  4. column :id
  5. column :name
  6. column :bot, :sortable => :bot_id do |c|
  7. link_to "ID:" + c.bot_id.to_s + " N:" + Bot.find(c.bot_id).botnick, "bots/" + c.bot_id.to_s
  8. end
  9. column :activate
  10. column :created_at
  11. column :updated_at
  12. default_actions
  13. end
  14. show :title => :name do
  15. attributes_table do
  16. row :id
  17. row :name
  18. row :bot do |c|
  19. span(link_to("ID:" + c.bot_id.to_s + " N:" + Bot.find(c.bot_id).botnick.to_s, "../bots/" + c.bot_id.to_s).to_s + " | " +
  20. link_to("add a channel to this bot", "/admin/channels/new?bot_id=" + c.bot_id.to_s + "&botnick=" + Bot.find(c.bot_id).botnick.to_s))
  21. end
  22. row :activate
  23. row :created_at
  24. row :updated_at
  25. end
  26. active_admin_comments
  27. end
  28. filter :id
  29. filter :name
  30. filter :bot, :as => :select, :member_label => :botnick
  31. filter :activate, :as => :select
  32. filter :created_at
  33. filter :updated_at
  34. form do |f|
  35. #@user = User.new(:email => params[:email])
  36. f.inputs "Details" do
  37. f.input :name, :label => "Channelname"
  38. if params[:bot_id] && params[:botnick] then
  39. f.input :bot_id, :as => :string, :member_label => :botnick, :input_html => { :readonly => true, :size => 10, :value => params[:botnick] }
  40. f.input :bot_id, :as => :hidden, :value => params[:bot_id], :member_label => :botnick, :input_html => { :readonly => true, :size => 10, :value => params[:bot_id] }
  41. #f.input :bot, :as => :select, :member_label => :botnick # https://github.com/justinfrench/formtastic/blob/master/lib/formtastic/inputs/select_input.rb
  42. else
  43. f.input :bot, :as => :select, :member_label => :botnick # https://github.com/justinfrench/formtastic/blob/master/lib/formtastic/inputs/select_input.rb
  44. end
  45. f.input :activate
  46. end
  47. f.buttons
  48. end
  49. end