Skip to content

Commit

Permalink
Add initial commit for setPaginationWrapperAttributes
Browse files Browse the repository at this point in the history
  • Loading branch information
lrljoe authored Sep 29, 2024
1 parent fd13aa9 commit 31cb65c
Show file tree
Hide file tree
Showing 6 changed files with 52 additions and 9 deletions.
11 changes: 11 additions & 0 deletions docs/pagination/available-methods.md
Original file line number Diff line number Diff line change
Expand Up @@ -296,3 +296,14 @@ public function configure(): void
$this->setShouldRetrieveTotalItemCountDisabled();
}
```

## setPaginationWrapperAttributes

Used to set attributes for the "div" that wraps the pagination section

```php
public function configure(): void
{
$this->setPaginationWrapperAttributes(['class' => 'text-lg']);
}
```
22 changes: 13 additions & 9 deletions resources/views/components/pagination.blade.php
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
@aware(['component','isTailwind','isBootstrap','isBootstrap4','isBootstrap5'])

@if ($this->hasConfigurableAreaFor('before-pagination'))
@include($this->getConfigurableAreaFor('before-pagination'), $this->getParametersForConfigurableArea('before-pagination'))
@endif
@includeWhen(
$this->hasConfigurableAreaFor('before-pagination'),
$this->getConfigurableAreaFor('before-pagination'),
$this->getParametersForConfigurableArea('before-pagination')
)

@if ($this->isTailwind)
<div>
<div {{ $this->getPaginationWrapperAttributes }}>
@if ($this->paginationVisibilityIsEnabled())
<div class="mt-4 px-4 md:p-0 sm:flex justify-between items-center space-y-4 sm:space-y-0">
<div>
Expand Down Expand Up @@ -47,7 +49,7 @@
@endif
</div>
@elseif ($this->isBootstrap4)
<div >
<div {{ $this->getPaginationWrapperAttributes }}>
@if ($this->paginationVisibilityIsEnabled())
@if ($this->paginationIsEnabled() && $this->isPaginationMethod('standard') && $this->getRows->lastPage() > 1)
<div class="row mt-3">
Expand Down Expand Up @@ -100,7 +102,7 @@
@endif
</div>
@elseif ($this->isBootstrap5)
<div >
<div {{ $this->getPaginationWrapperAttributes }} >
@if ($this->paginationVisibilityIsEnabled())
@if ($this->paginationIsEnabled() && $this->isPaginationMethod('standard') && $this->getRows->lastPage() > 1)
<div class="row mt-3">
Expand Down Expand Up @@ -152,6 +154,8 @@
</div>
@endif

@if ($this->hasConfigurableAreaFor('after-pagination'))
@include($this->getConfigurableAreaFor('after-pagination'), $this->getParametersForConfigurableArea('after-pagination'))
@endif
@includeWhen(
$this->hasConfigurableAreaFor('after-pagination'),
$this->getConfigurableAreaFor('after-pagination'),
$this->getParametersForConfigurableArea('after-pagination')
)
8 changes: 8 additions & 0 deletions src/Traits/Configuration/PaginationConfiguration.php
Original file line number Diff line number Diff line change
Expand Up @@ -177,4 +177,12 @@ public function setShouldRetrieveTotalItemCountDisabled(): self

return $this;
}

public function setPaginationWrapperAttributes(array $paginationWrapperAttributes): self
{
$this->paginationWrapperAttributes = array_merge(['class' => ''], $paginationWrapperAttributes);

return $this;
}

}
6 changes: 6 additions & 0 deletions src/Traits/Helpers/PaginationHelpers.php
Original file line number Diff line number Diff line change
Expand Up @@ -155,4 +155,10 @@ public function getShouldRetrieveTotalItemCount(): bool
{
return $this->shouldRetrieveTotalItemCount;
}

#[Computed]
public function getPaginationWrapperAttributes(): array
{
return $this->paginationWrapperAttributes;
}
}
4 changes: 4 additions & 0 deletions src/Traits/WithPagination.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,10 @@ trait WithPagination

protected bool $shouldRetrieveTotalItemCount = true;

// Used In Frontend
protected array $paginationWrapperAttributes = ['class' => ''];


public function mountWithPagination(): void
{
$sessionPerPage = session()->get($this->getPerPagePaginationSessionKey(), $this->getPerPageAccepted()[0] ?? 10);
Expand Down
10 changes: 10 additions & 0 deletions tests/Traits/Helpers/PaginationHelpersTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -173,4 +173,14 @@ public function test_can_toggle_total_item_count_retrieval_via_status(): void
$this->assertTrue($this->basicTable->getShouldRetrieveTotalItemCount());

}

public function test_can_get_pagination_wrapper_attributes(): void
{

$this->assertSame(['class' => ''], $this->basicTable->getPaginationWrapperAttributes());

$this->basicTable->setPaginationWrapperAttributes(['class' => 'text-lg']);

$this->assertSame(['class' => 'text-lg'], $this->basicTable->getPaginationWrapperAttributes());
}
}

0 comments on commit 31cb65c

Please sign in to comment.