Class: ActiveAdmin::Comments::Views::Comments
- Inherits:
-
Views::Panel
- Object
- Arbre::Component
- ActiveAdmin::Component
- Views::Panel
- ActiveAdmin::Comments::Views::Comments
- Defined in:
- lib/active_admin/comments/views/active_admin_comments.rb
Instance Method Summary collapse
- #build(resource) ⇒ Object
- #build_comment(comment) ⇒ Object protected
- #build_comment_form ⇒ Object protected
- #build_comments ⇒ Object protected
- #build_empty_message ⇒ Object protected
- #comment_form_url ⇒ Object protected
- #default_id_for_prefix ⇒ Object protected
- #title ⇒ Object protected
Methods inherited from Views::Panel
Instance Method Details
#build(resource) ⇒ Object
11 12 13 14 15 16 |
# File 'lib/active_admin/comments/views/active_admin_comments.rb', line 11 def build(resource) @resource = resource @comments = ActiveAdmin::Comment.find_for_resource_in_namespace @resource, active_admin_namespace.name super(title, :for => resource) build_comments end |
#build_comment(comment) ⇒ Object (protected)
29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/active_admin/comments/views/active_admin_comments.rb', line 29 def build_comment(comment) div :for => comment do div :class => 'active_admin_comment_meta' do h4 :class => 'active_admin_comment_author' do comment. ? auto_link(comment.) : 'Anonymous' end span pretty_format comment.created_at end div :class => 'active_admin_comment_body' do simple_format comment.body end end end |
#build_comment_form ⇒ Object (protected)
55 56 57 58 59 60 61 62 63 64 65 66 |
# File 'lib/active_admin/comments/views/active_admin_comments.rb', line 55 def build_comment_form self << active_admin_form_for(ActiveAdmin::Comment.new, :url => comment_form_url) do |f| f.inputs do f.input :resource_type, :as => :hidden, :input_html => { :value => ActiveAdmin::Comment.resource_type(@resource) } f.input :resource_id, :as => :hidden, :input_html => { :value => @resource.id } f.input :body, :label => false, :input_html => { :size => '80x8' } end f.actions do f.action :submit, :label => I18n.t('active_admin.comments.add') end end end |
#build_comments ⇒ Object (protected)
24 25 26 27 |
# File 'lib/active_admin/comments/views/active_admin_comments.rb', line 24 def build_comments @comments.any? ? @comments.each(&method(:build_comment)) : build_comment_form end |
#build_empty_message ⇒ Object (protected)
43 44 45 |
# File 'lib/active_admin/comments/views/active_admin_comments.rb', line 43 def span I18n.t('active_admin.comments.no_comments_yet'), :class => 'empty' end |
#comment_form_url ⇒ Object (protected)
47 48 49 50 51 52 53 |
# File 'lib/active_admin/comments/views/active_admin_comments.rb', line 47 def comment_form_url parts = [] parts << active_admin_namespace.name unless active_admin_namespace.root? parts << active_admin_namespace.comments_registration_name.underscore.pluralize parts << 'path' send parts.join '_' end |
#default_id_for_prefix ⇒ Object (protected)
68 69 70 |
# File 'lib/active_admin/comments/views/active_admin_comments.rb', line 68 def default_id_for_prefix 'active_admin_comments_for' end |
#title ⇒ Object (protected)
20 21 22 |
# File 'lib/active_admin/comments/views/active_admin_comments.rb', line 20 def title I18n.t 'active_admin.comments.title_content', :count => @comments.count end |