-
Notifications
You must be signed in to change notification settings - Fork 63
[Bug Fix] Fix DataTable pagination with array params and adapter naming #359
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
Merged
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
b986053
Fix build_query losing array param values on sort/paginate
djalmaaraujo 5959464
Move pagination adapters into data_table/ and rename to avoid conflicts
djalmaaraujo a626a9d
Add customizable prev/next labels and hide pagination for single page
djalmaaraujo 4940ef2
Remove unnecessary plain calls for label ivars in pagination
djalmaaraujo File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| # frozen_string_literal: true | ||
|
|
||
| module RubyUI | ||
| class DataTableKaminariAdapter | ||
| def initialize(collection) | ||
| @collection = collection | ||
| end | ||
|
|
||
| def current_page = @collection.current_page | ||
|
|
||
| def total_pages = @collection.total_pages | ||
|
|
||
| def total_count = @collection.total_count | ||
|
|
||
| def per_page = @collection.limit_value | ||
| end | ||
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| # frozen_string_literal: true | ||
|
|
||
| module RubyUI | ||
| class DataTableManualAdapter | ||
| attr_reader :current_page, :per_page, :total_count | ||
|
|
||
| def initialize(page:, per_page:, total_count:) | ||
| @current_page = page.to_i | ||
| @per_page = [per_page.to_i, 1].max | ||
| @total_count = total_count.to_i | ||
| end | ||
|
|
||
| def total_pages | ||
| [(@total_count.to_f / @per_page).ceil, 1].max | ||
| end | ||
| end | ||
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| # frozen_string_literal: true | ||
|
|
||
| module RubyUI | ||
| class DataTablePagyAdapter | ||
| def initialize(pagy) | ||
| @pagy = pagy | ||
| end | ||
|
|
||
| def current_page = @pagy.page | ||
|
|
||
| def total_pages = @pagy.pages | ||
|
|
||
| def total_count = @pagy.count | ||
|
|
||
| def per_page = @pagy.items | ||
| end | ||
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
6 changes: 3 additions & 3 deletions
6
...able_pagination_adapters/kaminari_test.rb → ...by_ui/data_table_kaminari_adapter_test.rb
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
10 changes: 5 additions & 5 deletions
10
..._table_pagination_adapters/manual_test.rb → ...ruby_ui/data_table_manual_adapter_test.rb
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 3 additions & 3 deletions
6
...ta_table_pagination_adapters/pagy_test.rb → test/ruby_ui/data_table_pagy_adapter_test.rb
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@djalmaaraujo I believe it's not necessary anymore.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The gem doesn't use Zeitwerk, so require_relative is needed here. When the generator copies the files into a Rails app, the app's autoloader handles it — but in the gem context these are required.