Class: ActiveAdmin::Views::Tabs

Inherits:
Component
  • Object
show all
Defined in:
lib/active_admin/views/components/tabs.rb

Instance Method Summary collapse

Instance Method Details

#build(&block) ⇒ Object


13
14
15
16
# File 'lib/active_admin/views/components/tabs.rb', line 13

def build(&block)
  @menu = ul(class: "nav nav-tabs", role: "tablist")
  @tabs_content = div(class: "tab-content")
end

#build_content_item(title, options, &block) ⇒ Object


27
28
29
30
# File 'lib/active_admin/views/components/tabs.rb', line 27

def build_content_item(title, options, &block)
  options = options.reverse_merge(id: fragmentize(title))
  div(options, &block)
end

#build_menu_item(title, options, &block) ⇒ Object


18
19
20
21
22
23
24
25
# File 'lib/active_admin/views/components/tabs.rb', line 18

def build_menu_item(title, options, &block)
  fragment = options.fetch(:id, fragmentize(title))

  html_options = options.fetch(:html_options, {})
  li html_options do
    link_to title, "##{fragment}"
  end
end

#tab(title, options = {}, &block) ⇒ Object


7
8
9
10
11
# File 'lib/active_admin/views/components/tabs.rb', line 7

def tab(title, options = {}, &block)
  title = title.to_s.titleize if title.is_a? Symbol
  @menu << build_menu_item(title, options, &block)
  @tabs_content << build_content_item(title, options, &block)
end