Module: IfdTools::ActiveAdmin::Dashboard::ContactRequests

Defined in:
lib/ifd_tools/active_admin/dashboard/contact_requests.rb

Class Method Summary collapse

Class Method Details

.included(dsl) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/ifd_tools/active_admin/dashboard/contact_requests.rb', line 6

def self.included(dsl)

  index_page_presenter = dsl.config.get_page_presenter(:index) || ::ActiveAdmin::PagePresenter.new(title: proc { I18n.t("active_admin.dashboard") })

  dsl.content(title: index_page_presenter[:title]) do 
    
    # Execute any code provided in the application dashboard itself
    instance_exec &index_page_presenter.block if index_page_presenter.block.present?
            
    # Another row of content
    columns do
      
      column do
        panel "Recent Contact Requests" do
          table_for ::IfdTools::ContactRequest.unread.limit(20) do
            column(:name) { |cr| link_to truncate(cr.to_s, length: 35), [:admin, cr] }
            column(:email) { |cr| mail_to cr.email, cr.email }
            column(:phone) { |cr| number_to_phone cr.phone, area_code: true }
          end
        end                
      end
      
      # Execute any additional code in this same row
      instance_exec &index_page_presenter[:additional_content] if index_page_presenter[:additional_content].present?

    end
  
  end

end