Module: Admin::LayoutHelper

Defined in:
app/helpers/amalgam/admin/layout_helper.rb

Instance Method Summary collapse

Instance Method Details

#body_classObject



21
22
23
24
25
26
27
28
29
30
# File 'app/helpers/amalgam/admin/layout_helper.rb', line 21

def body_class
  return @cls if @cls
  @cls = []
  @cls << "#{params[:controller]}_controller"
  @cls << [params[:action],params[:controller]]*'_'
  @cls << I18n.locale.to_s
  @cls << Rails.env
  @cls << @body_class if @body_class
  @cls = @cls.map(&:parameterize)*' '
end


32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
# File 'app/helpers/amalgam/admin/layout_helper.rb', line 32

def controller_links
  links = ""
  Amalgam.admin_menus.each do |name,actions|
    unless actions.first.is_a? Hash
      links += drop_down name.classify.constantize.model_name.human,'#', :controller => "amalgam/admin/#{name}" do
        dropdown = ""
        actions.each do |action|
          dropdown += dropdown_item(I18n.t("amalgam.admin.actions.#{action}"), amalgam.send("admin_#{name}_path")) if action == 'index' || action == :index
          dropdown += dropdown_item(I18n.t('amalgam.admin.actions.new'), amalgam.send("new_admin_#{name.singularize}_path")) if action == 'new' || action == :new
          dropdown += dropdown_item(I18n.t("amalgam.admin.actions.#{action}"), amalgam.send("#{action}_admin_#{name}_path")) if action != 'index' && action != :index && action != 'new' && action != :new
        end
        dropdown.html_safe
      end
    else
      links += menu_item I18n.t("amalgam.admin.menus.#{name}"), amalgam.send("admin_#{name}_path"), :controller => "amalgam/admin/#{actions.first[:controller]}"
    end
  end
  links.html_safe
end


15
16
17
18
19
# File 'app/helpers/amalgam/admin/layout_helper.rb', line 15

def drop_down(title, path='#', options={}, &block)
   :li, :class => "dropdown #{is_active?(path,options)}" do
    drop_down_link(title,path) + drop_down_list(&block)
  end
end


9
10
11
12
13
# File 'app/helpers/amalgam/admin/layout_helper.rb', line 9

def dropdown_item(title, path="#", options={})
  (:li) do
    link_to(title, path,options)
  end
end


3
4
5
6
7
# File 'app/helpers/amalgam/admin/layout_helper.rb', line 3

def menu_item(title, path="#", options={})
  (:li, :class => is_active?(path,options)) do
    link_to(title, path)
  end
end