channels.rb 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  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. Bot.find(c.bot_id) do |bot|
  20. span(link_to("ID:" + c.bot_id.to_s + " N:" + bot.botnick, "../bots/" + c.bot_id.to_s).to_s + " | " +
  21. link_to("add a channel to this bot", "/admin/channels/new?bot_id=" + bot.id.to_s + "&botnick=" + bot.botnick.to_s))
  22. end
  23. end
  24. row :activate
  25. row :created_at
  26. row :updated_at
  27. end
  28. active_admin_comments
  29. end
  30. filter :id
  31. filter :name
  32. filter :bot, :as => :select, :member_label => :botnick
  33. filter :activate, :as => :select
  34. filter :created_at
  35. filter :updated_at
  36. form do |f|
  37. #@user = User.new(:email => params[:email])
  38. f.inputs "Details" do
  39. f.input :name, :label => "Channelname"
  40. if params[:bot_id] && params[:botnick] then
  41. f.input :bot_id, :as => :string, :member_label => :botnick, :input_html => { :readonly => true, :size => 10, :value => params[:botnick] }
  42. f.input :bot_id, :as => :hidden, :value => params[:bot_id], :member_label => :botnick, :input_html => { :readonly => true, :size => 10, :value => params[:bot_id] }
  43. #f.input :bot, :as => :select, :member_label => :botnick # https://github.com/justinfrench/formtastic/blob/master/lib/formtastic/inputs/select_input.rb
  44. else
  45. f.input :bot, :as => :select, :member_label => :botnick # https://github.com/justinfrench/formtastic/blob/master/lib/formtastic/inputs/select_input.rb
  46. end
  47. f.input :activate
  48. end
  49. f.buttons
  50. end
  51. end