-
-
Notifications
You must be signed in to change notification settings - Fork 97
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
Show 'Page 1 of 1' instead of 'Page 1 of 0'. #1413
Conversation
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.
Hi, thanks for the PR!
Some remarks though:
- We're using automatic changelog generation based on commit messages using release-it, conventional-changelog and commitlint. Please change your commit message according to:
https://github.com/Patternslib/Patterns/blob/master/docs/developer/styleguide.md#commits-messages
If you even add Fixes: ...
speficiers, than you automatically reference and close the related issues.
My suggestion:
fix(pat-structure): If there are no search results, still show "Page 1 of 1" instead "Page 1 of 0".
Fixes: plone/mockup#1412
Fixes: plone/Products.CMFPlone#3591
- See my code suggestion. I think it's simpler and I don't know if Backbone goes unnecessarily crazy when changing some state attributes too often. My simplification assigns the value in one go.
this.state.totalPages = Math.ceil(response.total / state.pageSize); | ||
this.state.totalPages = this.state.totalPages === 0 ? 1 : this.state.totalPages; |
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.
this.state.totalPages = Math.ceil(response.total / state.pageSize); | |
this.state.totalPages = this.state.totalPages === 0 ? 1 : this.state.totalPages; | |
// Calculate the number of pages and set it to "1" if there are no results. | |
this.state.totalPages = Math.ceil(response.total / state.pageSize) || 1; |
Looking at the issue, I'd recomment to completely remove the pagination when there is no result in the listing. Would make more sense to me. Btw. thank you @devdanzin for contributing! We were talking briefly at the conference about the |
cf545b9
to
fa3ecf7
Compare
Thank you very much for the review!
I've adapted your suggestion, please let me know if it should be improved.
I tried @petschki's suggestion of not showing the pagination text and it looks better to me. Please let me know which option we should go with and whether the code makes sense. |
Done, not sure whether it's better to leave the empty div or also make it conditional. I've left it in current form.
Thank you for the review and for helping me at the sprint! |
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.
Yes, not showing the pagination at all is even a better solution.
I lean towards not showing the div when there are no results because I favor simple, small and clean HTML output. But I'm OK with the current solution.
…ation text. Fixes: plone#1412 Fixes: plone/Products.CMFPlone#3591
fa3ecf7
to
826bafe
Compare
This trivial PR intends to fix #1412 and plone/Products.CMFPlone#3591 by checking that
totalPages
is zero and setting it to one.