Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add pagination_label to page_component #339

Merged
merged 1 commit into from
Nov 15, 2023
Merged

add pagination_label to page_component #339

merged 1 commit into from
Nov 15, 2023

Conversation

yshmarov
Copy link
Contributor

@yshmarov yshmarov commented Nov 15, 2023

[pagination_component](https://polarisviewcomponents.org/lookbook/inspect/pagination/with_label) has label option, however we do not have such an option in the page_component, where we also have prev/next url.

added pagination_label to page_component.

example without @pagination_label defined:

Screenshot 2023-11-15 at 20 21 03

with @pagination_label:

Screenshot 2023-11-15 at 20 20 54

@kirillplatonov kirillplatonov merged commit 3014c85 into baoagency:main Nov 15, 2023
4 checks passed
@yshmarov yshmarov deleted the add-pagination_label-to-page_component branch November 16, 2023 08:43
@yshmarov
Copy link
Contributor Author

P.S. code snippet for adding this exact type of label (1-250 of 348) when using gem pagy:

module PagyHelper
  # 1-250 of 348
  # pagy_counter(@orders, @pagy.count)
  def pagy_counter(records, total_count)
    [index_range(records), total_count].join(" of ")
  end

  private

  def current_page_first_index(records)
    return records.offset_value + 1 if records.size > 1

    records.offset_value
  end

  def current_page_last_index(records)
    records.offset_value + records.count
  end

  def index_range(records)
    "#{current_page_first_index(records)}-#{current_page_last_index(records)}"
  end
end

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants