Skip to content

Commit

Permalink
pagy v9 compatibility, backwards compatible (#3046)
Browse files Browse the repository at this point in the history
* pagy v9 compatibility, backwards compatible

issue: #3014
pagy upgrade docs: https://ddnexus.github.io/pagy/changelog/#version-900

* do not force pagy v9 upgrade

* Update paginator_component.rb

* lint

* lint

* add per page

---------

Co-authored-by: Paul Bob <[email protected]>
  • Loading branch information
yshmarov and Paul-Bob authored Jul 24, 2024
1 parent 723c8b6 commit 6af4f0e
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 2 deletions.
6 changes: 5 additions & 1 deletion app/components/avo/paginator_component.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,11 @@ def change_items_per_page_url(option)
def render?
return false if discreet_pagination && pagy.pages <= 1

@pagy.items > 0
if defined?(@pagy.limit)
@pagy.limit > 0
else
@pagy.items > 0
end
end

def per_page_options
Expand Down
1 change: 1 addition & 0 deletions config/initializers/pagy.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
require "pagy/extras/trim"
require "pagy/extras/countless"
require "pagy/extras/size"

# For locales without native pagy i18n support
def pagy_locale_path(file_name)
Expand Down
3 changes: 2 additions & 1 deletion lib/avo/concerns/pagination.rb
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@ def apply_pagination(index_params:, query:)

send PAGINATION_METHOD[pagination_type.to_sym],
query,
items: index_params[:per_page],
items: index_params[:per_page], # Add per page in pagy < 9
limit: index_params[:per_page], # Add per page in pagy >= 9
link_extra: data_turbo_frame, # Add extra arguments in pagy 7.
anchor_string: data_turbo_frame, # Add extra arguments in pagy 8.
params: extra_pagy_params,
Expand Down

0 comments on commit 6af4f0e

Please sign in to comment.