Skip to content

Commit a931da9

Browse files
authored
Respect setDisplayPaginationDetailsDisabled for unpaginated tables (rappasoft#2119)
* Respect setDisplayPaginationDetailsDisabled for unpaginated tables * Fix styling --------- Co-authored-by: lrljoe <[email protected]>
1 parent da04abd commit a931da9

File tree

3 files changed

+45
-92
lines changed

3 files changed

+45
-92
lines changed

resources/views/components/pagination.blade.php

Lines changed: 40 additions & 89 deletions
Original file line numberDiff line numberDiff line change
@@ -1,64 +1,60 @@
1-
@aware(['isTailwind','isBootstrap','isBootstrap4','isBootstrap5'])
2-
31
@includeWhen(
42
$this->hasConfigurableAreaFor('before-pagination'),
53
$this->getConfigurableAreaFor('before-pagination'),
64
$this->getParametersForConfigurableArea('before-pagination')
75
)
86

9-
@if ($this->isTailwind)
10-
<div {{ $this->getPaginationWrapperAttributesBag() }}>
11-
@if ($this->paginationVisibilityIsEnabled())
7+
<div {{ $this->getPaginationWrapperAttributesBag() }}>
8+
@if ($this->paginationVisibilityIsEnabled())
9+
@if ($this->isTailwind)
1210
<div class="mt-4 px-4 md:p-0 sm:flex justify-between items-center space-y-4 sm:space-y-0">
1311
<div>
14-
@if ($this->paginationIsEnabled() && $this->isPaginationMethod('standard') && $this->getRows->lastPage() > 1)
12+
@if ($this->paginationIsEnabled && $this->isPaginationMethod('standard') && $this->getRows->lastPage() > 1 && $this->showPaginationDetails)
1513
<p class="paged-pagination-results text-sm text-gray-700 leading-5 dark:text-white">
16-
@if($this->showPaginationDetails())
1714
<span>{{ __($this->getLocalisationPath.'Showing') }}</span>
1815
<span class="font-medium">{{ $this->getRows->firstItem() }}</span>
1916
<span>{{ __($this->getLocalisationPath.'to') }}</span>
2017
<span class="font-medium">{{ $this->getRows->lastItem() }}</span>
2118
<span>{{ __($this->getLocalisationPath.'of') }}</span>
2219
<span class="font-medium"><span x-text="paginationTotalItemCount"></span></span>
2320
<span>{{ __($this->getLocalisationPath.'results') }}</span>
24-
@endif
2521
</p>
26-
@elseif ($this->paginationIsEnabled() && $this->isPaginationMethod('simple'))
22+
@elseif ($this->paginationIsEnabled && $this->isPaginationMethod('simple') && $this->showPaginationDetails)
2723
<p class="paged-pagination-results text-sm text-gray-700 leading-5 dark:text-white">
28-
@if($this->showPaginationDetails())
29-
<span>{{ __($this->getLocalisationPath.'Showing') }}</span>
30-
<span class="font-medium">{{ $this->getRows->firstItem() }}</span>
31-
<span>{{ __($this->getLocalisationPath.'to') }}</span>
32-
<span class="font-medium">{{ $this->getRows->lastItem() }}</span>
33-
@endif
24+
<span>{{ __($this->getLocalisationPath.'Showing') }}</span>
25+
<span class="font-medium">{{ $this->getRows->firstItem() }}</span>
26+
<span>{{ __($this->getLocalisationPath.'to') }}</span>
27+
<span class="font-medium">{{ $this->getRows->lastItem() }}</span>
3428
</p>
35-
@elseif ($this->paginationIsEnabled() && $this->isPaginationMethod('cursor'))
29+
@elseif ($this->paginationIsEnabled && $this->isPaginationMethod('cursor'))
3630
@else
37-
<p class="total-pagination-results text-sm text-gray-700 leading-5 dark:text-white">
38-
{{ __($this->getLocalisationPath.'Showing') }}
39-
<span class="font-medium">{{ $this->getRows->count() }}</span>
40-
{{ __($this->getLocalisationPath.'results') }}
41-
</p>
31+
@if($this->showPaginationDetails)
32+
<p class="total-pagination-results text-sm text-gray-700 leading-5 dark:text-white">
33+
<span>{{ __($this->getLocalisationPath.'Showing') }}</span>
34+
<span class="font-medium">{{ $this->getRows->count() }}</span>
35+
<span>{{ __($this->getLocalisationPath.'results') }}</span>
36+
</p>
37+
@endif
4238
@endif
4339
</div>
4440

45-
@if ($this->paginationIsEnabled())
41+
@if ($this->paginationIsEnabled)
4642
{{ $this->getRows->links('livewire-tables::specific.tailwind.'.(!$this->isPaginationMethod('standard') ? 'simple-' : '').'pagination') }}
4743
@endif
4844
</div>
49-
@endif
50-
</div>
51-
@elseif ($this->isBootstrap4)
52-
<div {{ $this->getPaginationWrapperAttributesBag() }}>
53-
@if ($this->paginationVisibilityIsEnabled())
54-
@if ($this->paginationIsEnabled() && $this->isPaginationMethod('standard') && $this->getRows->lastPage() > 1)
45+
@else
46+
@if ($this->paginationIsEnabled && $this->isPaginationMethod('standard') && $this->getRows->lastPage() > 1)
5547
<div class="row mt-3">
5648
<div class="col-12 col-md-6 overflow-auto">
5749
{{ $this->getRows->links('livewire-tables::specific.bootstrap-4.pagination') }}
5850
</div>
5951

60-
<div class="col-12 col-md-6 text-center text-md-right text-muted">
61-
@if($this->showPaginationDetails())
52+
<div @class([
53+
"col-12 col-md-6 text-center text-muted",
54+
"text-md-right" => $this->isBootstrap4,
55+
"text-md-end" => $this->isBootstrap5,
56+
])>
57+
@if($this->showPaginationDetails)
6258
<span>{{ __($this->getLocalisationPath.'Showing') }}</span>
6359
<strong>{{ $this->getRows->count() ? $this->getRows->firstItem() : 0 }}</strong>
6460
<span>{{ __($this->getLocalisationPath.'to') }}</span>
@@ -69,22 +65,26 @@
6965
@endif
7066
</div>
7167
</div>
72-
@elseif ($this->paginationIsEnabled() && $this->isPaginationMethod('simple'))
68+
@elseif ($this->paginationIsEnabled && $this->isPaginationMethod('simple'))
7369
<div class="row mt-3">
7470
<div class="col-12 col-md-6 overflow-auto">
7571
{{ $this->getRows->links('livewire-tables::specific.bootstrap-4.simple-pagination') }}
7672
</div>
7773

78-
<div class="col-12 col-md-6 text-center text-md-right text-muted">
79-
@if($this->showPaginationDetails())
74+
<div @class([
75+
"col-12 col-md-6 text-center text-muted",
76+
"text-md-right" => $this->isBootstrap4,
77+
"text-md-end" => $this->isBootstrap5,
78+
])>
79+
@if($this->showPaginationDetails)
8080
<span>{{ __($this->getLocalisationPath.'Showing') }}</span>
8181
<strong>{{ $this->getRows->count() ? $this->getRows->firstItem() : 0 }}</strong>
8282
<span>{{ __($this->getLocalisationPath.'to') }}</span>
8383
<strong>{{ $this->getRows->count() ? $this->getRows->lastItem() : 0 }}</strong>
8484
@endif
8585
</div>
8686
</div>
87-
@elseif ($this->paginationIsEnabled() && $this->isPaginationMethod('cursor'))
87+
@elseif ($this->paginationIsEnabled && $this->isPaginationMethod('cursor'))
8888
<div class="row mt-3">
8989
<div class="col-12 col-md-6 overflow-auto">
9090
{{ $this->getRows->links('livewire-tables::specific.bootstrap-4.simple-pagination') }}
@@ -93,66 +93,17 @@
9393
@else
9494
<div class="row mt-3">
9595
<div class="col-12 text-muted">
96-
{{ __($this->getLocalisationPath.'Showing') }}
97-
<strong>{{ $this->getRows->count() }}</strong>
98-
{{ __($this->getLocalisationPath.'results') }}
99-
</div>
100-
</div>
101-
@endif
102-
@endif
103-
</div>
104-
@elseif ($this->isBootstrap5)
105-
<div {{ $this->getPaginationWrapperAttributesBag() }} >
106-
@if ($this->paginationVisibilityIsEnabled())
107-
@if ($this->paginationIsEnabled() && $this->isPaginationMethod('standard') && $this->getRows->lastPage() > 1)
108-
<div class="row mt-3">
109-
<div class="col-12 col-md-6 overflow-auto">
110-
{{ $this->getRows->links('livewire-tables::specific.bootstrap-4.pagination') }}
111-
</div>
112-
<div class="col-12 col-md-6 text-center text-md-end text-muted">
113-
@if($this->showPaginationDetails())
114-
<span>{{ __($this->getLocalisationPath.'Showing') }}</span>
115-
<strong>{{ $this->getRows->count() ? $this->getRows->firstItem() : 0 }}</strong>
116-
<span>{{ __($this->getLocalisationPath.'to') }}</span>
117-
<strong>{{ $this->getRows->count() ? $this->getRows->lastItem() : 0 }}</strong>
118-
<span>{{ __($this->getLocalisationPath.'of') }}</span>
119-
<strong><span x-text="paginationTotalItemCount"></span></strong>
120-
<span>{{ __($this->getLocalisationPath.'results') }}</span>
121-
@endif
122-
</div>
123-
</div>
124-
@elseif ($this->paginationIsEnabled() && $this->isPaginationMethod('simple'))
125-
<div class="row mt-3">
126-
<div class="col-12 col-md-6 overflow-auto">
127-
{{ $this->getRows->links('livewire-tables::specific.bootstrap-4.simple-pagination') }}
128-
</div>
129-
<div class="col-12 col-md-6 text-center text-md-end text-muted">
130-
@if($this->showPaginationDetails())
131-
<span>{{ __($this->getLocalisationPath.'Showing') }}</span>
132-
<strong>{{ $this->getRows->count() ? $this->getRows->firstItem() : 0 }}</strong>
133-
<span>{{ __($this->getLocalisationPath.'to') }}</span>
134-
<strong>{{ $this->getRows->count() ? $this->getRows->lastItem() : 0 }}</strong>
96+
@if($this->showPaginationDetails)
97+
{{ __($this->getLocalisationPath.'Showing') }}
98+
<strong>{{ $this->getRows->count() }}</strong>
99+
{{ __($this->getLocalisationPath.'results') }}
135100
@endif
136101
</div>
137102
</div>
138-
@elseif ($this->paginationIsEnabled() && $this->isPaginationMethod('cursor'))
139-
<div class="row mt-3">
140-
<div class="col-12 col-md-6 overflow-auto">
141-
{{ $this->getRows->links('livewire-tables::specific.bootstrap-4.simple-pagination') }}
142-
</div>
143-
</div>
144-
@else
145-
<div class="row mt-3">
146-
<div class="col-12 text-muted">
147-
{{ __($this->getLocalisationPath.'Showing') }}
148-
<strong>{{ $this->getRows->count() }}</strong>
149-
{{ __($this->getLocalisationPath.'results') }}
150-
</div>
151-
</div>
152103
@endif
153104
@endif
154-
</div>
155-
@endif
105+
@endif
106+
</div>
156107

157108
@includeWhen(
158109
$this->hasConfigurableAreaFor('after-pagination'),

src/Traits/Helpers/PaginationHelpers.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ public function getPaginationTheme(): string
2727
return $this->paginationTheme;
2828
}
2929

30+
#[Computed]
3031
public function paginationIsEnabled(): bool
3132
{
3233
return $this->getPaginationStatus() === true;
@@ -118,6 +119,7 @@ public function getPerPageDisplayedItemCount(): int
118119
return $this->paginationCurrentCount;
119120
}
120121

122+
#[Computed]
121123
public function showPaginationDetails(): bool
122124
{
123125
return $this->shouldShowPaginationDetails === true;

tests/Unit/Traits/Visuals/PaginationVisualsTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@ public function test_detailed_pagination_is_displayed_standard_bs4(): void
186186
Livewire::test(PetsTable::class)
187187
->call('setTheme', 'bootstrap-4')
188188
->call('enableDetailedPagination', 'standard')
189-
->assertSeeHtmlInOrder(['<div class="col-12 col-md-6 text-center text-md-right text-muted">',
189+
->assertSeeHtmlInOrder(['<div class="col-12 col-md-6 text-center text-muted text-md-right">',
190190
'<span>Showing</span>',
191191
'<strong>1</strong>',
192192
'<span>to</span>',
@@ -231,7 +231,7 @@ public function test_detailed_pagination_is_displayed_standard_bs5(): void
231231
Livewire::test(PetsTable::class)
232232
->call('setTheme', 'bootstrap-5')
233233
->call('enableDetailedPagination', 'standard')
234-
->assertSeeHtmlInOrder(['<div class="col-12 col-md-6 text-center text-md-end text-muted">',
234+
->assertSeeHtmlInOrder(['<div class="col-12 col-md-6 text-center text-muted text-md-end">',
235235
'<span>Showing</span>',
236236
'<strong>1</strong>',
237237
'<span>to</span>',
@@ -244,7 +244,7 @@ public function test_detailed_pagination_is_displayed_simple_bs5(): void
244244
Livewire::test(PetsTable::class)
245245
->call('setTheme', 'bootstrap-5')
246246
->call('enableDetailedPagination', 'simple')
247-
->assertSeeHtmlInOrder(['<div class="col-12 col-md-6 text-center text-md-end text-muted">',
247+
->assertSeeHtmlInOrder(['<div class="col-12 col-md-6 text-center text-muted text-md-end">',
248248
'<span>Showing</span>',
249249
'<strong>1</strong>',
250250
'<span>to</span>',

0 commit comments

Comments
 (0)