Skip to content

Commit 8d0047d

Browse files
committed
Adjust Tests & Methods
1 parent ceb3cdc commit 8d0047d

File tree

3 files changed

+31
-5
lines changed

3 files changed

+31
-5
lines changed

resources/views/components/pagination.blade.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
)
88

99
@if ($this->isTailwind)
10-
<div {{ $this->getPaginationWrapperAttributes }}>
10+
<div {{ $this->getPaginationWrapperAttributesBag() }}>
1111
@if ($this->paginationVisibilityIsEnabled())
1212
<div class="mt-4 px-4 md:p-0 sm:flex justify-between items-center space-y-4 sm:space-y-0">
1313
<div>
@@ -49,7 +49,7 @@
4949
@endif
5050
</div>
5151
@elseif ($this->isBootstrap4)
52-
<div {{ $this->getPaginationWrapperAttributes }}>
52+
<div {{ $this->getPaginationWrapperAttributesBag() }}>
5353
@if ($this->paginationVisibilityIsEnabled())
5454
@if ($this->paginationIsEnabled() && $this->isPaginationMethod('standard') && $this->getRows->lastPage() > 1)
5555
<div class="row mt-3">
@@ -102,7 +102,7 @@
102102
@endif
103103
</div>
104104
@elseif ($this->isBootstrap5)
105-
<div {{ $this->getPaginationWrapperAttributes }} >
105+
<div {{ $this->getPaginationWrapperAttributesBag() }} >
106106
@if ($this->paginationVisibilityIsEnabled())
107107
@if ($this->paginationIsEnabled() && $this->isPaginationMethod('standard') && $this->getRows->lastPage() > 1)
108108
<div class="row mt-3">

src/Traits/Helpers/PaginationHelpers.php

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
namespace Rappasoft\LaravelLivewireTables\Traits\Helpers;
44

55
use Livewire\Attributes\Computed;
6+
use Illuminate\View\ComponentAttributeBag;
67

78
trait PaginationHelpers
89
{
@@ -156,9 +157,15 @@ public function getShouldRetrieveTotalItemCount(): bool
156157
return $this->shouldRetrieveTotalItemCount;
157158
}
158159

159-
#[Computed]
160160
public function getPaginationWrapperAttributes(): array
161161
{
162-
return $this->paginationWrapperAttributes;
162+
return $this->paginationWrapperAttributes ?? ['class' => ''];
163+
}
164+
165+
166+
#[Computed]
167+
public function getPaginationWrapperAttributesBag(): ComponentAttributeBag
168+
{
169+
return new ComponentAttributeBag($this->getPaginationWrapperAttributes());
163170
}
164171
}

tests/Traits/Helpers/PaginationHelpersTest.php

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -182,5 +182,24 @@ public function test_can_get_pagination_wrapper_attributes(): void
182182
$this->basicTable->setPaginationWrapperAttributes(['class' => 'text-lg']);
183183

184184
$this->assertSame(['class' => 'text-lg'], $this->basicTable->getPaginationWrapperAttributes());
185+
186+
$this->basicTable->setPaginationWrapperAttributes(['class' => 'text-lg', 'testval' => '456']);
187+
188+
$this->assertSame(['class' => 'text-lg', 'testval' => '456'], $this->basicTable->getPaginationWrapperAttributes());
189+
190+
}
191+
192+
public function test_can_get_pagination_wrapper_attributes_bag(): void
193+
{
194+
$this->assertSame((new \Illuminate\View\ComponentAttributeBag(['class' => '']))->getAttributes(), $this->basicTable->getPaginationWrapperAttributesBag()->getAttributes());
195+
196+
$this->basicTable->setPaginationWrapperAttributes(['class' => 'text-lg']);
197+
198+
$this->assertSame((new \Illuminate\View\ComponentAttributeBag(['class' => 'text-lg']))->getAttributes(), $this->basicTable->getPaginationWrapperAttributesBag()->getAttributes());
199+
200+
$this->basicTable->setPaginationWrapperAttributes(['class' => 'text-lg', 'testval' => '123']);
201+
202+
$this->assertSame((new \Illuminate\View\ComponentAttributeBag(['class' => 'text-lg', 'testval' => '123']))->getAttributes(), $this->basicTable->getPaginationWrapperAttributesBag()->getAttributes());
203+
185204
}
186205
}

0 commit comments

Comments
 (0)