diff --git a/modules/backend/behaviors/ListController.php b/modules/backend/behaviors/ListController.php index 9882bb7ad..66e56440f 100644 --- a/modules/backend/behaviors/ListController.php +++ b/modules/backend/behaviors/ListController.php @@ -141,6 +141,7 @@ class ListController extends ControllerBehavior 'recordUrl', 'recordOnClick', 'recordsPerPage', + 'showPageNumbers', 'noRecordsMessage', 'defaultSort', 'showSorting', @@ -456,7 +457,7 @@ class ListController extends ControllerBehavior public function listExtendColumns($host) { } - + /** * Called after the filter scopes are defined. * @param \Backend\Widgets\Filter $host The hosting filter widget @@ -559,7 +560,7 @@ class ListController extends ControllerBehavior call_user_func_array($callback, [$widget, $widget->model]); }); } - + /** * Static helper for extending filter scopes. * @param callable $callback diff --git a/modules/backend/widgets/Lists.php b/modules/backend/widgets/Lists.php index df8fc5feb..f8a9db001 100644 --- a/modules/backend/widgets/Lists.php +++ b/modules/backend/widgets/Lists.php @@ -96,6 +96,11 @@ class Lists extends WidgetBase */ public $showPagination = 'auto'; + /** + * @var bool Display page numbers when pagination is enabled + */ + public $showPageNumbers = true; + /** * @var string Specify a custom view path to override partials used by the list. */ @@ -190,6 +195,7 @@ class Lists extends WidgetBase 'recordUrl', 'recordOnClick', 'noRecordsMessage', + 'showPageNumbers', 'recordsPerPage', 'showSorting', 'defaultSort', @@ -248,6 +254,7 @@ class Lists extends WidgetBase $this->vars['showCheckboxes'] = $this->showCheckboxes; $this->vars['showSetup'] = $this->showSetup; $this->vars['showPagination'] = $this->showPagination; + $this->vars['showPageNumbers'] = $this->showPageNumbers; $this->vars['showSorting'] = $this->showSorting; $this->vars['sortColumn'] = $this->getSortColumn(); $this->vars['sortDirection'] = $this->sortDirection; @@ -255,11 +262,15 @@ class Lists extends WidgetBase $this->vars['treeLevel'] = 0; if ($this->showPagination) { - $this->vars['recordTotal'] = $this->records->total(); $this->vars['pageCurrent'] = $this->records->currentPage(); - $this->vars['pageLast'] = $this->records->lastPage(); - $this->vars['pageFrom'] = $this->records->firstItem(); - $this->vars['pageTo'] = $this->records->lastItem(); + if ($this->showPageNumbers) { + $this->vars['recordTotal'] = $this->records->total(); + $this->vars['pageLast'] = $this->records->lastPage(); + $this->vars['pageFrom'] = $this->records->firstItem(); + $this->vars['pageTo'] = $this->records->lastItem(); + } else { + $this->vars['hasMorePages'] = $this->records->hasMorePages(); + } } else { $this->vars['recordTotal'] = $this->records->count(); @@ -518,7 +529,10 @@ class Lists extends WidgetBase $records = $model->getNested(); } elseif ($this->showPagination) { - $records = $model->paginate($this->recordsPerPage, $this->currentPageNumber); + $paginationMethod = $this->showPageNumbers + ? 'paginate' + : 'simplePaginate'; + $records = $model->{$paginationMethod}($this->recordsPerPage, $this->currentPageNumber); } else { $records = $model->get(); diff --git a/modules/backend/widgets/lists/partials/_list.htm b/modules/backend/widgets/lists/partials/_list.htm index 79d6f81e7..f651a238b 100644 --- a/modules/backend/widgets/lists/partials/_list.htm +++ b/modules/backend/widgets/lists/partials/_list.htm @@ -18,7 +18,11 @@
diff --git a/modules/backend/widgets/lists/partials/_list_pagination_simple.htm b/modules/backend/widgets/lists/partials/_list_pagination_simple.htm new file mode 100644 index 000000000..3ace68ab3 --- /dev/null +++ b/modules/backend/widgets/lists/partials/_list_pagination_simple.htm @@ -0,0 +1,49 @@ +