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

A page can be both current and first or last #28

Closed
GarthSnyder opened this issue Feb 23, 2011 · 2 comments
Closed

A page can be both current and first or last #28

GarthSnyder opened this issue Feb 23, 2011 · 2 comments

Comments

@GarthSnyder
Copy link

The default paginator has separate partials for the current page, the first page, and the last page. However, these are not mutually exclusive sets. To facilitate styling, the paginator should emit page spans with both the current and first/last classes when this is appropriate.

Perhaps there should just be one page partial: include "first" class if page.first?, include "last" class if page.last?, include "current" class if page.current?, and link the page number if not page.current?.

@amatsuda
Copy link
Member

closed by 4beef97 a page can be both current and first or last

merge _current_page, _first_page_link, _last_page_link and _page_link into one _page partial

@amatsuda
Copy link
Member

Hi Garth,

Thank you for your opinion. Very good point as usual.

I understand what you mean. I know that Ruby/Rails can do that in a very simple way. In fact, my very first implementation was just a 40 lines of code like this amatsuda@bd2f1b5
and it was working almost the same with current version.

And since then, I've been trying to decouple the logic and view as far as possible, because I wanted to create something designers can understand. Then finally I came up with current style that does never use if or for - each or ternary operator or content_tag or any other Ruby code inside each minimum partial.

As a result... honestly, I'm not so much satisfied with current helper. Not only because a page can not be both current and first or last. I should admit that current "partialful" approach makes the generated code hard to understand for both programmers and designers.

So, I just implemented your proposal and pushed the code to a new branch. Perhaps the helper on this banch will be logically correct, and became a bit easier to deal with.
https://github.com/amatsuda/kaminari/tree/issue_28

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

No branches or pull requests

2 participants