From 2b2dbae4091a48133337b4751093bd5b85c620f0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bjo=CC=88rn=20Fromme?= Date: Tue, 26 Oct 2021 10:18:27 +0200 Subject: [PATCH] Improve mobile search performance, streamline namespace registration --- .../Controller/AjaxFilterPanelController.php | 37 +++++++++---------- .../Domain/Model/{ => Dto}/FilterOptions.php | 24 +++++++++++- .../Domain/Repository/AbstractRepository.php | 2 +- .../Classes/Service/FilterService.php | 2 +- .../Classes/Service/LogService.php | 2 +- .../controllers/mobile_search_controller.js | 15 -------- .../Private/Partials/Search/MobileSearch.html | 8 ++-- .../Private/Templates/AjaxCalendar/Range.html | 5 +-- .../Templates/AjaxFilterPanel/Options.html | 20 +++++----- .../Private/Templates/AjaxForm/FullForm.html | 11 ------ .../Templates/AjaxForm/SimpleForm.html | 11 ------ .../Templates/AjaxSearch/Searchresult.html | 6 +-- .../Templates/AjaxTable/Datestable.html | 6 +-- .../Templates/AjaxTable/DaytripRooms.html | 6 +-- .../Templates/AjaxTable/EventPricetable.html | 6 +-- .../Templates/AjaxTable/Pricetable.html | 6 +-- .../Templates/AjaxTable/PricetableHtml.html | 6 +-- .../Private/Templates/AjaxWatchlist/List.html | 7 ++-- .../Templates/Container/Teasergroup.html | 6 +-- .../Private/Templates/Container/Thirds.html | 34 ++++++++--------- .../Private/Templates/GroupsPrice/Index.html | 5 +-- .../Private/Templates/Pricetable/Event.html | 8 ++-- .../Templates/Search/Searchresult.html | 4 +- .../Private/Templates/Searchbar/Index.html | 4 +- .../Private/Templates/Watchlist/List.html | 6 +-- 25 files changed, 113 insertions(+), 134 deletions(-) rename public/typo3conf/ext/ep_products/Classes/Domain/Model/{ => Dto}/FilterOptions.php (93%) delete mode 100644 public/typo3conf/ext/ep_theme/Resources/Private/Templates/AjaxForm/FullForm.html delete mode 100644 public/typo3conf/ext/ep_theme/Resources/Private/Templates/AjaxForm/SimpleForm.html diff --git a/public/typo3conf/ext/ep_products/Classes/Controller/AjaxFilterPanelController.php b/public/typo3conf/ext/ep_products/Classes/Controller/AjaxFilterPanelController.php index 294a804c..84f35333 100644 --- a/public/typo3conf/ext/ep_products/Classes/Controller/AjaxFilterPanelController.php +++ b/public/typo3conf/ext/ep_products/Classes/Controller/AjaxFilterPanelController.php @@ -65,26 +65,16 @@ class AjaxFilterPanelController extends ActionController $excludedConceptUids = GeneralUtility::trimExplode(',', $this->settings['excludedConceptUids']); $excludedRegionUids = GeneralUtility::trimExplode(',', $this->settings['excludedRegionUids']); - $filterOptions = $this->filterService->getFilterOptions( - $filterSettings, - $excludedConceptUids, - $excludedRegionUids, - $forcedConceptUids - ); + $filterOptions = $this + ->filterService + ->getFilterOptions( + $filterSettings, + $excludedConceptUids, + $excludedRegionUids, + $forcedConceptUids + ); - $this->view->assignMultiple([ - 'filterSettings' => $filterSettings, - 'filterOptions' => $filterOptions, - 'stimulusController' => 'mobile-search', - ]); - } - - /** - * @param array $filterSettings - */ - public function searchAction(array $filterSettings) - { - $uri = $this->uriBuilder + $resultsUri = $this->uriBuilder ->reset() ->setCreateAbsoluteUri(true) ->setTargetPageUid($this->settings['defaultSearchPageUid']) @@ -96,6 +86,13 @@ class AjaxFilterPanelController extends ActionController 'searchresult' ); - return json_encode($uri, JSON_THROW_ON_ERROR); + $filterOptions->setResultsUri($resultsUri); + + $this->view->assignMultiple([ + 'filterSettings' => $filterSettings, + 'filterOptions' => $filterOptions, + 'stimulusController' => 'mobile-search', + ]); } + } diff --git a/public/typo3conf/ext/ep_products/Classes/Domain/Model/FilterOptions.php b/public/typo3conf/ext/ep_products/Classes/Domain/Model/Dto/FilterOptions.php similarity index 93% rename from public/typo3conf/ext/ep_products/Classes/Domain/Model/FilterOptions.php rename to public/typo3conf/ext/ep_products/Classes/Domain/Model/Dto/FilterOptions.php index 592dae09..7e9f05d8 100644 --- a/public/typo3conf/ext/ep_products/Classes/Domain/Model/FilterOptions.php +++ b/public/typo3conf/ext/ep_products/Classes/Domain/Model/Dto/FilterOptions.php @@ -1,6 +1,6 @@ pax = [ @@ -301,6 +306,22 @@ class FilterOptions implements \JsonSerializable $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 */ @@ -319,6 +340,7 @@ class FilterOptions implements \JsonSerializable 'dateTo' => ($this->getDateTo() !== null) ? $this->getDateTo()->format('Y-m-d') : null, 'busAvailable' => $this->getBusAvailable(), 'resultCount' => $this->getResultCount(), + 'resultsUri' => $this->getResultsUri(), ]; } diff --git a/public/typo3conf/ext/ep_products/Classes/Domain/Repository/AbstractRepository.php b/public/typo3conf/ext/ep_products/Classes/Domain/Repository/AbstractRepository.php index 8709c127..02f6c81b 100644 --- a/public/typo3conf/ext/ep_products/Classes/Domain/Repository/AbstractRepository.php +++ b/public/typo3conf/ext/ep_products/Classes/Domain/Repository/AbstractRepository.php @@ -27,7 +27,7 @@ namespace EP\EpProducts\Domain\Repository; * 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\Traits\DbConnectionTrait; use TYPO3\CMS\Core\Database\Connection; diff --git a/public/typo3conf/ext/ep_products/Classes/Service/FilterService.php b/public/typo3conf/ext/ep_products/Classes/Service/FilterService.php index 0c40a163..08404294 100644 --- a/public/typo3conf/ext/ep_products/Classes/Service/FilterService.php +++ b/public/typo3conf/ext/ep_products/Classes/Service/FilterService.php @@ -27,7 +27,7 @@ namespace EP\EpProducts\Service; * 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\Repository\DateRepository; use Symfony\Component\OptionsResolver\OptionsResolver; diff --git a/public/typo3conf/ext/ep_products/Classes/Service/LogService.php b/public/typo3conf/ext/ep_products/Classes/Service/LogService.php index 8fd63cb5..4e588ced 100644 --- a/public/typo3conf/ext/ep_products/Classes/Service/LogService.php +++ b/public/typo3conf/ext/ep_products/Classes/Service/LogService.php @@ -26,7 +26,7 @@ namespace EP\EpProducts\Service; * 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 TYPO3\CMS\Backend\Utility\BackendUtility; use TYPO3\CMS\Core\SingletonInterface; diff --git a/public/typo3conf/ext/ep_theme/Resources/Private/Assets/js/controllers/mobile_search_controller.js b/public/typo3conf/ext/ep_theme/Resources/Private/Assets/js/controllers/mobile_search_controller.js index d9181f21..a29537c8 100644 --- a/public/typo3conf/ext/ep_theme/Resources/Private/Assets/js/controllers/mobile_search_controller.js +++ b/public/typo3conf/ext/ep_theme/Resources/Private/Assets/js/controllers/mobile_search_controller.js @@ -14,7 +14,6 @@ export default class extends Controller { static values = { optionsUri: String, initialOptionsUri: String, - searchUri: String, loading: Boolean, loaded: 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) { e.stopPropagation() this.dateFromTarget.value = e.detail.from diff --git a/public/typo3conf/ext/ep_theme/Resources/Private/Partials/Search/MobileSearch.html b/public/typo3conf/ext/ep_theme/Resources/Private/Partials/Search/MobileSearch.html index 3e571542..e0447da0 100644 --- a/public/typo3conf/ext/ep_theme/Resources/Private/Partials/Search/MobileSearch.html +++ b/public/typo3conf/ext/ep_theme/Resources/Private/Partials/Search/MobileSearch.html @@ -1,13 +1,11 @@ - +