mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
NEW Add FirstPage() and LastPage() to PaginatedList (#10129)
This commit is contained in:
parent
e217a3d9cb
commit
20134e6a4f
@ -394,12 +394,28 @@ class PaginatedList extends ListDecorator
|
|||||||
return $this->TotalPages() > 1;
|
return $this->TotalPages() > 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
public function FirstPage()
|
||||||
|
{
|
||||||
|
return $this->CurrentPage() == 1;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
public function NotFirstPage()
|
public function NotFirstPage()
|
||||||
{
|
{
|
||||||
return $this->CurrentPage() != 1;
|
return !$this->FirstPage();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
public function LastPage()
|
||||||
|
{
|
||||||
|
return $this->CurrentPage() == $this->TotalPages();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -407,7 +423,7 @@ class PaginatedList extends ListDecorator
|
|||||||
*/
|
*/
|
||||||
public function NotLastPage()
|
public function NotLastPage()
|
||||||
{
|
{
|
||||||
return $this->CurrentPage() < $this->TotalPages();
|
return !$this->LastPage();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -282,6 +282,14 @@ class PaginatedListTest extends SapphireTest
|
|||||||
$this->assertFalse($list->MoreThanOnePage());
|
$this->assertFalse($list->MoreThanOnePage());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function testFirstPage()
|
||||||
|
{
|
||||||
|
$list = new PaginatedList(new ArrayList());
|
||||||
|
$this->assertTrue($list->FirstPage());
|
||||||
|
$list->setCurrentPage(2);
|
||||||
|
$this->assertFalse($list->FirstPage());
|
||||||
|
}
|
||||||
|
|
||||||
public function testNotFirstPage()
|
public function testNotFirstPage()
|
||||||
{
|
{
|
||||||
$list = new PaginatedList(new ArrayList());
|
$list = new PaginatedList(new ArrayList());
|
||||||
@ -290,6 +298,16 @@ class PaginatedListTest extends SapphireTest
|
|||||||
$this->assertTrue($list->NotFirstPage());
|
$this->assertTrue($list->NotFirstPage());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function testLastPage()
|
||||||
|
{
|
||||||
|
$list = new PaginatedList(new ArrayList());
|
||||||
|
$list->setTotalItems(50);
|
||||||
|
|
||||||
|
$this->assertFalse($list->LastPage());
|
||||||
|
$list->setCurrentPage(5);
|
||||||
|
$this->assertTrue($list->LastPage());
|
||||||
|
}
|
||||||
|
|
||||||
public function testNotLastPage()
|
public function testNotLastPage()
|
||||||
{
|
{
|
||||||
$list = new PaginatedList(new ArrayList());
|
$list = new PaginatedList(new ArrayList());
|
||||||
|
Loading…
Reference in New Issue
Block a user