Skip to content

Commit b0656e8

Browse files
authored
[BootstrapAdminUi] Remove pagination selector is there are no other limits (#163)
**Before** ![image](https://github.com/user-attachments/assets/c951c6a4-6c25-4c6b-8c57-769c6ddece35) **After** ![image](https://github.com/user-attachments/assets/9c540c76-15a3-4ce1-adfd-346e73fdb46e) **And still ok with several available pagination limits.** ![image](https://github.com/user-attachments/assets/9999dd3f-ab7f-4541-99f5-4eb541492e9d)
2 parents 3c169f0 + bc1d28a commit b0656e8

File tree

2 files changed

+15
-10
lines changed

2 files changed

+15
-10
lines changed

app/Grid/TalkGrid.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ public function buildGrid(GridBuilderInterface $gridBuilder): void
4444
{
4545
$gridBuilder
4646
->addOrderBy('startsAt')
47+
->setLimits([10, 25, 50])
4748
->addFilter(
4849
EntityFilter::create('conference', Conference::class)
4950
->setLabel('app.ui.conference')

src/BootstrapAdminUi/templates/shared/helper/pagination.html.twig

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,19 @@
1111
{% endmacro %}
1212

1313
{% macro number_of_results_selector(paginator, pagination_limits) %}
14-
<div class="dropdown">
15-
<button type="button" class="btn dropdown-toggle" data-bs-toggle="dropdown">
16-
{{ 'sylius.ui.show'|trans }} {{ paginator.maxPerPage }}
17-
</button>
18-
<div class="dropdown-menu dropdown-menu-end ">
19-
{% for limit in pagination_limits|filter(limit => limit != paginator.maxPerPage) %}
20-
{% set path = path(app.request.attributes.get('_route'), app.request.attributes.all('_route_params')|merge(app.request.query)|merge({'limit': limit})) %}
21-
<a class="dropdown-item" href="{{ path }}">{{ limit }}</a>
22-
{% endfor %}
14+
{% set other_pagination_limits = pagination_limits|filter(limit => limit != paginator.maxPerPage) %}
15+
16+
{% if other_pagination_limits is not empty %}
17+
<div class="dropdown">
18+
<button type="button" class="btn dropdown-toggle" data-bs-toggle="dropdown">
19+
{{ 'sylius.ui.show'|trans }} {{ paginator.maxPerPage }}
20+
</button>
21+
<div class="dropdown-menu dropdown-menu-end ">
22+
{% for limit in other_pagination_limits %}
23+
{% set path = path(app.request.attributes.get('_route'), app.request.attributes.all('_route_params')|merge(app.request.query)|merge({'limit': limit})) %}
24+
<a class="dropdown-item" href="{{ path }}">{{ limit }}</a>
25+
{% endfor %}
26+
</div>
2327
</div>
24-
</div>
28+
{% endif %}
2529
{% endmacro %}

0 commit comments

Comments
 (0)