Class: ActiveAdmin::Views::HeaderRenderer

Inherits:
Renderer
  • Object
show all
Defined in:
lib/active_admin/views/header_renderer.rb

Overview

Renderer for the header of the application. Includes the page title, global navigation and utility navigation.

Instance Attribute Summary

Attributes inherited from Renderer

#assigns, #view

Instance Method Summary collapse

Methods inherited from Renderer

#call_method_or_proc_on, #haml, #initialize, #method_missing, #set_ivar_on_view, #to_s

Methods included from Arbre::Builder

#current_dom_context, #helpers, #method_missing

Methods included from ActiveAdmin::ViewHelpers::RendererHelper

#render

Constructor Details

This class inherits a constructor from ActiveAdmin::Renderer

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class ActiveAdmin::Renderer

Instance Method Details

#active_admin_logout_pathObject (protected)

Returns the logout path from the application settings



62
63
64
65
66
67
68
# File 'lib/active_admin/views/header_renderer.rb', line 62

def active_admin_logout_path
  if active_admin_namespace.logout_link_path.is_a?(Symbol)
    send(active_admin_namespace.logout_link_path)
  else
    active_admin_namespace.logout_link_path
  end
end

Renders the global navigation returned by ActiveAdmin::ResourceController#current_menu

It uses the ActiveAdmin.tabs_renderer option



45
46
47
# File 'lib/active_admin/views/header_renderer.rb', line 45

def global_navigation
  render view_factory.global_navigation, current_menu, :class => 'header-item' 
end

#logout_methodObject (protected)



70
71
72
# File 'lib/active_admin/views/header_renderer.rb', line 70

def logout_method
  active_admin_namespace.logout_link_method || :get
end

#titleObject (protected)

Renders the title/branding area for the site



15
16
17
18
19
20
21
# File 'lib/active_admin/views/header_renderer.rb', line 15

def title
  if active_admin_namespace.site_title_image.blank?
   title_text
  else
    title_image
  end
end

#title_imageObject (protected)

Renders an image for the site’s header/branding area



24
25
26
27
28
29
30
# File 'lib/active_admin/views/header_renderer.rb', line 24

def title_image
  if !active_admin_namespace.site_title_link.blank?
     'h1', link_to( image_tag(active_admin_namespace.site_title_image, :id => "site_title_image", :alt => active_admin_namespace.site_title), active_admin_namespace.site_title_link ), :id => "site_title" 
  else
     'h1', image_tag( active_admin_namespace.site_title_image, :id => "site_title_image", :alt => active_admin_namespace.site_title ), :id => "site_title"
  end
end

#title_textObject (protected)

Renders a the site’s header/branding area as a string



33
34
35
36
37
38
39
# File 'lib/active_admin/views/header_renderer.rb', line 33

def title_text
  if !active_admin_namespace.site_title_link || active_admin_namespace.site_title_link == ""
     'h1', active_admin_namespace.site_title, :id => 'site_title'
  else
     'h1', link_to(active_admin_namespace.site_title, active_admin_namespace.site_title_link), :id => 'site_title'
  end
end

#to_htmlObject



8
9
10
# File 'lib/active_admin/views/header_renderer.rb', line 8

def to_html
  title + global_navigation + utility_navigation
end

#utility_navigationObject (protected)



49
50
51
52
53
54
55
56
57
58
59
# File 'lib/active_admin/views/header_renderer.rb', line 49

def utility_navigation
   'p', :id => "utility_nav", :class => 'header-item' do
    if current_active_admin_user?
      html = (:span, display_name(current_active_admin_user), :class => "current_user")

      if active_admin_namespace.logout_link_path
        html << link_to(I18n.t('active_admin.logout'), active_admin_logout_path, :method => logout_method)
      end
    end
  end
end