-
Notifications
You must be signed in to change notification settings - Fork 407
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
Countless pagination #108
Countless pagination #108
Conversation
@workgena I didn't try the code yet. If you have time, please, take a look at it. The doc should be already OK, but it is missing the tests for the |
Today I'll take a look at this solution. And will write tests for it. One thing I see strait away is:
Since, it is another subclass - it should be OK, no braking change, I think. Worth mention in documentation. |
True! I thought about adding it, and then I forgot. Thanks.
…On Mon, Nov 19, 2018, 2:41 PM Gena M. ***@***.***> wrote:
Today I'll take a look at this solution. And will write tests for it.
One thing I see strait away is:
- original Pagy returns ActiveRelation, in cast of ActiveRecord(Rails)
- Contless returns an Array
Since, it is another subclass - it should be OK, no braking change, I
think. Worth mention in documentation.
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#108 (comment)>, or mute
the thread
<https://github.com/notifications/unsubscribe-auth/AAGJcTXRppmShfU-kxfZp5pbZwyNYQVJks5uwmCcgaJpZM4Yn6xi>
.
|
Thanks for fixing my typos in the items test :). |
Many cases for Some new logic in attr_reader :count, :page, :items, :vars, :pages, :last, :offset, :from, :to, :prev, :next |
…Array; fix typo in comment
Countless test coverage
I've integrated this I was a little bit concerned about Each user can decide what pagination to use: Normal(with count) or Fast(Countless) by changing user-settings. So, Both scenarios work as expected. |
I didn't understand what was your concern with BTW, your use-case looks interesting. If you have time, you may want to write some article/tutorial explaining what you did. |
pagy_get_vars_without_items(collection, vars) | ||
end | ||
alias_method :pagy_get_vars, :pagy_get_vars_with_items | ||
|
||
# support for countless extra | ||
if defined?(Pagy::COUNTLESS) # defined in the countless extra |
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.
Lets imagine PostsController with require 'pagy/extras/countless'
always. So Pagy::COUNTLESS = true
.
But in fact it uses normal pagination with @pagy, @records = pagy(collection)
.
I was afraid, that this block of code populates vars
with wrong values.
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.
understood. The COUNTLESS
constant is just to avoid to load the aliases and method for the items
extra... but that is done at load time. Then it does not matter because they are designed to work in parallel, with different named classes and methods.
Just a thought here: this looks great and I assume it would be mostly useful with endless scrolling and other non-nav UI. However this could still be useful when having a normal pagy_nav. And in those situations I think the nav helper should just have next/prev links. Currently it will shows "page 1, 2" on load when the total pages is maybe 90. I understand why, but the result is confusing UX. So a better situation for the user would be to just have next/prev links and skip the page numbers. |
@espen: just feed |
BTW, me miss this in documentation 📚 ... |
@espen @workgena Endless scrolling (or incremental scroll) is coming with the I need someone for trying it and writing tests (hoping to be able to push it soon with at least the doc) |
Thanks. Will try this out a bit more. I think as a user (at least in my app) it's rarely relevant to me how many pages I have. Either I use search or just click next. So skipping one SQL query and not present page links could be a good solution both for performance and UX. Awesome to hear that endless scrolling will be implemented. |
Add the
Pagy::Countless
subclass and thecountless
extra.