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

Fixed start and end bug #23

Merged
merged 2 commits into from
Jul 14, 2016
Merged

Conversation

ultimate-tester
Copy link
Contributor

Makes sure the start and end are now correctly determined. It tries to keep the "current page button" in the middle of all page buttons. Also no more lower than zero browsing.
Also fixed up the test to correctly test this behavior.

The new calculation of start and end tries to keep to current page in
the middle of the buttons for the pages. Also, no more lower than one
paginating.
Page limit is now 5 to correctly test the current page being in the
middle of the buttons.
@coveralls
Copy link

coveralls commented Jul 13, 2016

Coverage Status

Coverage remained the same at 96.774% when pulling c4060f3 on ultimate-tester:master into cf460aa on expressjs:master.

@niftylettuce
Copy link
Contributor

@ultimate-tester can you explain what this pull request does? how was it not correct before and how is it correct now?

@ultimate-tester
Copy link
Contributor Author

ultimate-tester commented Jul 14, 2016

Certainly. The current version has the getArrayPages function that returns a function that returns all pages. There is an optional limit to limit the amount of buttons (or pages) to be returned. If you set this limit to 3 (for instance.. This could be any number) and the actual total amount of pages is HIGHER than 3, then every page after page 3 will cause the number of buttons to increase. You are on page 4, then this means you have 4 buttons. Page 5 will have 5 buttons, page 6 will have 6 etc. etc. etc.

My fix correctly follows the limit. Set it to 3, and it will always return 3 pages with the current page in the middle of them. To demonstrate, let's say you are on page number 9 and have limit set to 3. This will be returned:

[8] [9] [10]

So actually this brings 2 new things. A correct limit, and the current page always being the middle one of the buttons shown.

@niftylettuce
Copy link
Contributor

Perfect!

@niftylettuce niftylettuce merged commit 0218747 into expressjs:master Jul 14, 2016
@niftylettuce
Copy link
Contributor

I released v0.2.1 to NPM just now! npm i --save express-paginate@0.2.1

Thank you so much @ultimate-tester for your contributions, fixed tests, and explanations 😄

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