Module: SimpleAdmin::HeaderHelper

Included in:
AdminHelper
Defined in:
app/helpers/simple_admin/header_helper.rb

Instance Method Summary collapse

Instance Method Details

#action_itemsObject



33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
# File 'app/helpers/simple_admin/header_helper.rb', line 33

def action_items
   :div, :class => "action_items" do
    content = ""
    # If we are currently showing, then check for edit and destroy action items
    if params[:action].to_sym == :show
      if @interface.actions.include?(:edit)
        content << link_to("Edit #{@interface.member.titlecase}",
          send("edit_simple_admin_#{@interface.member}_path", @object))
      end
      content << "&nbsp;"
      if @interface.actions.include?(:destroy)
        content << link_to("Delete #{@interface.member.titlecase}",
          send("simple_admin_#{@interface.member}_path", @object),
          :method => :delete, :confirm => "Are you sure you want to delete this?")
      end
    end
    # If we are not showing an item or creating a new one, then check for new action items
    unless [:new, :show, :dashboard].include?(params[:action].to_sym)
      if @interface.constant && @interface.member
        if @interface.actions.include?(:new)
          content << link_to("New #{@interface.member.titlecase}",
            send("new_simple_admin_#{@interface.member}_path"))
        end
      end
    end
    content.html_safe
  end
end


24
25
26
27
28
29
30
31
# File 'app/helpers/simple_admin/header_helper.rb', line 24

def breadcrumbs
   :span, :class => 'breadcrumb' do
    SimpleAdmin::Breadcrumbs.parse(request.fullpath, params[:action]).collect do |crumb|
      link_to(crumb.first, crumb.last) +
      (:span, ' / ', :class => 'breadcrumb_sep')
    end.join.html_safe
  end
end

#tabsObject



3
4
5
6
7
8
9
10
11
# File 'app/helpers/simple_admin/header_helper.rb', line 3

def tabs
   :ul, :id => 'tabs' do
    SimpleAdmin.registered.collect do |interface|
       :li, :id => interface.collection, :class => "#{'current' if @interface == interface}" do
        link_to interface.collection.titlecase, send("simple_admin_#{interface.collection}_path".to_sym)
      end
    end.join.html_safe
  end
end

#utility_navObject



13
14
15
16
17
18
19
20
21
22
# File 'app/helpers/simple_admin/header_helper.rb', line 13

def utility_nav
   :p, :id => 'utility_nav' do
    if SimpleAdmin.current_user_method && send(SimpleAdmin.current_user_method)
      content = "".html_safe
      content << (:span, send(SimpleAdmin.current_user_name_method), :class => "current_user") if SimpleAdmin.current_user_name_method
      content << link_to("Logout", Rails.application.routes.url_helpers.logout_path) if Rails.application.routes.url_helpers.respond_to?(:logout_path)
      content
    end
  end
end