diff --git a/public/typo3conf/ext/ep_products/Classes/Controller/AjaxSearchController.php b/public/typo3conf/ext/ep_products/Classes/Controller/AjaxSearchController.php index 0cf84ab1..96a12d4d 100644 --- a/public/typo3conf/ext/ep_products/Classes/Controller/AjaxSearchController.php +++ b/public/typo3conf/ext/ep_products/Classes/Controller/AjaxSearchController.php @@ -29,6 +29,7 @@ namespace EP\EpProducts\Controller; use EP\EpProducts\Domain\Model\FilterSettings; use EP\EpProducts\Service\FilterService; +use EP\EpProducts\Service\FilterSettingsEncoder; use EP\EpProducts\Service\SearchResultUrlService; use EP\EpProducts\Service\SearchResultService; use EP\EpProducts\Traits\RequestArgumentTypeConversionTrait; @@ -122,9 +123,24 @@ class AjaxSearchController extends ActionController $this->searchResultUrlService->process($searchResult, $options); + $encodedFilterSettings = FilterSettingsEncoder::encode($filterSettings); + $referringPageUri = $this + ->uriBuilder + ->reset() + ->setTargetPageUid($this->settings['defaultSearchPageUid']) + ->uriFor( + 'searchresult', + ['filterSettings' => $encodedFilterSettings], + 'Search', + null, + 'searchresult' + ) + ; + return json_encode([ 'data' => $searchResult->getData(), 'filterOptions' => $filterOptions, + 'referringPageUri' => $referringPageUri, 'meta' => [ 'organic' => $organic, 'total' => $searchResult->getTotal(), diff --git a/public/typo3conf/ext/ep_theme/Resources/Private/Assets/js/components/SearchResult.vue b/public/typo3conf/ext/ep_theme/Resources/Private/Assets/js/components/SearchResult.vue index 78731a80..17538777 100644 --- a/public/typo3conf/ext/ep_theme/Resources/Private/Assets/js/components/SearchResult.vue +++ b/public/typo3conf/ext/ep_theme/Resources/Private/Assets/js/components/SearchResult.vue @@ -42,11 +42,8 @@ resultData: {}, resultMeta: null, filterSettings: defaultFilterSettings, - filterOptions: defaultFilterOptions, - referringPage: { - url: this.referringPageUrl, - label: 'zurück zum Suchergebnis' - } + referringPageUri: null, + filterOptions: defaultFilterOptions } }, props: { @@ -58,10 +55,6 @@ type: Object, default: null }, - referringPageUrl: { - type: String, - default: null - }, argumentPrefix: { type: String, required: true @@ -127,13 +120,14 @@ url: this.resultsUri, method: 'post', data: $.param(query) - }).then((response) => { + }).then(response => { this.resultData = response.data.data; this.filterOptions = response.data.filterOptions; + this.referringPageUri = response.data.referringPageUri; this.resultMeta = response.data.meta; this.loading = false; EventBus.$emit('ajaxContentLoaded'); - }).catch(() => { + }).finally(() => { this.loading = false; }); }, diff --git a/public/typo3conf/ext/ep_theme/Resources/Private/Assets/js/components/SearchResultItem.vue b/public/typo3conf/ext/ep_theme/Resources/Private/Assets/js/components/SearchResultItem.vue index d1817b37..41f2db8f 100644 --- a/public/typo3conf/ext/ep_theme/Resources/Private/Assets/js/components/SearchResultItem.vue +++ b/public/typo3conf/ext/ep_theme/Resources/Private/Assets/js/components/SearchResultItem.vue @@ -2,7 +2,7 @@
- + @@ -44,7 +44,7 @@
ab {{ item.minPrice }} € - Details & Buchen @@ -82,14 +82,20 @@ section: { type: Object, required: true - } - }, - methods: { - getUrl () { - return this.item.detailPageUri + '?ref=' + window.location.pathname; + }, + referringPageUri: { + type: String, + default: null } }, computed: { + url () { + let url = this.item.detailPageUri; + if (this.referringPageUri) { + url += '?ref=' + this.referringPageUri; + } + return url; + }, nightsOptions () { const nights = this.item.nights; if (nights === null) { diff --git a/public/typo3conf/ext/ep_theme/Resources/Private/Templates/Search/Searchresult.html b/public/typo3conf/ext/ep_theme/Resources/Private/Templates/Search/Searchresult.html index 5c1a7ef9..a3b790bf 100644 --- a/public/typo3conf/ext/ep_theme/Resources/Private/Templates/Search/Searchresult.html +++ b/public/typo3conf/ext/ep_theme/Resources/Private/Templates/Search/Searchresult.html @@ -302,7 +302,8 @@ :key="item.key" :item="item" :section="section" - :referring-page="referringPage"> + :referring-page-uri="referringPageUri" + >