Skip to content

Commit

Permalink
fix: pagy 9 support (#3090)
Browse files Browse the repository at this point in the history
* fix: pagy 9 support

* fix: pagy 9 support

* fix test
  • Loading branch information
Paul-Bob authored Aug 2, 2024
1 parent a763f23 commit bc0c2f6
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 8 deletions.
2 changes: 1 addition & 1 deletion Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -421,7 +421,7 @@ GEM
nokogiri (1.16.6-x86_64-linux)
racc (~> 1.4)
orm_adapter (0.5.0)
pagy (8.6.3)
pagy (9.0.5)
parallel (1.25.1)
parser (3.3.4.0)
ast (~> 2.4.1)
Expand Down
2 changes: 1 addition & 1 deletion app/components/avo/paginator_component.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ def change_items_per_page_url(option)
def render?
return false if discreet_pagination && pagy.pages <= 1

if ::Pagy::VERSION > ::Gem::Version.new("9.0")
if ::Pagy::VERSION >= ::Gem::Version.new("9.0")
@pagy.limit > 0
else
@pagy.items > 0
Expand Down
2 changes: 1 addition & 1 deletion app/components/avo/views/resource_index_component.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@
<% end %>
<% if view_type.to_sym == :table || view_type.to_sym == :map %>
<% if @records.present? %>
<div class="mt-4">
<div class="mt-4 w-full">
<%= render Avo::PaginatorComponent.new pagy: @pagy, turbo_frame: turbo_frame || "none", index_params: @index_params, resource: @resource, parent_record: parent_record, discreet_pagination: field&.discreet_pagination %>
</div>
<% end %>
Expand Down
2 changes: 1 addition & 1 deletion config/initializers/pagy.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
require "pagy/extras/trim"
require "pagy/extras/countless"
if ::Pagy::VERSION > ::Gem::Version.new("9.0")
if ::Pagy::VERSION >= ::Gem::Version.new("9.0")
require "pagy/extras/size"
end

Expand Down
6 changes: 2 additions & 4 deletions spec/system/avo/filters/filters_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -342,10 +342,8 @@
wait_for_loaded
check "Featured"

expect(page).to have_css "[data-turbo-frame][aria-label='Next']"
# expect to have the previous link disabled (no turbo-frame attached)
expect(page).to have_css "[data-turbo-frame][aria-label='Previous']"
expect(page).not_to have_css "[data-turbo-frame][aria-label='Previous']"
expect(page).to have_css "[aria-label='Next']"
expect(page).to have_css "[aria-label='Previous']"

expect(find(".current")).to have_text "1"
expect(find(".current")).not_to have_text "2"
Expand Down

0 comments on commit bc0c2f6

Please sign in to comment.