Improve mobile search performance, streamline namespace registration

This commit is contained in:
Björn Fromme
2021-10-26 10:18:27 +02:00
parent 8228c0d153
commit 2b2dbae409
25 changed files with 113 additions and 134 deletions
@@ -65,26 +65,16 @@ class AjaxFilterPanelController extends ActionController
$excludedConceptUids = GeneralUtility::trimExplode(',', $this->settings['excludedConceptUids']); $excludedConceptUids = GeneralUtility::trimExplode(',', $this->settings['excludedConceptUids']);
$excludedRegionUids = GeneralUtility::trimExplode(',', $this->settings['excludedRegionUids']); $excludedRegionUids = GeneralUtility::trimExplode(',', $this->settings['excludedRegionUids']);
$filterOptions = $this->filterService->getFilterOptions( $filterOptions = $this
->filterService
->getFilterOptions(
$filterSettings, $filterSettings,
$excludedConceptUids, $excludedConceptUids,
$excludedRegionUids, $excludedRegionUids,
$forcedConceptUids $forcedConceptUids
); );
$this->view->assignMultiple([ $resultsUri = $this->uriBuilder
'filterSettings' => $filterSettings,
'filterOptions' => $filterOptions,
'stimulusController' => 'mobile-search',
]);
}
/**
* @param array $filterSettings
*/
public function searchAction(array $filterSettings)
{
$uri = $this->uriBuilder
->reset() ->reset()
->setCreateAbsoluteUri(true) ->setCreateAbsoluteUri(true)
->setTargetPageUid($this->settings['defaultSearchPageUid']) ->setTargetPageUid($this->settings['defaultSearchPageUid'])
@@ -96,6 +86,13 @@ class AjaxFilterPanelController extends ActionController
'searchresult' 'searchresult'
); );
return json_encode($uri, JSON_THROW_ON_ERROR); $filterOptions->setResultsUri($resultsUri);
$this->view->assignMultiple([
'filterSettings' => $filterSettings,
'filterOptions' => $filterOptions,
'stimulusController' => 'mobile-search',
]);
} }
} }
@@ -1,6 +1,6 @@
<?php <?php
namespace EP\EpProducts\Domain\Model; namespace EP\EpProducts\Domain\Model\Dto;
/*************************************************************** /***************************************************************
* *
@@ -101,6 +101,11 @@ class FilterOptions implements \JsonSerializable
*/ */
protected $resultCount; protected $resultCount;
/**
* @var string
*/
protected $resultsUri;
public function __construct() public function __construct()
{ {
$this->pax = [ $this->pax = [
@@ -301,6 +306,22 @@ class FilterOptions implements \JsonSerializable
$this->resultCount = $resultCount; $this->resultCount = $resultCount;
} }
/**
* @return string
*/
public function getResultsUri(): ?string
{
return $this->resultsUri;
}
/**
* @param string $resultsUri
*/
public function setResultsUri(string $resultsUri)
{
$this->resultsUri = $resultsUri;
}
/** /**
* @return array * @return array
*/ */
@@ -319,6 +340,7 @@ class FilterOptions implements \JsonSerializable
'dateTo' => ($this->getDateTo() !== null) ? $this->getDateTo()->format('Y-m-d') : null, 'dateTo' => ($this->getDateTo() !== null) ? $this->getDateTo()->format('Y-m-d') : null,
'busAvailable' => $this->getBusAvailable(), 'busAvailable' => $this->getBusAvailable(),
'resultCount' => $this->getResultCount(), 'resultCount' => $this->getResultCount(),
'resultsUri' => $this->getResultsUri(),
]; ];
} }
@@ -27,7 +27,7 @@ namespace EP\EpProducts\Domain\Repository;
* This copyright notice MUST APPEAR in all copies of the script! * This copyright notice MUST APPEAR in all copies of the script!
***************************************************************/ ***************************************************************/
use EP\EpProducts\Domain\Model\FilterOptions; use EP\EpProducts\Domain\Model\Dto\FilterOptions;
use EP\EpProducts\Service\FilterService; use EP\EpProducts\Service\FilterService;
use EP\EpProducts\Traits\DbConnectionTrait; use EP\EpProducts\Traits\DbConnectionTrait;
use TYPO3\CMS\Core\Database\Connection; use TYPO3\CMS\Core\Database\Connection;
@@ -27,7 +27,7 @@ namespace EP\EpProducts\Service;
* This copyright notice MUST APPEAR in all copies of the script! * This copyright notice MUST APPEAR in all copies of the script!
***************************************************************/ ***************************************************************/
use EP\EpProducts\Domain\Model\FilterOptions; use EP\EpProducts\Domain\Model\Dto\FilterOptions;
use EP\EpProducts\Domain\Model\SearchResult; use EP\EpProducts\Domain\Model\SearchResult;
use EP\EpProducts\Domain\Repository\DateRepository; use EP\EpProducts\Domain\Repository\DateRepository;
use Symfony\Component\OptionsResolver\OptionsResolver; use Symfony\Component\OptionsResolver\OptionsResolver;
@@ -26,7 +26,7 @@ namespace EP\EpProducts\Service;
* This copyright notice MUST APPEAR in all copies of the script! * This copyright notice MUST APPEAR in all copies of the script!
***************************************************************/ ***************************************************************/
use EP\EpProducts\Domain\Model\FilterOptions; use EP\EpProducts\Domain\Model\Dto\FilterOptions;
use EP\EpProducts\Traits\DbConnectionTrait; use EP\EpProducts\Traits\DbConnectionTrait;
use TYPO3\CMS\Backend\Utility\BackendUtility; use TYPO3\CMS\Backend\Utility\BackendUtility;
use TYPO3\CMS\Core\SingletonInterface; use TYPO3\CMS\Core\SingletonInterface;
@@ -14,7 +14,6 @@ export default class extends Controller {
static values = { static values = {
optionsUri: String, optionsUri: String,
initialOptionsUri: String, initialOptionsUri: String,
searchUri: String,
loading: Boolean, loading: Boolean,
loaded: Boolean, loaded: Boolean,
show: Boolean, show: Boolean,
@@ -63,20 +62,6 @@ export default class extends Controller {
}) })
} }
search() {
const options = {
method: 'POST',
body: new FormData(this.formTarget)
}
this.loadingValue = true
fetch(this.searchUriValue, options)
.then(this.checkStatus)
.then(this.parseJSON)
.then(uri => {
window.location = uri
})
}
selectDateRange(e) { selectDateRange(e) {
e.stopPropagation() e.stopPropagation()
this.dateFromTarget.value = e.detail.from this.dateFromTarget.value = e.detail.from
@@ -1,13 +1,11 @@
<html data-namespace-typo3-fluid="true" lang="en" <html xmlns:f="http://typo3.org/ns/TYPO3/CMS/Fluid/ViewHelpers"
xmlns="http://www.w3.org/1999/xhtml" xmlns:ep="http://typo3.org/ns/EP/EpTheme/ViewHelpers"
xmlns:f="http://typo3.org/ns/fluid/ViewHelpers" data-namespace-typo3-fluid="true">
xmlns:ep="http://typo3.org/ns/EP/EpTheme/ViewHelpers">
<div class="fixed lg:hidden top-0 left-0 inset-0 w-screen h-screen pt-14 pb-10 z-50 bg-gray-700 hidden" <div class="fixed lg:hidden top-0 left-0 inset-0 w-screen h-screen pt-14 pb-10 z-50 bg-gray-700 hidden"
data-controller="mobile-search" data-controller="mobile-search"
data-mobile-search-options-uri-value="{ep:uri.ajax(controller: 'AjaxFilterPanel', action: 'options', pageUid: settings.defaultAjaxUid, format: 'html')}" data-mobile-search-options-uri-value="{ep:uri.ajax(controller: 'AjaxFilterPanel', action: 'options', pageUid: settings.defaultAjaxUid, format: 'html')}"
data-mobile-search-initial-options-uri-value="{ep:uri.ajax(controller: 'AjaxFilterPanel', action: 'options', pageUid: settings.defaultAjaxUid, arguments: '{filterSettings: filterSettings}', format: 'html')}" data-mobile-search-initial-options-uri-value="{ep:uri.ajax(controller: 'AjaxFilterPanel', action: 'options', pageUid: settings.defaultAjaxUid, arguments: '{filterSettings: filterSettings}', format: 'html')}"
data-mobile-search-search-uri-value="{ep:uri.ajax(controller: 'AjaxFilterPanel', action: 'search', pageUid: settings.defaultAjaxUid, format: 'json')}"
data-action="overlay-toggle:toggle@window->mobile-search#open datepicker:range-select->mobile-search#selectDateRange"> data-action="overlay-toggle:toggle@window->mobile-search#open datepicker:range-select->mobile-search#selectDateRange">
<div class="fixed top-0 left-0 z-100 inset-x-0 px-4 py-2 flex justify-between bg-white shadow-md"> <div class="fixed top-0 left-0 z-100 inset-x-0 px-4 py-2 flex justify-between bg-white shadow-md">
<a href="{f:uri.typolink(parameter: settings.defaultHomeUid)}" <a href="{f:uri.typolink(parameter: settings.defaultHomeUid)}"
@@ -1,7 +1,6 @@
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" <html xmlns:f="http://typo3.org/ns/TYPO3/CMS/Fluid/ViewHelpers"
xmlns:f="http://typo3.org/ns/fluid/ViewHelpers"
xmlns:ep="http://typo3.org/ns/EP/EpTheme/ViewHelpers" xmlns:ep="http://typo3.org/ns/EP/EpTheme/ViewHelpers"
xmlns:v="http://typo3.org/ns/FluidTYPO3/Vhs/ViewHelpers"> data-namespace-typo3-fluid="true">
<f:layout name="Default"/> <f:layout name="Default"/>
@@ -1,7 +1,6 @@
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" <html xmlns:f="http://typo3.org/ns/TYPO3/CMS/Fluid/ViewHelpers"
xmlns:f="http://typo3.org/ns/fluid/ViewHelpers"
xmlns:ep="http://typo3.org/ns/EP/EpTheme/ViewHelpers" xmlns:ep="http://typo3.org/ns/EP/EpTheme/ViewHelpers"
xmlns:v="http://typo3.org/ns/FluidTYPO3/Vhs/ViewHelpers"> data-namespace-typo3-fluid="true">
<f:layout name="Default"/> <f:layout name="Default"/>
@@ -13,13 +12,14 @@
data="{'mobile-search-target': 'form'}"> data="{'mobile-search-target': 'form'}">
<f:render partial="Search/FilterPanel" arguments="{_all}"/> <f:render partial="Search/FilterPanel" arguments="{_all}"/>
</f:form> </f:form>
<f:if condition="{filterOptions.resultsUri}">
<div class="mt-4"> <div class="mt-4">
<button type="button" <a href="{filterOptions.resultsUri}"
class="button button--primary w-full" class="button button--primary w-full">
data-action="mobile-search#search">
Ergebnis anzeigen Ergebnis anzeigen
</button> </a>
</div> </div>
</f:if>
<div class="mt-4"> <div class="mt-4">
<button type="button" <button type="button"
class="button button--secondary w-full" class="button button--secondary w-full"
@@ -1,11 +0,0 @@
<div xmlns="http://www.w3.org/1999/xhtml" lang="en"
xmlns:f="http://typo3.org/ns/fluid/ViewHelpers"
xmlns:ep="http://typo3.org/ns/EP/EpTheme/ViewHelpers">
<f:layout name="Form/Default"/>
<f:section name="Main">
<f:render partial="ContactForm/Full" arguments="{_all}"/>
</f:section>
</div>
@@ -1,11 +0,0 @@
<div xmlns="http://www.w3.org/1999/xhtml" lang="en"
xmlns:f="http://typo3.org/ns/fluid/ViewHelpers"
xmlns:ep="http://typo3.org/ns/EP/EpTheme/ViewHelpers">
<f:layout name="Form/Default"/>
<f:section name="Main">
<f:render partial="ContactForm/Simple" arguments="{_all}"/>
</f:section>
</div>
@@ -1,6 +1,6 @@
<html data-namespace-typo3-fluid="true" lang="en" <html xmlns:f="http://typo3.org/ns/TYPO3/CMS/Fluid/ViewHelpers"
xmlns="http://www.w3.org/1999/xhtml" xmlns:ep="http://typo3.org/ns/EP/EpTheme/ViewHelpers"
xmlns:f="http://typo3.org/ns/fluid/ViewHelpers"> data-namespace-typo3-fluid="true">
<f:layout name="Default"/> <f:layout name="Default"/>
@@ -1,6 +1,6 @@
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" <html xmlns:f="http://typo3.org/ns/TYPO3/CMS/Fluid/ViewHelpers"
xmlns:f="http://typo3.org/ns/fluid/ViewHelpers" xmlns:ep="http://typo3.org/ns/EP/EpTheme/ViewHelpers"
xmlns:ep="http://typo3.org/ns/EP/EpTheme/ViewHelpers"> data-namespace-typo3-fluid="true">
<f:layout name="Default"/> <f:layout name="Default"/>
@@ -1,6 +1,6 @@
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" <html xmlns:f="http://typo3.org/ns/TYPO3/CMS/Fluid/ViewHelpers"
xmlns:f="http://typo3.org/ns/fluid/ViewHelpers" xmlns:ep="http://typo3.org/ns/EP/EpTheme/ViewHelpers"
xmlns:ep="http://typo3.org/ns/EP/EpTheme/ViewHelpers"> data-namespace-typo3-fluid="true">
<f:layout name="Default"/> <f:layout name="Default"/>
@@ -1,7 +1,7 @@
<html data-namespace-typo3-fluid="true" lang="en" <html xmlns:f="http://typo3.org/ns/TYPO3/CMS/Fluid/ViewHelpers"
xmlns="http://www.w3.org/1999/xhtml" xmlns:ep="http://typo3.org/ns/EP/EpTheme/ViewHelpers"
xmlns:v="http://typo3.org/ns/FluidTYPO3/Vhs/ViewHelpers" xmlns:v="http://typo3.org/ns/FluidTYPO3/Vhs/ViewHelpers"
xmlns:f="http://typo3.org/ns/fluid/ViewHelpers"> data-namespace-typo3-fluid="true">
<f:layout name="Default"/> <f:layout name="Default"/>
@@ -1,6 +1,6 @@
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" <html xmlns:f="http://typo3.org/ns/TYPO3/CMS/Fluid/ViewHelpers"
xmlns:f="http://typo3.org/ns/fluid/ViewHelpers" xmlns:ep="http://typo3.org/ns/EP/EpTheme/ViewHelpers"
xmlns:ep="http://typo3.org/ns/EP/EpTheme/ViewHelpers"> data-namespace-typo3-fluid="true">
<f:layout name="Default"/> <f:layout name="Default"/>
@@ -1,6 +1,6 @@
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" <html xmlns:f="http://typo3.org/ns/TYPO3/CMS/Fluid/ViewHelpers"
xmlns:f="http://typo3.org/ns/fluid/ViewHelpers" xmlns:ep="http://typo3.org/ns/EP/EpTheme/ViewHelpers"
xmlns:ep="http://typo3.org/ns/EP/EpTheme/ViewHelpers"> data-namespace-typo3-fluid="true">
<f:layout name="Default"/> <f:layout name="Default"/>
@@ -1,7 +1,6 @@
<html data-namespace-typo3-fluid="true" lang="en" <html xmlns:f="http://typo3.org/ns/TYPO3/CMS/Fluid/ViewHelpers"
xmlns="http://www.w3.org/1999/xhtml" xmlns:ep="http://typo3.org/ns/EP/EpTheme/ViewHelpers"
xmlns:f="http://typo3.org/ns/fluid/ViewHelpers" data-namespace-typo3-fluid="true">
xmlns:ep="http://typo3.org/ns/EP/EpTheme/ViewHelpers">
<f:if condition="{watchlist -> f:count()} == 0"> <f:if condition="{watchlist -> f:count()} == 0">
<f:then> <f:then>
@@ -1,6 +1,6 @@
<html data-namespace-typo3-fluid="true" lang="en" <html xmlns:f="http://typo3.org/ns/TYPO3/CMS/Fluid/ViewHelpers"
xmlns="http://www.w3.org/1999/xhtml" xmlns:ep="http://typo3.org/ns/EP/EpTheme/ViewHelpers"
xmlns:f="http://typo3.org/ns/fluid/ViewHelpers"> data-namespace-typo3-fluid="true">
<f:layout name="Default"/> <f:layout name="Default"/>
@@ -1,6 +1,6 @@
<html data-namespace-typo3-fluid="true" lang="en" <html xmlns:f="http://typo3.org/ns/TYPO3/CMS/Fluid/ViewHelpers"
xmlns="http://www.w3.org/1999/xhtml" xmlns:ep="http://typo3.org/ns/EP/EpTheme/ViewHelpers"
xmlns:f="http://typo3.org/ns/fluid/ViewHelpers"> data-namespace-typo3-fluid="true">
<f:layout name="Default"/> <f:layout name="Default"/>
@@ -1,8 +1,7 @@
<html data-namespace-typo3-fluid="true" lang="en" <html xmlns:f="http://typo3.org/ns/TYPO3/CMS/Fluid/ViewHelpers"
xmlns="http://www.w3.org/1999/xhtml"
xmlns:ep="http://typo3.org/ns/EP/EpTheme/ViewHelpers" xmlns:ep="http://typo3.org/ns/EP/EpTheme/ViewHelpers"
xmlns:encore="http://typo3.org/ns/Ssch/Typo3Encore/ViewHelpers" xmlns:encore="http://typo3.org/ns/Ssch/Typo3Encore/ViewHelpers"
xmlns:f="http://typo3.org/ns/fluid/ViewHelpers"> data-namespace-typo3-fluid="true">
<div class="container"> <div class="container">
<div class="page-header"> <div class="page-header">
@@ -1,8 +1,6 @@
<html data-namespace-typo3-fluid="true" lang="en" <html xmlns:f="http://typo3.org/ns/TYPO3/CMS/Fluid/ViewHelpers"
xmlns="http://www.w3.org/1999/xhtml"
xmlns:f="http://typo3.org/ns/fluid/ViewHelpers"
xmlns:ep="http://typo3.org/ns/EP/EpTheme/ViewHelpers" xmlns:ep="http://typo3.org/ns/EP/EpTheme/ViewHelpers"
xmlns:v="http://typo3.org/ns/FluidTYPO3/Vhs/ViewHelpers"> data-namespace-typo3-fluid="true">
<f:layout name="Default"/> <f:layout name="Default"/>
@@ -1,4 +1,6 @@
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xmlns:f="http://typo3.org/ns/fluid/ViewHelpers"> <html xmlns:f="http://typo3.org/ns/TYPO3/CMS/Fluid/ViewHelpers"
xmlns:ep="http://typo3.org/ns/EP/EpTheme/ViewHelpers"
data-namespace-typo3-fluid="true">
<f:layout name="Default"/> <f:layout name="Default"/>
@@ -1,4 +1,6 @@
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xmlns:f="http://typo3.org/ns/fluid/ViewHelpers"> <html xmlns:f="http://typo3.org/ns/TYPO3/CMS/Fluid/ViewHelpers"
xmlns:ep="http://typo3.org/ns/EP/EpTheme/ViewHelpers"
data-namespace-typo3-fluid="true">
<f:layout name="Default"/> <f:layout name="Default"/>
@@ -1,6 +1,6 @@
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" <html xmlns:f="http://typo3.org/ns/TYPO3/CMS/Fluid/ViewHelpers"
xmlns:f="http://typo3.org/ns/fluid/ViewHelpers" xmlns:ep="http://typo3.org/ns/EP/EpTheme/ViewHelpers"
xmlns:ep="http://typo3.org/ns/EP/EpTheme/ViewHelpers"> data-namespace-typo3-fluid="true">
<f:layout name="Default"/> <f:layout name="Default"/>