Skip to content

Commit

Permalink
[FEATURE] Add button to select all records
Browse files Browse the repository at this point in the history
Add and handle button to select all records from all pages in recycler.
Right now, there is pagination, which means that you can select 50 records max.

Resolves: #81310
Releases: master
Change-Id: Icfc0c93e5cff5cd9573a6a39b615ce0c6e1d273c
Reviewed-on: https://review.typo3.org/54849
Tested-by: TYPO3com <no-reply@typo3.com>
Reviewed-by: Tobi Kretschmann <tobi@tobishome.de>
Tested-by: Tobi Kretschmann <tobi@tobishome.de>
Reviewed-by: Joerg Boesche <typo3@joergboesche.de>
Tested-by: Joerg Boesche <typo3@joergboesche.de>
Reviewed-by: Steffen Frese <steffenf14@gmail.com>
Reviewed-by: Jigal van Hemert <jigal.van.hemert@typo3.org>
Tested-by: Jigal van Hemert <jigal.van.hemert@typo3.org>
  • Loading branch information
Łukasz Uznański authored and Jigal van Hemert committed Mar 6, 2018
1 parent 861e6c0 commit 7ef3270
Show file tree
Hide file tree
Showing 7 changed files with 428 additions and 69 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
.. include:: ../../Includes.txt

==================================================================
Feature: #54849 - Add button to select all records in EXT:recycler
==================================================================

See :issue:`54849`

Description
===========

Add button to select all records from all pages in EXT:recycler.


Impact
======

All TYPO3 installations where EXT:recycler is enabled.

.. index:: Backend, ext:recycler
Original file line number Diff line number Diff line change
Expand Up @@ -50,12 +50,10 @@ public function __construct()
* Transforms the rows for the deleted records
*
* @param array $deletedRowsArray Array with table as key and array with all deleted rows
* @param int $totalDeleted Number of deleted records in total
* @return array JSON array
*/
public function transform($deletedRowsArray, $totalDeleted)
public function transform($deletedRowsArray)
{
$total = 0;
$jsonArray = [
'rows' => []
];
Expand All @@ -65,7 +63,6 @@ public function transform($deletedRowsArray, $totalDeleted)
$iconFactory = GeneralUtility::makeInstance(IconFactory::class);

foreach ($deletedRowsArray as $table => $rows) {
$total += count($deletedRowsArray[$table]);
foreach ($rows as $row) {
$pageTitle = $this->getPageTitle((int)$row['pid']);
$backendUserName = $this->getBackendUser((int)$row[$GLOBALS['TCA'][$table]['ctrl']['cruser_id']]);
Expand All @@ -92,7 +89,29 @@ public function transform($deletedRowsArray, $totalDeleted)
}
}
}
$jsonArray['total'] = $totalDeleted;
return $jsonArray;
}

/**
* Transforms the rows for the deleted records
*
* @param array $deletedRowsArray Array with table as key and array with all deleted rows
* @return array JSON array
*/
public function transformSmallAddTotal(array $deletedRowsArray): array
{
$jsonArray = [];
$total = 0;
if (is_array($deletedRowsArray)) {
foreach ($deletedRowsArray as $table => $rows) {
foreach ($rows as $row) {
$key = $table . ':' . $row['uid'];
$jsonArray['rows'][$key] = 1;
$total++;
}
}
}
$jsonArray['total'] = $total;
return $jsonArray;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public function __construct()
$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;
$this->conf['records'] = GeneralUtility::_GP('records') ? GeneralUtility::_GP('records') : null;
$this->conf['records'] = json_decode(GeneralUtility::_GP('records') ? GeneralUtility::_GP('records') : '[]', true);
$this->conf['recursive'] = GeneralUtility::_GP('recursive') ? (bool)GeneralUtility::_GP('recursive') : false;
}

Expand Down Expand Up @@ -94,11 +94,13 @@ public function dispatch(ServerRequestInterface $request): ResponseInterface
$deletedRowsArray = $model->getDeletedRows();

$model = GeneralUtility::makeInstance(DeletedRecords::class);
$totalDeleted = $model->getTotalCount($this->conf['startUid'], $this->conf['table'], $this->conf['depth'], $this->conf['filterTxt']);
$model->loadData($this->conf['startUid'], $this->conf['table'], $this->conf['depth'], null, $this->conf['filterTxt']);
$deletedRowsArrayAll = $model->getDeletedRows();

/* @var $controller DeletedRecordsController */
$controller = GeneralUtility::makeInstance(DeletedRecordsController::class);
$recordsArray = $controller->transform($deletedRowsArray, $totalDeleted);
$recordsArray = $controller->transform($deletedRowsArray);
$recordsArrayAll = $controller->transformSmallAddTotal($deletedRowsArrayAll);

$modTS = $this->getBackendUser()->getTSConfig('mod.recycler');
$allowDelete = $this->getBackendUser()->isAdmin() ? true : (bool)$modTS['properties']['allowDelete'];
Expand All @@ -109,7 +111,8 @@ public function dispatch(ServerRequestInterface $request): ResponseInterface
$view->assign('total', $recordsArray['total']);
$content = [
'rows' => $view->render(),
'totalItems' => $recordsArray['total']
'totalItems' => $recordsArrayAll['total'],
'allTheRows' => $recordsArrayAll['rows']
];
break;
case 'undoRecords':
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ class RecyclerModuleController extends ActionController
/**
* @var int
*/
protected $recordsPageLimit = 50;
protected $recordsPageLimit = 25;

/**
* @var int
Expand Down
12 changes: 12 additions & 0 deletions typo3/sysext/recycler/Resources/Private/Language/locallang.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,18 @@
<trans-unit id="button.delete">
<source>Delete</source>
</trans-unit>
<trans-unit id="button.selectall">
<source>Select all records from all pages</source>
</trans-unit>
<trans-unit id="button.deselectall">
<source>Deselect all</source>
</trans-unit>
<trans-unit id="button.selectallamount">
<source>Select all records ({0}) from all pages</source>
</trans-unit>
<trans-unit id="button.selectallamountrest">
<source>Select the rest of the records ({0}) from all pages</source>
</trans-unit>
<trans-unit id="button.deleteselected">
<source>Delete {0} records</source>
</trans-unit>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,21 +44,44 @@
</tbody>
</table>
</div>
<div class="progress progress-bar-notice alert-loading" style="display: none">
<div class="t3js-progressbar progress-bar progress-bar-striped active m-3"
role="progressbar" aria-valuenow="100" aria-valuemin="0" aria-valuemax="100"
style="width: 100%; height:25px; ">
<span class="sr-only">Loading...</span>
</div>
</div>
<div>
<button class="btn btn-default disabled" data-action="massundo">
<core:icon identifier="actions-edit-undo" />
<span class="text">
<f:translate key="button.undo" />
</span>
</button>
<f:if condition="{allowDelete}">
<button class="btn btn-default disabled" data-action="massdelete">
<core:icon identifier="actions-edit-delete" />

<div>
<button class="btn btn-default disabled" data-action="selectall">
<core:icon identifier="actions-document-select" />
<span class="text">
<f:translate key="LLL:EXT:recycler/Resources/Private/Language/locallang.xlf:button.selectall"/>
</span>
</button>
<button class="btn btn-default disabled" data-action="deselectall">
<span class="text">
<f:translate key="button.delete" />
<f:translate key="LLL:EXT:recycler/Resources/Private/Language/locallang.xlf:button.deselectall"/>
</span>
</button>
</f:if>
</div>
<div>
<button class="btn btn-default disabled" data-action="massundo">
<core:icon identifier="actions-edit-undo" />
<span class="text">
<f:translate key="button.undo" />
</span>
</button>
<f:if condition="{allowDelete}">
<button class="btn btn-default disabled" data-action="massdelete">
<core:icon identifier="actions-edit-delete" />
<span class="text">
<f:translate key="button.delete" />
</span>
</button>
</f:if>
</div>
</div>
<nav>
</nav>
Expand Down

0 comments on commit 7ef3270

Please sign in to comment.