Skip to content
Snippets Groups Projects

[FEATURE] save filters in session

Merged Kevin von Spiczak requested to merge feature_3338-saveFiltersInSession into master
44 files
+ 1669
1012
Compare changes
  • Side-by-side
  • Inline
Files
44
@@ -87,76 +87,70 @@ class BackendController extends ActionController {
@@ -87,76 +87,70 @@ class BackendController extends ActionController {
* @return void
* @return void
*/
*/
public function indexAction(array $filters = []): void {
public function indexAction(array $filters = []): void {
try {
$pageUid = (int) GeneralUtility::_GP('id');
$pageUid = (int) GeneralUtility::_GP('id');
/** @var BackendUserAuthentication $backendUser */
/** @var BackendUserAuthentication $backendUser */
$backendUser = $GLOBALS['BE_USER'];
$backendUser = $GLOBALS['BE_USER'];
if ($filters === []) {
if ($filters === []) {
$filters = $backendUser->getModuleData('tools_beuser/index.php/web_SgJobsBackend_filters', 'ses') ?: [];
$filters = $backendUser->getModuleData('tools_beuser/index.php/web_SgJobsBackend_filters', 'ses') ?: [];
} else {
} else {
$backendUser->pushModuleData('tools_beuser/index.php/web_SgJobsBackend_filters', $filters);
$backendUser->pushModuleData('tools_beuser/index.php/web_SgJobsBackend_filters', $filters);
}
}
// create docheader + buttons
$pageInfo = BackendUtility::readPageAccess($pageUid, $GLOBALS['BE_USER']->getPagePermsClause(1));
// create docheader + buttons
if ($pageInfo === FALSE) {
$pageInfo = BackendUtility::readPageAccess($pageUid, $GLOBALS['BE_USER']->getPagePermsClause(1));
$pageInfo = ['uid' => $pageUid];
if ($pageInfo === FALSE) {
}
$pageInfo = ['uid' => $pageUid];
}
$this->docHeaderComponent = GeneralUtility::makeInstance(DocHeaderComponent::class);
$this->docHeaderComponent->setMetaInformation($pageInfo);
$this->docHeaderComponent = GeneralUtility::makeInstance(DocHeaderComponent::class);
BackendService::makeButtons($this->docHeaderComponent, $this->request);
$this->docHeaderComponent->setMetaInformation($pageInfo);
$this->view->assign('docHeader', $this->docHeaderComponent->docHeaderContent());
BackendService::makeButtons($this->docHeaderComponent, $this->request);
// get all jobs
$this->view->assign('docHeader', $this->docHeaderComponent->docHeaderContent());
/** @var ObjectStorage $jobs */
$jobs = $this->jobRepository->findBackendJobs($pageUid, $filters);
$this->view->assign('pageUid', $pageUid);
$this->view->assign('pages', BackendService::getPagesWithJobRecords());
$totalJobCount = \count($jobs);
$sortingData = [];
$this->view->assign('pages', BackendService::getPagesWithJobRecords());
if ($GLOBALS['TYPO3_CONF_VARS']['EXTENSIONS']['sg_jobs']['allowManualSorting'] && count($filters) <= 0) {
$this->view->assign('pageUid', $pageUid);
/**
* Somehow the pId is changed so data gets lost.
$sortingData = [];
*
if ($GLOBALS['TYPO3_CONF_VARS']['EXTENSIONS']['sg_jobs']['allowManualSorting'] && count($filters) <= 0) {
*
* $previousUid = 0;
/**
* $sortingData = [];
*
* foreach ($jobs as $job) {
* Somehow the pId is changed so data gets lost.
* if ($previousUid) {
*
* $sortingData['prev'][$job->getUid()] = $previousUid;
*
* $sortingData['next'][$previousUid] = $job->getUid();
* $previousUid = 0;
* }
* $sortingData = [];
* $previousUid = $job->getUid();
* foreach ($jobs as $job) {
* }
* if ($previousUid) {
*/
* $sortingData['prev'][$job->getUid()] = $previousUid;
$this->view->assign('manualSortingDestroysEverything', TRUE);
* $sortingData['next'][$previousUid] = $job->getUid();
}
* }
$this->view->assign('sortingData', $sortingData);
* $previousUid = $job->getUid();
* }
/** @var ObjectStorage $jobs */
*/
$jobs = $this->jobRepository->findBackendJobs($pageUid, $filters);
$this->view->assign('manualSortingDestroysEverything', TRUE);
$totalJobCount = \count($jobs);
}
// get all Locations
$this->view->assign('sortingData', $sortingData);
/** @noinspection PhpUndefinedMethodInspection */
/** @var QueryResultInterface $companies */
// get all Locations
$companies = $this->companyRepository->findByPid($pageUid);
/** @noinspection PhpUndefinedMethodInspection */
$this->view->assign('locationOptions', $companies);
/** @var QueryResultInterface $companies */
$companies = $this->companyRepository->findByPid($pageUid);
$this->view->assign('isAdmin', $GLOBALS['BE_USER']->isAdmin());
$this->view->assign('locationOptions', $companies);
$this->view->assign('filters', $filters);
if ($totalJobCount || $companies->count()) {
$this->view->assign('jobs', $jobs);
$this->view->assign('jobs', $jobs);
if (!$totalJobCount && $pageUid) {
$this->view->assign('filters', $filters);
// clear previously set filters again,
} else {
// without this, the user would be stuck without filters and just the flash message
$this->view->assign('noRecords', 1);
$backendUser->pushModuleData('tools_beuser/index.php/web_SgJobsBackend_filters', []);
$this->view->assign('isAdmin', $GLOBALS['BE_USER']->isAdmin());
$this->addFlashMessage(
$this->addFlashMessage(
LocalizationUtility::translate('backend.notice.noRecords', 'SgJobs'), '', FlashMessage::INFO
LocalizationUtility::translate('backend.notice.noRecords', 'SgJobs'), '', FlashMessage::INFO
);
);
}
} catch (\Exception $exception) {
// check for NULL value in view and render an error message
$this->view->assign('docHeader', NULL);
}
}
}
}
}
}
Loading