Class: Avo::TabGroupComponent
Constant Summary
Concerns::FindAssociationField::ASSOCIATIONS
Instance Method Summary
collapse
#component_name, #has_with_trial
#find_association_field
Instance Method Details
#active_tab ⇒ Object
65
66
67
68
69
70
71
|
# File 'app/components/avo/tab_group_component.rb', line 65
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
49
50
51
|
# File 'app/components/avo/tab_group_component.rb', line 49
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
73
74
75
76
77
78
79
80
81
82
83
84
85
|
# File 'app/components/avo/tab_group_component.rb', line 73
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
|
#frame_args(tab) ⇒ Object
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
|
# File 'app/components/avo/tab_group_component.rb', line 21
def frame_args(tab)
args = {
target: :_top,
class: "block"
}
if is_not_loaded?(tab)
args[:loading] = :lazy
args[:src] = helpers.resource_path(
resource: @resource,
record: @resource.record,
keep_query_params: true,
active_tab_name: tab.name,
tab_turbo_frame: tab.turbo_frame_id(parent: @group)
)
end
args
end
|
#is_not_loaded?(tab) ⇒ Boolean
41
42
43
|
# File 'app/components/avo/tab_group_component.rb', line 41
def is_not_loaded?(tab)
params[:tab_turbo_frame] != tab.turbo_frame_id(parent: @group)
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
53
54
55
56
57
|
# File 'app/components/avo/tab_group_component.rb', line 53
def tabs
@group.visible_items.map do |tab|
tab.hydrate(view: view)
end
end
|
#tabs_have_content? ⇒ Boolean
45
46
47
|
# File 'app/components/avo/tab_group_component.rb', line 45
def tabs_have_content?
visible_tabs.present?
end
|
#visible_tabs ⇒ Object
59
60
61
62
63
|
# File 'app/components/avo/tab_group_component.rb', line 59
def visible_tabs
tabs.select do |tab|
tab.visible?
end
end
|