Module: Godmin::Helpers::Navigation

Defined in:
lib/godmin/helpers/navigation.rb

Instance Method Summary collapse

Instance Method Details



47
48
49
# File 'lib/godmin/helpers/navigation.rb', line 47

def navbar_divider
   :li, "", class: "divider"
end


31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
# File 'lib/godmin/helpers/navigation.rb', line 31

def navbar_dropdown(title)
  dropdown_toggle = link_to "#", class: "dropdown-toggle", data: { toggle: "dropdown" } do
    concat "#{title} "
    concat  :span, "", class: "caret"
  end

  dropdown_menu =  :ul, class: "dropdown-menu" do
    yield
  end

   :li, class: "dropdown" do
    concat dropdown_toggle
    concat dropdown_menu
  end
end


4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/godmin/helpers/navigation.rb', line 4

def navbar_item(resource, url = resource, show: nil, icon: nil, **options)
  show ||= lambda do
    resource.is_a?(String) ? true : policy(resource).index?
  end

  return unless show.call

  link_text =
    if block_given?
      capture do
        yield
      end
    else
      resource.respond_to?(:model_name) ? resource.model_name.human(count: :many) : resource
    end

   :li do
    link_to url, options do
      if icon.present?
        concat  :span, "", class: "glyphicon glyphicon-#{icon}"
        concat " "
      end
      concat link_text
    end
  end
end