module Adminterface::Extensions::Views::Components::Tabs
Public Instance Methods
build_content_item(title, options, &block)
click to toggle source
# File lib/adminterface/extensions/views/components/tabs.rb, line 15 def build_content_item(title, options, &block) fragment = options.fetch(:id, fragmentize(title)) options = options.reverse_merge(id: fragment, "aria-labelledby": "#{fragment}-tab") div(options.merge(tab_pane_options(fragment)), &block) end
content_html_options()
click to toggle source
# File lib/adminterface/extensions/views/components/tabs.rb, line 31 def content_html_options content_html[:class] = "tab-content #{content_html[:class]}".squish content_html end
default_css_class()
click to toggle source
# File lib/adminterface/extensions/views/components/tabs.rb, line 21 def default_css_class tabs_css_classes end
Private Instance Methods
current_tab?(fragment)
click to toggle source
# File lib/adminterface/extensions/views/components/tabs.rb, line 75 def current_tab?(fragment) fragment.eql?(params[:tab]) || (!@http && @tabs_content&.children.blank?) end
link_to_http(title, fragment)
click to toggle source
# File lib/adminterface/extensions/views/components/tabs.rb, line 43 def link_to_http(title, fragment) params[:tab] ||= @default_tab || fragment link_to(title, url_for(controller: resource_scope[:controller], action: resource_scope[:action], tab: fragment, anchor: id, anchor_id: id), **toggler_options(fragment)) end
link_to_js(title, fragment)
click to toggle source
# File lib/adminterface/extensions/views/components/tabs.rb, line 38 def link_to_js(title, fragment) options = toggler_options(fragment).merge(data: {"bs-toggle": "tab", "bs-target": "##{fragment}"}) link_to(title, "##{fragment}", **options) end
resource_scope()
click to toggle source
# File lib/adminterface/extensions/views/components/tabs.rb, line 52 def resource_scope session.fetch(:resource_scope, {}).with_indifferent_access end
tab_pane_options(fragment)
click to toggle source
# File lib/adminterface/extensions/views/components/tabs.rb, line 68 def tab_pane_options(fragment) { class: "tab-pane #{current_tab?(fragment) ? "active" : nil}".squish, role: "tabpanel" } end
toggler_options(fragment)
click to toggle source
# File lib/adminterface/extensions/views/components/tabs.rb, line 56 def toggler_options(fragment) defaults = {id: "#{fragment}-tab", "aria-controls": fragment} options = if current_tab?(fragment) {class: "nav-link active", "aria-selected": "true"} else {class: "nav-link", "aria-selected": "false"} end defaults.merge(options) end