Skip to content

Commit

Permalink
Fixed pager when viewing a entity history with lots of entries (#162)
Browse files Browse the repository at this point in the history
  • Loading branch information
DamienHarper committed Jan 9, 2020
1 parent 4ea1709 commit f08476b
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
{% endfor %}
</div>

{{ pager.render(entity, paginator) }}
{{ pager.render(entity, id, paginator) }}
</div>
</div>
{% endblock dh_doctrine_audit_content %}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{% macro render(entity, paginator, proximity = 3, displayedPages = 10) %}
{% macro render(entity, id = null, paginator, proximity = 3, displayedPages = 10) %}
{% if paginator.haveToPaginate %}
{% set start = paginator.currentPage - proximity %}
{% set end = paginator.currentPage + proximity %}
Expand All @@ -13,72 +13,72 @@

<nav class="float-right">
<ul class="pagination">
{{ _self.first(entity, paginator) }}
{{ _self.previous(entity, paginator) }}
{{ _self.dotsIfStartIsOver3(entity, paginator, start) }}
{{ _self.pages(entity, paginator, start, end) }}
{{ _self.dotsIfEndIsUnder3ToLast(entity, paginator, end) }}
{{ _self.next(entity, paginator) }}
{{ _self.last(entity, paginator) }}
{{ _self.first(entity, id, paginator) }}
{{ _self.previous(entity, id, paginator) }}
{{ _self.dotsIfStartIsOver3(entity, id, paginator, start) }}
{{ _self.pages(entity, id, paginator, start, end) }}
{{ _self.dotsIfEndIsUnder3ToLast(entity, id, paginator, end) }}
{{ _self.next(entity, id, paginator) }}
{{ _self.last(entity, id, paginator) }}
</ul>
</nav>
{% endif %}
{% endmacro render %}

{% macro first(entity, paginator) %}
{% macro first(entity, id, paginator) %}
{% if paginator.hasPreviousPage %}
<li class="page-item"><a href="{{ path('dh_doctrine_audit_show_entity_history', {entity: entity, page: 1}) }}" class="page-link" rel="previous"><i class="fa fw fa-angle-double-left"></i> {% trans %}audit.pager.first{% endtrans %}</a></li>
<li class="page-item"><a href="{{ path('dh_doctrine_audit_show_entity_history', {entity: entity, id: id, page: 1}) }}" class="page-link" rel="previous"><i class="fa fw fa-angle-double-left"></i> {% trans %}audit.pager.first{% endtrans %}</a></li>
{% else %}
<li class="page-item disabled"><span class="page-link"><i class="fa fw fa-angle-double-left"></i> {% trans %}audit.pager.first{% endtrans %}</span></li>
{% endif %}
{% endmacro first %}

{% macro previous(entity, paginator) %}
{% macro previous(entity, id, paginator) %}
{% if paginator.hasPreviousPage %}
<li class="page-item"><a href="{{ path('dh_doctrine_audit_show_entity_history', {entity: entity, page: paginator.previousPage}) }}" class="page-link" rel="previous"><i class="fa fw fa-angle-left"></i> {% trans %}audit.pager.previous{% endtrans %}</a></li>
<li class="page-item"><a href="{{ path('dh_doctrine_audit_show_entity_history', {entity: entity, id: id, page: paginator.previousPage}) }}" class="page-link" rel="previous"><i class="fa fw fa-angle-left"></i> {% trans %}audit.pager.previous{% endtrans %}</a></li>
{% else %}
<li class="page-item disabled"><span class="page-link"><i class="fa fw fa-angle-left"></i> {% trans %}audit.pager.previous{% endtrans %}</span></li>
{% endif %}
{% endmacro previous %}

{% macro dotsIfStartIsOver3(entity, paginator, start) %}
{% macro dotsIfStartIsOver3(entity, id, paginator, start) %}
{% if start > 1 %}
<li class="page-item disabled"><span class="page-link">&hellip;</span></li>
{% endif %}
{% endmacro dotsIfStartIsOver3 %}

{% macro pages(entity, paginator, start, end) %}
{% macro pages(entity, id, paginator, start, end) %}
{% for i in start..end %}
{{ _self.page(entity, paginator, i) }}
{{ _self.page(entity, id, paginator, i) }}
{% endfor %}
{% endmacro pages %}

{% macro dotsIfEndIsUnder3ToLast(entity, paginator, end) %}
{% macro dotsIfEndIsUnder3ToLast(entity, id, paginator, end) %}
{% if end < paginator.numPages %}
<li class="page-item disabled"><span class="page-link">&hellip;</span></li>
{% endif %}
{% endmacro dotsIfEndIsUnder3ToLast %}

{% macro next(entity, paginator) %}
{% macro next(entity, id, paginator) %}
{% if paginator.hasNextPage %}
<li class="page-item"><a href="{{ path('dh_doctrine_audit_show_entity_history', {entity: entity, page: paginator.nextPage}) }}" class="page-link" rel="next">{% trans %}audit.pager.next{% endtrans %} <i class="fa fw fa-angle-right"></i></a></li>
<li class="page-item"><a href="{{ path('dh_doctrine_audit_show_entity_history', {entity: entity, id: id, page: paginator.nextPage}) }}" class="page-link" rel="next">{% trans %}audit.pager.next{% endtrans %} <i class="fa fw fa-angle-right"></i></a></li>
{% else %}
<li class="page-item disabled"><span class="page-link">{% trans %}audit.pager.next{% endtrans %} <i class="fa fw fa-angle-right"></i></span></li>
{% endif %}
{% endmacro next %}

{% macro last(entity, paginator) %}
{% macro last(entity, id, paginator) %}
{% if paginator.hasNextPage %}
<li class="page-item"><a href="{{ path('dh_doctrine_audit_show_entity_history', {entity: entity, page: paginator.numPages}) }}" class="page-link" rel="previous">{% trans %}audit.pager.last{% endtrans %} <i class="fa fw fa-angle-double-right"></i></a></li>
<li class="page-item"><a href="{{ path('dh_doctrine_audit_show_entity_history', {entity: entity, id: id, page: paginator.numPages}) }}" class="page-link" rel="previous">{% trans %}audit.pager.last{% endtrans %} <i class="fa fw fa-angle-double-right"></i></a></li>
{% else %}
<li class="page-item disabled"><span class="page-link">{% trans %}audit.pager.last{% endtrans %} <i class="fa fw fa-angle-double-right"></i></span></li>
{% endif %}
{% endmacro last %}

{% macro page(entity, paginator, page) %}
{% macro page(entity, id, paginator, page) %}
{% if page == paginator.currentPage %}
<li class="page-item active"><span class="page-link">{{ page }} <span class="sr-only">{% trans %}audit.pager.current{% endtrans %}</span></span></li>
{% else %}
<li class="page-item"><a href="{{ path('dh_doctrine_audit_show_entity_history', {entity: entity, page: page}) }}" class="page-link">{{ page }}</a></li>
<li class="page-item"><a href="{{ path('dh_doctrine_audit_show_entity_history', {entity: entity, id: id, page: page}) }}" class="page-link">{{ page }}</a></li>
{% endif %}
{% endmacro page %}

0 comments on commit f08476b

Please sign in to comment.