mirror of
https://github.com/Icinga/icingaweb2.git
synced 2025-07-26 07:14:35 +02:00
Limiter: Do not use a hardcoded default limit
This commit is contained in:
parent
9a043386de
commit
99c511eefd
@ -84,12 +84,15 @@ class Controller extends ModuleActionController
|
|||||||
*
|
*
|
||||||
* In case the current view has been requested as compact this method does nothing.
|
* In case the current view has been requested as compact this method does nothing.
|
||||||
*
|
*
|
||||||
|
* @param int $itemsPerPage Default number of items per page
|
||||||
|
*
|
||||||
* @return $this
|
* @return $this
|
||||||
*/
|
*/
|
||||||
protected function setupLimitControl()
|
protected function setupLimitControl($itemsPerPage = 25)
|
||||||
{
|
{
|
||||||
if (! $this->view->compact) {
|
if (! $this->view->compact) {
|
||||||
$this->view->limiter = new Limiter();
|
$this->view->limiter = new Limiter();
|
||||||
|
$this->view->limiter->setDefaultLimit($itemsPerPage);
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
@ -102,8 +105,8 @@ class Controller extends ModuleActionController
|
|||||||
* The paginator is set on the `paginator' view property only if the current view has not been requested as compact.
|
* The paginator is set on the `paginator' view property only if the current view has not been requested as compact.
|
||||||
*
|
*
|
||||||
* @param QueryInterface $query The query to create a paginator for
|
* @param QueryInterface $query The query to create a paginator for
|
||||||
* @param int $itemsPerPage Number of items per page
|
* @param int $itemsPerPage Default number of items per page
|
||||||
* @param int $pageNumber Current page number
|
* @param int $pageNumber Default page number
|
||||||
*
|
*
|
||||||
* @return $this
|
* @return $this
|
||||||
*/
|
*/
|
||||||
|
@ -21,6 +21,8 @@ class Limiter extends AbstractWidget
|
|||||||
|
|
||||||
private $pages;
|
private $pages;
|
||||||
|
|
||||||
|
private $default;
|
||||||
|
|
||||||
public function setUrl(Url $url)
|
public function setUrl(Url $url)
|
||||||
{
|
{
|
||||||
$this->url = $url;
|
$this->url = $url;
|
||||||
@ -39,13 +41,19 @@ class Limiter extends AbstractWidget
|
|||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function setDefaultLimit($limit)
|
||||||
|
{
|
||||||
|
$this->default = $limit;
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
public function render()
|
public function render()
|
||||||
{
|
{
|
||||||
if ($this->url === null) {
|
if ($this->url === null) {
|
||||||
$this->url = Url::fromRequest();
|
$this->url = Url::fromRequest();
|
||||||
}
|
}
|
||||||
|
|
||||||
$currentLimit = (int) $this->url->getParam('limit', 25); // Default??
|
$currentLimit = (int) $this->url->getParam('limit', $this->default);
|
||||||
$availableLimits = array(
|
$availableLimits = array(
|
||||||
10 => '10',
|
10 => '10',
|
||||||
25 => '25',
|
25 => '25',
|
||||||
|
Loading…
x
Reference in New Issue
Block a user