[BUGFIX] Pagination in recycler is broken 50/36450/5
authorAndreas Fernandez <a.fernandez@scripting-base.de>
Fri, 30 Jan 2015 16:24:43 +0000 (17:24 +0100)
committerChristian Kuhn <lolli@schwarzbu.ch>
Fri, 30 Jan 2015 16:54:29 +0000 (17:54 +0100)
Due to the use of a wrong _GP variable, the recycler can only load the
first two pages. Also, reset the paginator upon table change.

Resolves: #64652
Releases: master
Change-Id: I0519b5fd721e46f07e9b9e0003d812317d88660e
Reviewed-on: http://review.typo3.org/36450
Reviewed-by: Mathias Schreiber <mathias.schreiber@wmdb.de>
Tested-by: Mathias Schreiber <mathias.schreiber@wmdb.de>
Reviewed-by: Christian Kuhn <lolli@schwarzbu.ch>
Tested-by: Christian Kuhn <lolli@schwarzbu.ch>
typo3/sysext/recycler/Classes/Controller/RecyclerAjaxController.php
typo3/sysext/recycler/Classes/Domain/Model/Tables.php
typo3/sysext/recycler/Resources/Public/JavaScript/Recycler.js

index 16e65ca..7a27973 100644 (file)
@@ -46,7 +46,7 @@ class RecyclerAjaxController {
                $this->conf['action'] = GeneralUtility::_GP('action');
                $this->conf['table'] = GeneralUtility::_GP('table') ? GeneralUtility::_GP('table') : '';
                $this->conf['limit'] = GeneralUtility::_GP('limit') ? (int)GeneralUtility::_GP('limit') : 25;
-               $this->conf['start'] = GeneralUtility::_GP('start') ? (int)GeneralUtility::_GP('limit') : 0;
+               $this->conf['start'] = GeneralUtility::_GP('start') ? (int)GeneralUtility::_GP('start') : 0;
                $this->conf['filterTxt'] = GeneralUtility::_GP('filterTxt') ? GeneralUtility::_GP('filterTxt') : '';
                $this->conf['startUid'] = GeneralUtility::_GP('startUid') ? (int)GeneralUtility::_GP('startUid') : 0;
                $this->conf['depth'] = GeneralUtility::_GP('depth') ? (int)GeneralUtility::_GP('depth') : 0;
@@ -101,17 +101,17 @@ class RecyclerAjaxController {
                                $view->assign('records', $recordsArray['rows']);
                                $view->assign('allowDelete', $allowDelete);
                                $view->assign('total', $recordsArray['total']);
-                               $content = json_encode(array(
+                               $content = array(
                                        'rows' => $view->render(),
                                        'totalItems' => $recordsArray['total']
-                               ));
+                               );
                                break;
                        case 'undoRecords':
                                if (empty($this->conf['records']) || !is_array($this->conf['records'])) {
-                                       $content = json_encode(array(
+                                       $content = array(
                                                'success' => FALSE,
                                                'message' => LocalizationUtility::translate('flashmessage.delete.norecordsselected', 'recycler')
-                                       ));
+                                       );
                                        break;
                                }
 
@@ -120,17 +120,17 @@ class RecyclerAjaxController {
                                $success = $model->undeleteData($this->conf['records'], $this->conf['recursive']);
                                $affectedRecords = count($this->conf['records']);
                                $messageKey = 'flashmessage.undo.' . ($success ? 'success' : 'failure') . '.' . ($affectedRecords === 1 ? 'singular' : 'plural');
-                               $content = json_encode(array(
+                               $content = array(
                                        'success' => TRUE,
                                        'message' => sprintf(LocalizationUtility::translate($messageKey, 'recycler'), $affectedRecords)
-                               ));
+                               );
                                break;
                        case 'deleteRecords':
                                if (empty($this->conf['records']) || !is_array($this->conf['records'])) {
-                                       $content = json_encode(array(
+                                       $content = array(
                                                'success' => FALSE,
                                                'message' => LocalizationUtility::translate('flashmessage.delete.norecordsselected', 'recycler')
-                                       ));
+                                       );
                                        break;
                                }
 
@@ -139,13 +139,14 @@ class RecyclerAjaxController {
                                $success = $model->deleteData($this->conf['records']);
                                $affectedRecords = count($this->conf['records']);
                                $messageKey = 'flashmessage.delete.' . ($success ? 'success' : 'failure') . '.' . ($affectedRecords === 1 ? 'singular' : 'plural');
-                               $content = json_encode(array(
+                               $content = array(
                                        'success' => TRUE,
                                        'message' => sprintf(LocalizationUtility::translate($messageKey, 'recycler'), $affectedRecords)
-                               ));
+                               );
                                break;
                }
-               $ajaxObj->addContent($this->conf['table'] . '_' . $this->conf['start'], $content);
+               $ajaxObj->setContentFormat('json');
+               $ajaxObj->setContent($content);
        }
 
        /**
index 827d9a1..108a6d9 100644 (file)
@@ -62,8 +62,7 @@ class Tables {
                        $deletedRecordsTotal,
                        $lang->sL('LLL:EXT:recycler/mod1/locallang.xlf:label_alltables')
                ));
-               $output = json_encode($jsonArray);
-               return $output;
+               return $jsonArray;
        }
 
        /**
index ee97b44..c2fb560 100644 (file)
@@ -89,6 +89,7 @@ define(['jquery', 'nprogress'], function($, NProgress) {
 
                // changing "table"
                Recycler.elements.$tableSelector.on('change', function() {
+                       Recycler.paging.currentPage = 1;
                        Recycler.loadDeletedElements();
                });
 
@@ -480,6 +481,7 @@ define(['jquery', 'nprogress'], function($, NProgress) {
 
                if (Recycler.paging.totalPages === 1) {
                        // early abort if only one page is available
+                       Recycler.elements.$paginator.contents().remove();
                        return;
                }
 
@@ -515,7 +517,7 @@ define(['jquery', 'nprogress'], function($, NProgress) {
                }
 
                $ul.append($controlFirstPage, liElements, $controlLastPage);
-               Recycler.elements.$paginator.contents().replaceWith($ul);
+               Recycler.elements.$paginator.html($ul);
        };
 
        /**