-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Pagination #1517
Pagination #1517
Conversation
Added DS.Request class for pagination, sinceToken etc Added documentation Store any metadataFor(type) in the created DS.AdapterPopulatedRecordArray
Added pagination support to findAll() Added ability to specify the request param to use for `page` and `pageSize`
I've just noticed the source for |
* upstream/master: Latest ember-dev uses local packages. [BUGFIX beta] Prevent error in failed reload().
* master: Latest ember-dev uses local packages. Fixed JSONSerializer.extractArray() [BUGFIX beta] Prevent error in failed reload(). Conflicts: packages/ember-data/lib/serializers/json_serializer.js
Tests are complete (AFAICT), looking forward to some feedback. Bring it on! |
Not knowing much of ember (data) internals, I'm wondering whether it will be possible - with your work merged - to do pagination with links. What I have in my User response right now: Will this PR help with that? |
Yes it will. My plan is to publish an My hope is that the community will iterate on the best solution at the UI end and we’ll get something that’s ready to move into core. |
How we can get size of pages? |
The adapter can specify the page size, this is controlled by it's I've just added a binding in
It's also possible for the pagination to be enforced from the server side, in which case this can be found in
You just need to have two |
Can you add records to a not-completely loaded relationship? And can you persist that to the server? |
Added pageSize, total, totalPages and isFinished to AdapterPopulatedRecordArray Added normalizeMetadata() to JSONSerializer to provide standardised access to page, pageSize, total, isFinished Added pagination tests metaForType() object is now an Ember.Object so it is observable Refactored for separation of concerns in Request and AdapterPopulatedRecordArray Changed AdapterPopulatedRecordArray.page to startPage and endPage
* upstream/master: [DOC] Stop store.pushPayload docs overwriting store.push
I've thrown together the beginnings of a module that shows how this PR can be used to build the UI. It provides 'infinite-scroll' style pagination and also standard page-based navigation as well. https://github.com/aexmachina/ember-pager You can see a demo here: http://jsbin.com/ujaWImap/latest |
@wycats and @bradleypriest, not really getting any feedback on this - is there something that I should be doing to get this moving forward? I think it's important that we get this in before 1.0 - it'd be a real shame for 1.0 to go out without decent support for pagination. |
Hey @aexmachina, love what you're doing here, I haven't had much time to check through it at the moment, but I'll try and have a look this week sometime. However, I personally am kind of against putting this in before 1.0. Flexible pagination is hard, and I'd rather we manage this as a separate plugin being used in production apps for a couple of cycles first. |
Hi @bradleypriest, thanks for getting back to me. What I'm trying to do here is to add the absolute minimum that's required in core, in order to allow the rest to be implemented using a plugin. Essentially all this PR does is to add support for Without this core support in Ember Data I think any plugin is always going to having to do heavy lifting to make this work, and we're not providing the community with clear conventions for how to represent this information. However, with the core features in this PR it become pretty simple to provide pagination support on top of Ember Data. I've pushed an ember-pager plugin that shows one way that this could be used, and you can see a JSBin example here. But I'm sure there's lots of other ways this could be done, and I don't claim to know which one is the 'best'. I personally think that this really does need to be in 1.0, and I think that this PR provides a very minimal and non-controversial implementation that allows the community to work through the details, providing the 'conventions' that then allow the community to build on top of. Really looking forward to hearing your thoughts :) |
The minimal and controversial support is the support for I would concur with @bradleypriest on this. Let's make an ember-data specific library that can add conventional pagination. If there are ember-data APIs that make it impossible to do that, let's discuss what those are. |
Here is how i rewrite (https://github.com/VisualGuruz/emberjs-pageable) one existing mixin: https://gist.github.com/mahasamatman/b58622b51364c87f7814 It completely independent from Ember-Data (except metadata properties, but there are several methods to load it). The only thing you should do - is implement getPage(page) action somwhere. Simple? Yes:) |
I totally agree here. That's precisely what I'm trying to do - I accept that I may be overreaching with the addition of
The @mahasamatman, that's a really nice solution. The main difference if this PR was accepted is that the The main benefits of this PR can be summarised as follows:
And we also get I'd be open to doing this entirely in a plugin, but I can't see how that could be done using what's currently supported. Basically, if this PR goes too far then we can remove |
Some work I've made related to infinite scroll, search filters and pagination, not depending on any new thing in ED, working with ember-list. I posted here since I thought it might help/inspire/whatever: https://gist.github.com/huafu/6984862 |
resolver = Ember.RSVP.defer(); | ||
request = adapter.requestFor(this, type, null, page); | ||
|
||
request.fetchPage = function(store, type, query, page) { |
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.
rather then placing this on the object, it seems like it should be an argument/option to requestFor and passed to the request constructor.
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.
Yep, that's good feedback. Will do.
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.
Have done.
Several improvements based on feedback from stefanpenner
@stefanpenner I've made a bunch of changes based on your feedback (thanks!) When would be a good time for us to have a chat with the developer you mentioned would be worth chatting to? Really hoping you can continue to help me push this forward :) |
Is this dead? |
@recipher I'm willing, but I haven't been able to get agreement from the core team on moving this forward. I just don't think that it's a priority for them at this stage. @wagenet has indicated that he's open to a discussion on the forum, so I'll try to restart discussion over there... |
That'd be great. This would have made my work so much easier on the thing Does this work on relationships? Something like... this.get('blog.comments').loadMore(); ? On 13 June 2014 00:42, Simon Wade notifications@github.com wrote:
|
Also issue #1937 is a common use case. You only see examples with the find() method. But you should also be able to query async hasMany relations (through the |
Just talked to @aexmachina, we will be using the new JSONApi meta for pagination, so closing this PR. |
@aexmachina What's the state of play with this? |
Long stale by now :) |
This PR adds the foundation for pagination support in Ember Data. Example usage using an 'infinite-scroll'
loadMore
approach can be seen here. The goal of this PR is to provide the underlying requirements to support pagination, so that the community can iterate on rest of the implementation in userland until we've got something we're happy with.The solution adds a
DS.Request
class to contain information about the parameters that were used to create a givenAdapterPopulatedArray
, thereby allowing for more pages of results to be fetched from the server.I've folded the
sinceToken
into theRequest
class, but this is the only 'breaking' change. SoAdapter.findAll: function(store, type, sinceToken)
is nowAdapter.findAll: function(store, type, request)
.Please feel free to offer any feedback - I've tried to stay close to the style of the rest of the project, but happy to take on board any feedback.
One possible concern is that I'm using
page
andpageSize
parameters which is nice and simple but there's an edge case where thepageSize
changes and leads to duplicate/missing records in the series of pages. I'd prefer to useoffset
andlimit
, but the common practice seems to bepage
andpageSize
so I've used this approach instead.Todo
findQuery()
andfindAll()
support pagination, I'll add support for the otherfind...()
methods now