Skip to content
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

Fix logic in Paginator hasNextPage() method. #1467

Open
wants to merge 1 commit into
base: dev-master
Choose a base branch
from

Conversation

onlywei
Copy link

@onlywei onlywei commented Dec 6, 2013

Previously was not working when totalItems is 0.

@@ -117,7 +117,11 @@ Y.mix(PaginatorCore.prototype, {
@return {Boolean} `true` if there is a next page, `false` otherwise.
*/
hasNextPage: function () {
return (!this.get('totalItems') || this.get('page') < this.get('totalPages'));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Or return this.get('totalItems') && (this.get('page') < this.get('totalPages'));

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Uh oh. I misunderstood the intent of the code.

You can see in the API docs for the method that if 'totalItems' isn't set, Paginator assumes there is always a next page. I guess this is to simulate infinite result sets.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@lsmith That's correct. In the event that it is bound to a datasource with an unknown upper limit (ie a search page, or email inbox)

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It doesn't look like I can check if this.get('totalItems') === 0 either because 0 is "unset" for that attribute, right?

Searches returning 0 results is a very real case, though. Need a way to deal with this.

@onlywei
Copy link
Author

onlywei commented Dec 6, 2013

I'm having trouble running yogi test for this module, how about you?

Update: works now after running npm install in the root directory.

@@ -4,7 +4,7 @@ Paginator Change History
@VERSION@
------

* No changes.
* Fix hasNextPage() method. Previously failing when totalItems = 0.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"* hasNextPage() now correctly reports false when there are no items to be paged over."

@ghost ghost assigned apipkin Dec 6, 2013
items to be paged over.

Previously was not working when totalItems is 0.
@lsmith
Copy link
Contributor

lsmith commented Dec 6, 2013

@onlywei I would suggest opening an issue for this and discuss with @apipkin. It looks like the code is working as designed, but does not distinguish the "no items" case from the "unbounded items" case.

@apipkin apipkin removed their assignment Mar 15, 2014
@okuryu okuryu assigned apipkin and unassigned apipkin Mar 16, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants