paginator: fix switching to sequential pagination.

Fix a bug where the paginator didn't correctly switch to sequential
pagination when reaching the page limit.
This commit is contained in:
evazion
2021-02-18 19:01:45 -06:00
parent 4e6dff782d
commit 981d56c97c
2 changed files with 6 additions and 2 deletions

View File

@@ -12,7 +12,7 @@ class PaginatorComponent < ApplicationComponent
end
def use_sequential_paginator?
paginator_mode != :numbered || current_page >= paginator_page_limit
paginator_mode != :numbered
end
def pages

View File

@@ -20,10 +20,14 @@ module PaginationExtension
elsif page.to_s =~ /\Aa(\d+)\z/i
@paginator_mode = :sequential_after
paginate_sequential_after($1, records_per_page)
elsif page.to_i > page_limit
raise PaginationError
elsif page.to_i == page_limit
@paginator_mode = :sequential_after
paginate_numbered(page.to_i, records_per_page)
else
@paginator_mode = :numbered
@current_page = [page.to_i, 1].max
raise PaginationError if current_page > page_limit
paginate_numbered(current_page, records_per_page)
end