Skip to content
Snippets Groups Projects
Commit 4a1c7b02 authored by Tim Wagner's avatar Tim Wagner
Browse files

[BUGFIX] Clean up and fix job list filtering

parent d60c3ac8
No related branches found
No related tags found
No related merge requests found
...@@ -52,32 +52,19 @@ class CompanyRepository extends Repository { ...@@ -52,32 +52,19 @@ class CompanyRepository extends Repository {
* *
* @param int $pageUid * @param int $pageUid
* @return mixed * @return mixed
* @throws \InvalidArgumentException * @throws \TYPO3\CMS\Core\Context\Exception\AspectNotFoundException
*/ */
public function getAllCountries($pageUid) { public function getAllCountries($pageUid) {
/** @var QueryInterface $query */ $result = $this->getAllCompanies($pageUid)->toArray();
$query = $this->createQuery();
$querySettings = $query->getQuerySettings();
$querySettings->setStoragePageIds([$pageUid]);
$querySettings->setLanguageUid(
GeneralUtility::makeInstance(Context::class)->getPropertyFromAspect('language', 'id', 0)
);
$query->setQuerySettings($querySettings); $countryArray = [];
$query->setOrderings(
[
'sorting' => QueryInterface::ORDER_ASCENDING,
]
);
$result = $query->execute()->toArray();
$countryArray = [''];
/** @var Company $company */ /** @var Company $company */
foreach ($result as $company) { foreach ($result as $company) {
$countryName = $company->getCountry(); $countryName = $company->getCountry();
$countryArray[$countryName] = $countryName; if ($countryName !== '') {
// The filtering needs this specific key for some reason.
$countryArray[$countryName] = $countryName;
}
} }
return $countryArray; return $countryArray;
...@@ -88,68 +75,42 @@ class CompanyRepository extends Repository { ...@@ -88,68 +75,42 @@ class CompanyRepository extends Repository {
* *
* @param int $pageUid * @param int $pageUid
* @return mixed * @return mixed
* @throws \InvalidArgumentException * @throws \TYPO3\CMS\Core\Context\Exception\AspectNotFoundException
*/ */
public function getAllCities($pageUid) { public function getAllCities($pageUid) {
/** @var QueryInterface $query */ $result = $this->getAllCompanies($pageUid)->toArray();
$query = $this->createQuery();
$querySettings = $query->getQuerySettings();
$querySettings->setStoragePageIds([$pageUid]);
$querySettings->setLanguageUid(
GeneralUtility::makeInstance(Context::class)->getPropertyFromAspect('language', 'id', 0)
);
$query->setQuerySettings($querySettings);
$query->setOrderings( $cityArray = [];
[
'sorting' => QueryInterface::ORDER_ASCENDING,
]
);
$result = $query->execute()->toArray();
$cityArray = [''];
/** @var Company $company */ /** @var Company $company */
foreach ($result as $company) { foreach ($result as $company) {
$cityName = $company->getCity(); $cityName = $company->getCity();
$cityArray[$cityName] = $cityName; if ($cityName !== '') {
// The filtering needs this specific key for some reason.
$cityArray[$cityName] = $cityName;
}
} }
return $cityArray; return $cityArray;
} }
/** /**
* Returns all companies filtered by page id * Returns all company names filtered by page id
* *
* @param int $pageUid * @param int $pageUid
* @return mixed * @return mixed
* @throws \InvalidArgumentException * @throws \TYPO3\CMS\Core\Context\Exception\AspectNotFoundException
*/ */
public function getAllCompanyNames($pageUid) { public function getAllCompanyNames($pageUid) {
/** @var QueryInterface $query */ $result = $this->getAllCompanies($pageUid)->toArray();
$query = $this->createQuery();
$querySettings = $query->getQuerySettings();
$querySettings->setStoragePageIds([$pageUid]);
$querySettings->setLanguageUid(
GeneralUtility::makeInstance(Context::class)->getPropertyFromAspect('language', 'id', 0)
);
$query->setQuerySettings($querySettings);
$query->setOrderings(
[
'sorting' => QueryInterface::ORDER_ASCENDING,
]
);
$result = $query->execute()->toArray();
$companyArray = ['']; $companyArray = [];
/** @var Company $company */ /** @var Company $company */
foreach ($result as $company) { foreach ($result as $company) {
$companyName = $company->getName(); $companyName = $company->getName();
$companyArray[$companyName] = $companyName; if ($companyName !== '') {
// The filtering needs this specific key for some reason.
$companyArray[$companyName] = $companyName;
}
} }
return $companyArray; return $companyArray;
...@@ -160,10 +121,9 @@ class CompanyRepository extends Repository { ...@@ -160,10 +121,9 @@ class CompanyRepository extends Repository {
* *
* @param int $pageUid * @param int $pageUid
* @return mixed * @return mixed
* @throws \InvalidArgumentException * @throws \TYPO3\CMS\Core\Context\Exception\AspectNotFoundException
*/ */
public function getAllCompanies($pageUid) { public function getAllCompanies($pageUid) {
/** @var QueryInterface $query */
$query = $this->createQuery(); $query = $this->createQuery();
$querySettings = $query->getQuerySettings(); $querySettings = $query->getQuerySettings();
$querySettings->setStoragePageIds([$pageUid]); $querySettings->setStoragePageIds([$pageUid]);
......
...@@ -366,6 +366,10 @@ ...@@ -366,6 +366,10 @@
<source><![CDATA[Location]]></source> <source><![CDATA[Location]]></source>
<target><![CDATA[Standort]]></target> <target><![CDATA[Standort]]></target>
</trans-unit> </trans-unit>
<trans-unit id="frontend.filter.selections.all" approved="yes">
<source><![CDATA[All]]></source>
<target><![CDATA[Alle]]></target>
</trans-unit>
<trans-unit id="frontend.filter.submit" approved="yes"> <trans-unit id="frontend.filter.submit" approved="yes">
<source><![CDATA[Filter]]></source> <source><![CDATA[Filter]]></source>
<target><![CDATA[Filtern]]></target> <target><![CDATA[Filtern]]></target>
......
...@@ -276,6 +276,9 @@ ...@@ -276,6 +276,9 @@
<trans-unit id="frontend.filter.locations"> <trans-unit id="frontend.filter.locations">
<source><![CDATA[Location]]></source> <source><![CDATA[Location]]></source>
</trans-unit> </trans-unit>
<trans-unit id="frontend.filter.selections.all">
<source><![CDATA[All]]></source>
</trans-unit>
<trans-unit id="frontend.filter.submit"> <trans-unit id="frontend.filter.submit">
<source><![CDATA[Filter]]></source> <source><![CDATA[Filter]]></source>
</trans-unit> </trans-unit>
......
...@@ -213,6 +213,10 @@ ...@@ -213,6 +213,10 @@
<source><![CDATA[Location]]></source> <source><![CDATA[Location]]></source>
<target><![CDATA[地点]]></target> <target><![CDATA[地点]]></target>
</trans-unit> </trans-unit>
<trans-unit id="frontend.filter.selections.all" approved="yes">
<source><![CDATA[All]]></source>
<target><![CDATA[]]></target>
</trans-unit>
<trans-unit id="frontend.location" approved="yes"> <trans-unit id="frontend.location" approved="yes">
<source><![CDATA[Location]]></source> <source><![CDATA[Location]]></source>
<target><![CDATA[地点]]></target> <target><![CDATA[地点]]></target>
......
...@@ -18,13 +18,15 @@ ...@@ -18,13 +18,15 @@
property="filterCountry" property="filterCountry"
optionValueField="value" optionValueField="value"
options="{countries}" options="{countries}"
prependOptionLabel="{f:translate(key: 'frontend.filter.selections.all')}"
prependOptionValue="0"
id="filter-countries"/> id="filter-countries"/>
</div> </div>
</div> </div>
<div class="col-md-6 col-sm-6 col-cs-12"> <div class="col-md-6 col-sm-6 col-cs-12">
<div class="sgjobs-filter-bar-form-control"> <div class="sgjobs-filter-bar-form-control">
<label for="filter-countries"> <label for="filter-locations">
<f:translate key="frontend.filter.locations"/> <f:translate key="frontend.filter.locations"/>
</label> </label>
<f:form.select <f:form.select
...@@ -33,7 +35,9 @@ ...@@ -33,7 +35,9 @@
value="{selectedLocation}" value="{selectedLocation}"
property="filterLocation" property="filterLocation"
optionValueField="value" optionValueField="value"
options="{companies}" options="{cities}"
prependOptionLabel="{f:translate(key: 'frontend.filter.selections.all')}"
prependOptionValue="0"
id="filter-locations"/> id="filter-locations"/>
</div> </div>
</div> </div>
...@@ -52,6 +56,8 @@ ...@@ -52,6 +56,8 @@
property="filterCompany" property="filterCompany"
optionValueField="value" optionValueField="value"
options="{companies}" options="{companies}"
prependOptionLabel="{f:translate(key: 'frontend.filter.selections.all')}"
prependOptionValue="0"
id="filter-companies"/> id="filter-companies"/>
</div> </div>
</div> </div>
...@@ -69,7 +75,7 @@ ...@@ -69,7 +75,7 @@
optionLabelField="title" optionLabelField="title"
optionValueField="uid" optionValueField="uid"
options="{departments}" options="{departments}"
prependOptionLabel="" prependOptionLabel="{f:translate(key: 'frontend.filter.selections.all')}"
prependOptionValue="0" prependOptionValue="0"
id="filter-departments"/> id="filter-departments"/>
</div> </div>
...@@ -90,7 +96,7 @@ ...@@ -90,7 +96,7 @@
optionLabelField="title" optionLabelField="title"
optionValueField="uid" optionValueField="uid"
options="{experienceLevels}" options="{experienceLevels}"
prependOptionLabel="" prependOptionLabel="{f:translate(key: 'frontend.filter.selections.all')}"
prependOptionValue="0" prependOptionValue="0"
id="filter-experienceLevels"/> id="filter-experienceLevels"/>
</div> </div>
......
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