Class: Avo::Index::ResourceTableComponent
Constant Summary
Concerns::FindAssociationField::ASSOCIATIONS
Instance Attribute Summary collapse
Instance Method Summary
collapse
#a_button, #a_link, #button_classes, #card_classes, #chart_color, #decode_filter_params, #empty_state, #encode_filter_params, #frame_id, #get_model_class, #input_classes, #mount_path, #number_to_social, #possibly_rails_authentication?, #render_license_warning, #root_path_without_url, #svg, #white_panel_classes
#field_wrapper, #filter_wrapper, #index_field_wrapper, #item_selector_data_attributes, #resource_grid, #resource_show_path, #resource_table
#has_with_trial
#find_association_field
Instance Attribute Details
#pagy ⇒ Object
Returns the value of attribute pagy.
5
6
7
|
# File 'app/components/avo/index/resource_table_component.rb', line 5
def pagy
@pagy
end
|
#query ⇒ Object
Returns the value of attribute query.
5
6
7
|
# File 'app/components/avo/index/resource_table_component.rb', line 5
def query
@query
end
|
Instance Method Details
#before_render ⇒ Object
7
8
9
|
# File 'app/components/avo/index/resource_table_component.rb', line 7
def before_render
@header_fields, @table_row_components = cache_table_rows
end
|
#cache_table_rows ⇒ Object
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
|
# File 'app/components/avo/index/resource_table_component.rb', line 47
def cache_table_rows
cache_if Avo.configuration.cache_resources_on_index_view, @resource.cache_hash(@parent_record), expires_in: 1.day do
, table_row_components = generate_table_row_components
= .map(&:table_header_label)
table_row_components.map { |table_row_component| table_row_component. = }
return [, table_row_components]
end
end
|
#encrypted_query ⇒ Object
20
21
22
23
24
25
26
27
28
29
|
# File 'app/components/avo/index/resource_table_component.rb', line 20
def encrypted_query
if Module.const_defined?("Ransack::Search") && @query.instance_of?(Ransack::Search)
@query = @query.result
end
Avo::Services::EncryptionService.encrypt(message: @query, purpose: :select_all, serializer: Marshal)
rescue
disable_select_all
end
|
#generate_table_row_components ⇒ Object
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
|
# File 'app/components/avo/index/resource_table_component.rb', line 64
def generate_table_row_components
= []
table_row_components = []
@resources.each do |resource|
row_fields = resource.get_fields(reflection: @reflection, only_root: true)
.concat row_fields
table_row_components << resource.resolve_component(Avo::Index::TableRowComponent).new(
resource: resource,
fields: row_fields,
reflection: @reflection,
parent_record: @parent_record,
parent_resource: @parent_resource,
actions: @actions
)
end
.uniq!(&:table_header_label)
[, table_row_components]
end
|
#selected_all_label ⇒ Object
39
40
41
42
43
44
45
|
# File 'app/components/avo/index/resource_table_component.rb', line 39
def selected_all_label
if @resource..countless?
t "avo.records_selected_from_all_pages_html"
else
t "avo.x_records_selected_from_all_pages_html", count: @pagy.count
end
end
|
#selected_page_label ⇒ Object
31
32
33
34
35
36
37
|
# File 'app/components/avo/index/resource_table_component.rb', line 31
def selected_page_label
if @resource..countless?
t "avo.x_records_selected_from_page_html", selected: @pagy.in
else
t "avo.x_records_selected_from_a_total_of_x_html", selected: @pagy.in, count: @pagy.count
end
end
|