Class: Avo::PaginatorComponent
Constant Summary
collapse
- NUMBER_DELIMITER =
"."
Concerns::FindAssociationField::ASSOCIATIONS
Instance Method Summary
collapse
#component_name
#a_button, #a_link, #body_classes, #button_classes, #chart_color, #container_classes, #d, #decode_filter_params, #e, #editor_file_path, #editor_url, #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, #rtl?, #text_direction, #ui, #wrap_in_modal
#field_wrapper, #filter_wrapper, #index_field_wrapper, #item_selector_data_attributes, #record_path, #record_title, #resource_for_record, #resource_grid, #resource_show_path, #resource_table
#find_association_field
Instance Method Details
#change_items_per_page_url(option) ⇒ Object
16
17
18
19
20
21
22
23
24
25
26
27
28
29
|
# File 'app/components/avo/paginator_component.rb', line 16
def change_items_per_page_url(option)
if @parent_record.present?
helpers.related_resources_path(
@parent_record,
@parent_record,
parent_resource: @parent_resource,
per_page: option,
keep_query_params: true,
page: 1
)
else
helpers.resources_path(resource: @resource, per_page: option, keep_query_params: true, page: 1)
end
end
|
#current_per_page_label ⇒ Object
49
50
51
|
# File 'app/components/avo/paginator_component.rb', line 49
def current_per_page_label
per_page_option_label(@index_params[:per_page])
end
|
58
59
60
|
# File 'app/components/avo/paginator_component.rb', line 58
def formatted_count
formatted_number(@pagy.count)
end
|
62
63
64
65
66
|
# File 'app/components/avo/paginator_component.rb', line 62
def formatted_series_nav
@pagy.series_nav(anchor_string: %(data-turbo-frame="#{@turbo_frame}"))
.gsub(/>(\d{4,})</) { |match| match.sub($1, formatted_number($1)) }
.html_safe
end
|
#per_page_option_label(option) ⇒ Object
53
54
55
56
|
# File 'app/components/avo/paginator_component.rb', line 53
def per_page_option_label(option)
num = helpers.content_tag(:span, option, class: "pagination__per-page-option-num")
"#{num} #{t("avo.per_page").downcase}".html_safe
end
|
#per_page_options ⇒ Object
37
38
39
40
41
42
43
44
45
46
47
|
# File 'app/components/avo/paginator_component.rb', line 37
def per_page_options
@per_page_options ||= begin
options = [*Avo.configuration.per_page_steps, Avo.configuration.per_page.to_i, @index_params[:per_page].to_i]
if @parent_record.present?
options.prepend Avo.configuration.via_per_page
end
options.sort.uniq
end
end
|
#render? ⇒ Boolean
31
32
33
34
35
|
# File 'app/components/avo/paginator_component.rb', line 31
def render?
return false if @discreet_pagination && @pagy.pages <= 1
@pagy.limit > 0
end
|