mirror of
https://github.com/symbiote/silverstripe-gridfieldextensions.git
synced 2024-10-22 17:05:39 +02:00
FIX When setting the page sizes, reset items per page to the first value
This commit is contained in:
parent
f80fc03bbb
commit
320a6198e5
@ -159,6 +159,10 @@ class GridFieldConfigurablePaginator extends GridFieldPaginator
|
||||
public function setPageSizes(array $pageSizes)
|
||||
{
|
||||
$this->pageSizes = $pageSizes;
|
||||
|
||||
// Reset items per page
|
||||
$this->setItemsPerPage(current($pageSizes));
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
@ -80,6 +80,20 @@ class GridFieldConfigurablePaginatorTest extends SapphireTest
|
||||
$this->assertSame(3, $paginator->getTotalPages());
|
||||
}
|
||||
|
||||
public function testItemsPerPageIsSetToFirstInPageSizesListWhenChanged()
|
||||
{
|
||||
$paginator = new GridFieldConfigurablePaginator(20, array(20, 40, 60));
|
||||
$paginator->setGridField($this->gridField);
|
||||
|
||||
// Initial state, should be what was provided to the constructor
|
||||
$this->assertSame(20, $paginator->getItemsPerPage());
|
||||
|
||||
$paginator->setPageSizes(array(50, 100, 200));
|
||||
|
||||
// Set via public API, should now be set to 50
|
||||
$this->assertSame(50, $paginator->getItemsPerPage());
|
||||
}
|
||||
|
||||
public function testGetCurrentPreviousAndNextPages()
|
||||
{
|
||||
$paginator = new GridFieldConfigurablePaginator(20, array(20, 40, 60));
|
||||
|
Loading…
Reference in New Issue
Block a user