Class: Avo::TabGroupComponent
Constant Summary
Concerns::FindAssociationField::ASSOCIATIONS
Instance Method Summary
collapse
#has_with_trial
#find_association_field
Instance Method Details
#active_tab ⇒ Object
41
42
43
44
45
46
47
|
# File 'app/components/avo/tab_group_component.rb', line 41
def active_tab
return if group.visible_items.blank?
group.visible_items.find do |tab|
tab.name.to_s == active_tab_name.to_s
end
end
|
#active_tab_name ⇒ Object
25
26
27
|
# File 'app/components/avo/tab_group_component.rb', line 25
def active_tab_name
CGI.unescape(params[group_param] || group.visible_items&.first&.name)
end
|
#after_initialize ⇒ Object
13
14
15
|
# File 'app/components/avo/tab_group_component.rb', line 13
def after_initialize
group.index = index
end
|
#args(tab) ⇒ Object
49
50
51
52
53
54
55
56
57
58
59
60
61
|
# File 'app/components/avo/tab_group_component.rb', line 49
def args(tab)
{
class: "block #{'hidden' unless tab.name == active_tab_name}",
data: {
loaded: tab.name == active_tab_name,
tabs_target: :tabPanel,
tab_id: tab.name,
}
}
end
|
#render? ⇒ Boolean
17
18
19
|
# File 'app/components/avo/tab_group_component.rb', line 17
def render?
tabs_have_content? && visible_tabs.present?
end
|
#tabs ⇒ Object
29
30
31
32
33
|
# File 'app/components/avo/tab_group_component.rb', line 29
def tabs
@group.visible_items.map do |tab|
tab.hydrate(view: view)
end
end
|
#tabs_have_content? ⇒ Boolean
21
22
23
|
# File 'app/components/avo/tab_group_component.rb', line 21
def tabs_have_content?
visible_tabs.present?
end
|
#visible_tabs ⇒ Object
35
36
37
38
39
|
# File 'app/components/avo/tab_group_component.rb', line 35
def visible_tabs
tabs.select do |tab|
tab.visible?
end
end
|