-
Notifications
You must be signed in to change notification settings - Fork 43
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 creating pager range #245
Conversation
This BTW what we use public function getPages(): array
{
$start = 1;
$numAdjacents = (int) floor(($this->maxPages - 1) / 2);
if ($this->currentPage - $numAdjacents < $start) {
$begin = $start;
$end = min($this->numPages, $this->maxPages);
} elseif ($this->currentPage + $numAdjacents > $this->numPages) {
$begin = max($start, $this->numPages - $this->maxPages + 1);
$end = $this->numPages;
} else {
$begin = $this->currentPage - $numAdjacents;
$end = $this->currentPage + $numAdjacents;
}
return range($begin, $end, 1);
} |
@JanTvrdik Yours variant more shortly )) |
@JanTvrdik I try your code. It is good. return array_unique(array_merge(
[1],
range($begin, $end, 1),
[$this->numPages]
)); and we get that I try use your code in PR |
I think this changes need be in |
Looks like a good fix. Please rebase you PR to 2.1 branch. I have changed the base in the PR, you only need to rebase and push the changes. |
@serieznyi We solve the „always display first page“ problem in template {% set paginationRoute = app.request.attributes.get('_route') %}
{% set paginationParams = filters.pagination.getUrlParameters() %}
{% set pages = filters.pagination.pages %}
<ul>
{% if pages|first != 1 %}
<li><a href="{{ ongr_paginate_path(paginationRoute, 1, paginationParams) }}">1</a></li>
<li>…</li>
{% set pages = pages|slice(2) %}
{% endif %}
{% for page in pages %}
<li class="{% if page == filters.pagination.getCurrentPage %}is-active{% endif %}">
<a href="{{ ongr_paginate_path(paginationRoute, page, paginationParams) }}">{{ page }}</a>
</li>
{% endfor %}
</ul> |
@saimaz with rebase my branch contains not may commits. So i do cherry-pick. |
@saimaz why travic-ci fail on prepare tests environment? What I need to do? |
@saimaz I read Travic-CI docs and understand what a problem. |
Thanks @serieznyi for the changes. I fixed Travis issues. Lets see if there will be any errors. |
Ok, seems like token fix didn't help. There is no java 8 anymore in the current travis image we are using. So I changed the java version to 9 in the 2.1 branch. Apparently one test is failing, I will take a look whats wrong with it. If someone could help on this I would appreciate. |
Thanks @serieznyi for the fixes it helped me a lot! Appreciate this. You can rebase now with 2.1 branch and I could merge this as well and then release a patch version. |
@saimaz maybe i simple merge origin/2.1 in my feature branch and you use squash merge if all ok? |
Sure I could squash merging the PR, but travis still freaks out with errors :( |
@saimaz I know about tests fail. I try fix it in few days |
@saimaz tests fixed. I think what you need see my code and analyse what I do. |
Why did you set max pages to 3 instead of 2? |
@saimaz Because I throw exception then maxPages less 3. Also I have some errors in my logic and I try fix it. |
@saimaz I fix my logic. You can check it. Try tests |
$this->numPages = (int) ceil($this->totalItems/$this->itemsPerPage); | ||
|
||
$this->maxPages = $maxPages < 3 ? 3 : $maxPages; |
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.
@saimaz I replace throwing exception on default minimum value because I afraid that my changes crash somebody app.
Anybody can watch my PR? Please ) |
I'm checking it. Looks quite good. Will test it and merge it quite soon ;) Thanks for the PR! |
quite soon? ;) |
yep ;) |
How come this was only merges into 2.1? Isn't this bug relevant for all branches? |
Pager always create count pages equals value of PagerAwareViewData::maxPages.
So I am fix it.
I use logic from this function in repository jasongrimes/php-paginator
UPDATE 1
I use modified code of @JanTvrdik