Skip to content

Commit

Permalink
fix Warped::Controllers::Pageable::Ui#series (#9)
Browse files Browse the repository at this point in the history
  • Loading branch information
juan-apa authored Apr 8, 2024
1 parent bae0bf7 commit 8af5cae
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion lib/warped/controllers/pageable/ui.rb
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,11 @@ def paginated?
# the current page is a string, the others are integers
# series example: [1, :gap, 7, 8, "9", 10, 11, :gap, 36]
def series(page, total_pages)
return [] if total_pages.zero?
return ["1"] if total_pages == 1

if total_pages <= 9
(1..total_pages).to_a
(1..(page - 1)).to_a + [page.to_s] + ((page + 1)..total_pages).to_a
else
[1, :gap, page - 2, page - 1, page.to_s, page + 1, page + 2, :gap, total_pages]
end
Expand Down

0 comments on commit 8af5cae

Please sign in to comment.