From c81bb3b4d3c9fea93cd239a7afcbff5837566154 Mon Sep 17 00:00:00 2001 From: Andrew O'Neil Date: Wed, 7 Mar 2012 14:45:22 +1300 Subject: [PATCH] MINOR: Change -10/+10 buttons to First and Last --- forms/gridfield/GridFieldPaginator.php | 20 +++++++++----------- templates/Includes/GridFieldPaginator_Row.ss | 2 +- 2 files changed, 10 insertions(+), 12 deletions(-) diff --git a/forms/gridfield/GridFieldPaginator.php b/forms/gridfield/GridFieldPaginator.php index 267cc8487..115823b2f 100755 --- a/forms/gridfield/GridFieldPaginator.php +++ b/forms/gridfield/GridFieldPaginator.php @@ -93,12 +93,11 @@ class GridFieldPaginator implements GridField_HTMLProvider, GridField_DataManipu $lastShownRecord = $totalRows; - // Ten pages back button - $prev10PageNum = $this->currentPage - 10 <= 1 ? 1 : $this->currentPage - 10; - $prev10Page = new GridField_Action($gridField, 'pagination_prev10', '-10', 'paginate', 1); - $prev10Page->addExtraClass('ss-gridfield-prev10page'); + // First page button + $firstPage = new GridField_Action($gridField, 'pagination_first', 'First', 'paginate', 1); + $firstPage->addExtraClass('ss-gridfield-firstpage'); if($this->currentPage == 1) - $prev10Page = $prev10Page->performDisabledTransformation(); + $firstPage = $firstPage->performDisabledTransformation(); // Previous page button $previousPageNum = $this->currentPage <= 1 ? 1 : $this->currentPage - 1; @@ -115,21 +114,20 @@ class GridFieldPaginator implements GridField_HTMLProvider, GridField_DataManipu $nextPage = $nextPage->performDisabledTransformation(); // Ten pages forward button - $next10PageNum = $this->currentPage + 10 >= $totalPages ? $totalPages : $this->currentPage + 10; - $next10Page = new GridField_Action($gridField, 'pagination_next10', '+10', 'paginate', $next10PageNum); - $next10Page->addExtraClass('ss-gridfield-next10page'); + $lastPage = new GridField_Action($gridField, 'pagination_last', 'Last', 'paginate', $totalPages); + $lastPage->addExtraClass('ss-gridfield-lastpage'); if($this->currentPage == $totalPages) - $next10Page = $next10Page->performDisabledTransformation(); + $lastPage = $lastPage->performDisabledTransformation(); // Render in template $forTemplate = new ArrayData(array( - 'Previous10Page' => $prev10Page, + 'FirstPage' => $firstPage, 'PreviousPage' => $previousPage, 'CurrentPageNum' => $this->currentPage, 'NumPages' => $totalPages, 'NextPage' => $nextPage, - 'Next10Page' => $next10Page, + 'LastPage' => $lastPage, 'FirstShownRecord' => $firstShownRecord, 'LastShownRecord' => $lastShownRecord, 'NumRecords' => $totalRows diff --git a/templates/Includes/GridFieldPaginator_Row.ss b/templates/Includes/GridFieldPaginator_Row.ss index 5fc35552b..6d280e93c 100644 --- a/templates/Includes/GridFieldPaginator_Row.ss +++ b/templates/Includes/GridFieldPaginator_Row.ss @@ -1,7 +1,7 @@
- $Previous10Page $PreviousPage Page $CurrentPageNum of $NumPages $NextPage $Next10Page + $FirstPage $PreviousPage Page $CurrentPageNum of $NumPages $NextPage $LastPage
View $FirstShownRecord - $LastShownRecord of $NumRecords