Skip to content
Snippets Groups Projects
Commit 6ee3e5b8 authored by Sergiu-Lucian Petrica's avatar Sergiu-Lucian Petrica
Browse files

Made joblist filtering work again

parent 864656c0
No related branches found
No related tags found
No related merge requests found
......@@ -31,6 +31,7 @@ use SGalinski\SgJobs\Service\BackendService;
use SGalinski\SgJobs\Service\FrontendFilterService;
use TYPO3\CMS\Core\Resource\ResourceFactory;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Extbase\Configuration\ConfigurationManagerInterface;
/**
* Ajax Controller
......@@ -50,7 +51,7 @@ class JoblistController extends AbstractAjaxController {
* @throws \InvalidArgumentException
*/
public function filterAction() {
$siteRootId = BackendService::getRootUidByPageUid($GLOBALS['TSFE']->id);
$recordPageId = $_POST['recordPageId'];
$filters = [
'country' => $_POST['parameters']['country'],
......@@ -61,14 +62,14 @@ class JoblistController extends AbstractAjaxController {
];
// get all correct filter options, based on the selection
$this->view->assign('cities', FrontendFilterService::getLocations($filters, $siteRootId));
$this->view->assign('companies', FrontendFilterService::getCompanies($filters, $siteRootId));
$this->view->assign('areas', FrontendFilterService::getAreas($filters, $siteRootId));
$this->view->assign('functions', FrontendFilterService::getFunctions($filters, $siteRootId));
$this->view->assign('countries', $this->companyRepository->getAllCountries($siteRootId));
$this->view->assign('cities', FrontendFilterService::getLocations($filters, $recordPageId));
$this->view->assign('companies', FrontendFilterService::getCompanies($filters, $recordPageId));
$this->view->assign('areas', FrontendFilterService::getAreas($filters, $recordPageId));
$this->view->assign('functions', FrontendFilterService::getFunctions($filters, $recordPageId));
$this->view->assign('countries', $this->companyRepository->getAllCountries($recordPageId));
// set all filtered jobs
$this->view->assign('jobs', FrontendFilterService::getJobs($filters, $siteRootId));
$this->view->assign('jobs', FrontendFilterService::getJobs($filters, $recordPageId));
// set default selected values
$this->view->assign('selectedCountry', $filters['country']);
......
......@@ -65,6 +65,7 @@ class JoblistController extends ActionController {
)['persistence']['storagePid'];
$this->assignFilterValues($recordPageId);
$this->view->assign('recordPageId', $recordPageId);
// get all jobs for the next root page
$jobs = $this->jobRepository->findJobs($recordPageId);
......
......@@ -40,11 +40,11 @@ class FrontendFilterService {
* Get all the locations based on the given filters
*
* @param array $filters
* @param int $siteRootId
* @param int $recordPageId
* @return array
* @throws \InvalidArgumentException
*/
public static function getLocations(array $filters = [], $siteRootId): array {
public static function getLocations(array $filters = [], $recordPageId): array {
$queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)->getQueryBuilderForTable(
'tx_sgjobs_domain_model_company'
);
......@@ -77,7 +77,7 @@ class FrontendFilterService {
$statement->andWhere(
$queryBuilder->expr()->eq(
'pid', $queryBuilder->createNamedParameter($siteRootId)
'pid', $queryBuilder->createNamedParameter($recordPageId)
)
);
......@@ -95,11 +95,11 @@ class FrontendFilterService {
* Get all the companies based on the given filters
*
* @param array $filters
* @param int $siteRootId
* @param int $recordPageId
* @return array
* @throws \InvalidArgumentException
*/
public static function getCompanies(array $filters = [], $siteRootId): array {
public static function getCompanies(array $filters = [], $recordPageId): array {
$queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)->getQueryBuilderForTable(
'tx_sgjobs_domain_model_company'
);
......@@ -140,7 +140,7 @@ class FrontendFilterService {
$statement->andWhere(
$queryBuilder->expr()->eq(
'pid', $queryBuilder->createNamedParameter($siteRootId)
'pid', $queryBuilder->createNamedParameter($recordPageId)
)
);
......@@ -159,11 +159,11 @@ class FrontendFilterService {
* Get all the areas based on the given filters
*
* @param array $filters
* @param int $siteRootId
* @param int $recordPageId
* @return array
* @throws \InvalidArgumentException
*/
public static function getAreas(array $filters = [], $siteRootId): array {
public static function getAreas(array $filters = [], $recordPageId): array {
$queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)->getQueryBuilderForTable(
'tx_sgjobs_domain_model_company'
);
......@@ -201,7 +201,7 @@ class FrontendFilterService {
$statement->andWhere(
$queryBuilder->expr()->eq(
'b.pid', $queryBuilder->createNamedParameter($siteRootId)
'b.pid', $queryBuilder->createNamedParameter($recordPageId)
)
);
......@@ -220,11 +220,11 @@ class FrontendFilterService {
* Get all the functions based on the given filters
*
* @param array $filters
* @param int $siteRootId
* @param int $recordPageId
* @return array
* @throws \InvalidArgumentException
*/
public static function getFunctions(array $filters = [], $siteRootId): array {
public static function getFunctions(array $filters = [], $recordPageId): array {
$queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)->getQueryBuilderForTable(
'tx_sgjobs_domain_model_company'
);
......@@ -270,7 +270,7 @@ class FrontendFilterService {
$statement->andWhere(
$queryBuilder->expr()->eq(
'b.pid', $queryBuilder->createNamedParameter($siteRootId)
'b.pid', $queryBuilder->createNamedParameter($recordPageId)
)
);
......@@ -289,11 +289,11 @@ class FrontendFilterService {
* Get all the jobs based on the given filters
*
* @param array $filters
* @param int $siteRootId
* @param int $recordPageId
* @return mixed
* @throws \InvalidArgumentException
*/
public static function getJobs(array $filters = [], $siteRootId): array {
public static function getJobs(array $filters = [], $recordPageId): array {
// get all company ids
$queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)->getQueryBuilderForTable(
'tx_sgjobs_domain_model_company'
......@@ -340,7 +340,7 @@ class FrontendFilterService {
$statement->andWhere(
$queryBuilder->expr()->eq(
'b.pid', $queryBuilder->createNamedParameter($siteRootId)
'b.pid', $queryBuilder->createNamedParameter($recordPageId)
)
);
......@@ -356,6 +356,6 @@ class FrontendFilterService {
$objectManager = GeneralUtility::makeInstance(ObjectManager::class);
/** @var JobRepository $jobRepository */
$jobRepository = $objectManager->get(JobRepository::class);
return $jobRepository->findByCompanyId($siteRootId, $result)->toArray();
return $jobRepository->findByCompanyId($recordPageId, $result)->toArray();
}
}
......@@ -11,9 +11,12 @@
<f:for each="{jobs}" as="job">
<f:render partial="Job" arguments="{job: job}" />
<hr>
</f:for>
<br/>
</div>
<div id="sgjobs-apply-nojob">
<f:form action="applyForm" controller="Joblist" pluginName="JobApplication" pageUid="{settings.applyPage}" objectName="jobData">
<f:form.hidden id="recordPageId" name="recordPageId" value="{recordPageId}" />
<f:form.submit value="{f:translate(key:'frontend.applyNow.emptyApplication')}" />
</f:form>
</div>
......
......@@ -12,7 +12,7 @@ export default class FileAjax {
*/
constructor() {
$('.remove-file').on('click', this._removeFile);
$('.sgjobs-select').on('change', this._filterJoblist());
$('.sgjobs-select').on('change', this._filterJoblist);
}
/**
......@@ -37,6 +37,7 @@ export default class FileAjax {
}
/**
* Filter for the joblist
*
* @private
*/
......@@ -44,6 +45,7 @@ export default class FileAjax {
$.post(
'?eID=sgAjax&extensionName=SgJobs&controller=Ajax%5CJoblist&action=filter&format=html',
{
recordPageId: $('#recordPageId').val(),
parameters: {
country: $('#filter-countries').val(),
location: $('#filter-locations').val(),
......
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