-
Notifications
You must be signed in to change notification settings - Fork 37
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
Generate Page Links without Pagination #59
Comments
Not currently, although I have been thinking about this and I'm trying out some approaches to making this work. As soon as I'm happy with it, I'll publish a prerelease package so you can try it out. Just out of curiosity, is there a specific reason you can't have the library handle pagination for you? I'm asking because I know pagination in Saule is somewhat limited currently, and I'd like to know what people are actually doing to make it better. |
We use a library that completely encapsulates the data access and the The really cool benefit of your library is that you define a resource and If we could set the page size, page number (current page) and a total Being able to specify meta data would be really useful as well. Thank you for this library, it has been incredibly helpful. On Fri, Dec 18, 2015 at 3:31 PM, Jouke van der Maas <
|
I've been thinking about the problem, and I'm thinking of providing a hook that Saule calls to find the current, next, previous, etc. page numbers. Ideally I'd let users provide the pagination scheme as well. The only thing I'm not sure how to do, is to provide the requested page to the action method. Is this library you are using publicly available? If so I'd like to take a look at it. If not, how do you provide paging information to it? I assume you would need to do that somewhere in your action method. |
@joukevandermaas would you be interested in sponsorship towards this feature? |
@bjornharrtell not really. I feel like involving money brings in a lot of other complications. Thanks for the offer. I am interested in working on this, though. This, #128 and #78 are some of the things I think Saule can really use. |
Ok that's understandable. Let me know what I can do to help. Will likely try to implement in near future but any input on how is of course appreciated. |
I think this involves a refactor in the way pagination gets applied. I'd like to move that code to By doing it that way you should get:
The method should take as many parameters as needed to make this convenient. I'm expecting this will be the collection you returned from the action method, all query parameters related to pagination and maybe the type of the items in the collection. If it turns out to be really hard to write code that applies pagination using generics, we might consider a different, typed API that is easier to use. We could also expose some helpers that would make this easier. |
(a long-term plan would be to move filters and sorting into this class too, that way everything works the same way and consumers get complete control if they need it) |
Revisiting this issue I agree that using an approach similar to the meta support would be nice but I have one concern. The concern is when I need some additional context (probably owned by the controller) to calculate meta and/or links data. To examplify, in the code at http://awesan.com/saule/content/8-adding-metadata.html the Total is calculated with people.Count(). What if that operation is too slow and we have the total count at some other source accessable using a service that the controller owns? I.e I'd like to be able to somehow inject a context into the GetMetadata method and the equivalent future method for links. |
I'm currently facing the same issue. There is a pretty simple solution to this problem in another project - Telerik MVC.
|
The use-case in this issue is supported as of #181, but I haven't had time to document it for a stable release yet. In general I don't think an issue should be closed if the new API does not have documentation. If you're happy looking at the PR to see how it works, you can use the latest pre-release to get this functionality today.
I agree with this in theory, but I want to think properly about what the API for those should be. Simply making existing stuff public without any thought will probably lead to bad usability. That said, I have accepted some recent PRs that made existing internal class public (possibly with some modifications). I'm generally happy making Saule more flexible as long as it doesn't break the simple 'getting started without configuration' cases. |
@joukevandermaas Thanks for a tip. Should have read changelog more carefully. A small insight maybe. While "HandlesQueryAttribute" solution seems to work for what it does, it does not allow Saule to create a "last" page link as described in here: http://jsonapi.org/format/#fetching-pagination, because it does not know what a total count is. It will also generate an incorrect "next" page link when being on a "last" page for a same reason. |
Since the documentation now exists, i will close this issue. |
Is there a way to generate the page links without the library handling the paging?
Basically the data has already been paged and I just need to get the page links generated.
The text was updated successfully, but these errors were encountered: