Skip to content
Snippets Groups Projects
Commit 359ec63a authored by Ole Anders's avatar Ole Anders
Browse files

Enable sorting in backend module

parent 69942838
No related branches found
No related tags found
No related merge requests found
......@@ -105,6 +105,7 @@ class BackendController extends ActionController {
public function indexAction(array $filters = []) {
try {
$pageUid = (int) GeneralUtility::_GP('id');
$sortingData = [];
// create docheader + buttons
$pageInfo = BackendUtility::readPageAccess($pageUid, $GLOBALS['BE_USER']->getPagePermsClause(1));
......@@ -125,6 +126,23 @@ class BackendController extends ActionController {
$this->view->assign('pages', BackendService::getPagesWithJobRecords());
$this->view->assign('pageUid', $pageUid);
if (count($filters) === 0) {
$prevUid = 0;
$prevPrevUid = 0;
$sortingData = [];
foreach ($jobs as $job) {
if ($prevUid) {
$sortingData['prev'][$job->getUid()] = $prevPrevUid;
$sortingData['next'][$prevUid] = '-' . $job->getUid();
$sortingData['prevUid'][$job->getUid()] = $prevUid;
}
$prevPrevUid = isset($sortingData['prev'][$job->getUid()]) ? -$prevUid : $job->getPid();
$prevUid = $job->getUid();
}
}
$this->view->assign('sortingData', $sortingData);
// get all Locations
/** @noinspection PhpUndefinedMethodInspection */
/** @var QueryResultInterface $companies */
......
......@@ -45,6 +45,7 @@ class ControlViewHelper extends AbstractViewHelper {
parent::initializeArguments();
$this->registerArgument('table', 'string', 'The table to control', TRUE);
$this->registerArgument('row', 'mixed', 'The row of the record', TRUE);
$this->registerArgument('sortingData', 'array', 'The sorting data', FALSE, []);
}
/**
......@@ -57,6 +58,8 @@ class ControlViewHelper extends AbstractViewHelper {
public function render(): string {
$row = $this->arguments['row'];
$table = $this->arguments['table'];
$sortingData = $this->arguments['sortingData'];
/** @var DatabaseRecordList $databaseRecordList */
$databaseRecordList = GeneralUtility::makeInstance(DatabaseRecordList::class);
......@@ -76,6 +79,7 @@ class ControlViewHelper extends AbstractViewHelper {
$languageService->includeLLFile('EXT:backend/Resources/Private/Language/locallang_alt_doc.xlf');
$databaseRecordList->calcPerms = $GLOBALS['BE_USER']->calcPerms($pageInfo);
$databaseRecordList->currentTable = $sortingData;
return $databaseRecordList->makeControl($table, $row);
}
......
......@@ -23,7 +23,7 @@
</td>
<td nowrap="nowrap" class="col-control">
<f:format.raw>
<sg:backend.control table="tx_sgjobs_domain_model_job" row="{job}" />
<sg:backend.control table="tx_sgjobs_domain_model_job" row="{job}" sortingData="{sortingData}"/>
</f:format.raw>
</td>
</tr>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment