Feat: Use GET to fetch tables via ajax to make use of cache
This commit is contained in:
@@ -125,7 +125,6 @@ class AjaxTableController extends ActionController
|
|||||||
(
|
(
|
||||||
Product $product,
|
Product $product,
|
||||||
Hotel $hotel,
|
Hotel $hotel,
|
||||||
string $paCode = null,
|
|
||||||
string $dateFrom = null,
|
string $dateFrom = null,
|
||||||
string $dateTo = null
|
string $dateTo = null
|
||||||
): void {
|
): void {
|
||||||
@@ -133,6 +132,7 @@ class AjaxTableController extends ActionController
|
|||||||
$filterSettings = $this->filterService->getNormalizedFilterSettings([], $forcedConceptUids);
|
$filterSettings = $this->filterService->getNormalizedFilterSettings([], $forcedConceptUids);
|
||||||
$filterSettings['dateFrom'] = $dateFrom;
|
$filterSettings['dateFrom'] = $dateFrom;
|
||||||
$filterSettings['dateTo'] = $dateTo;
|
$filterSettings['dateTo'] = $dateTo;
|
||||||
|
$paCode = GeneralUtility::_GET('pa');
|
||||||
|
|
||||||
$dates = $this->dateService->getDatesTable([
|
$dates = $this->dateService->getDatesTable([
|
||||||
'product' => $product,
|
'product' => $product,
|
||||||
@@ -226,23 +226,18 @@ class AjaxTableController extends ActionController
|
|||||||
Product $product,
|
Product $product,
|
||||||
Hotel $hotel,
|
Hotel $hotel,
|
||||||
Date $date,
|
Date $date,
|
||||||
string $paCode = null,
|
|
||||||
bool $singleDate = false
|
bool $singleDate = false
|
||||||
): void {
|
): void {
|
||||||
$forcedConceptUids = GeneralUtility::trimExplode(',', $this->settings['forcedConceptUids'], true);
|
$forcedConceptUids = GeneralUtility::trimExplode(',', $this->settings['forcedConceptUids'], true);
|
||||||
$filterSettings = $this->filterService->getNormalizedFilterSettings([], $forcedConceptUids);
|
$filterSettings = $this->filterService->getNormalizedFilterSettings([], $forcedConceptUids);
|
||||||
|
|
||||||
// if ($reseller = $this->resellerDataService->getResellerForCurrentDomain()) {
|
|
||||||
// $paCode = $reseller['paCode'];
|
|
||||||
// }
|
|
||||||
|
|
||||||
$priceTable = $this->dateService->getPriceTable([
|
$priceTable = $this->dateService->getPriceTable([
|
||||||
'product' => $product,
|
'product' => $product,
|
||||||
'hotel' => $hotel,
|
'hotel' => $hotel,
|
||||||
'filterSettings' => $filterSettings,
|
'filterSettings' => $filterSettings,
|
||||||
'date' => $date,
|
'date' => $date,
|
||||||
'template' => $this->settings['bpnBookingUrlTemplateCode'],
|
'template' => $this->settings['bpnBookingUrlTemplateCode'],
|
||||||
'paCode' => $paCode,
|
'paCode' => GeneralUtility::_GET('pa'),
|
||||||
]);
|
]);
|
||||||
$hasSurchargeOrDiscount = $this->dateService->checkSurcharcheOrDiscount($priceTable);
|
$hasSurchargeOrDiscount = $this->dateService->checkSurcharcheOrDiscount($priceTable);
|
||||||
|
|
||||||
|
|||||||
+8
-17
@@ -1,4 +1,4 @@
|
|||||||
import { Controller } from 'stimulus'
|
import { Controller } from '@hotwired/stimulus'
|
||||||
import { useFetch } from '../mixins/use_fetch'
|
import { useFetch } from '../mixins/use_fetch'
|
||||||
import { useConfig } from '../mixins/use_config'
|
import { useConfig } from '../mixins/use_config'
|
||||||
|
|
||||||
@@ -13,8 +13,6 @@ export default class extends Controller {
|
|||||||
|
|
||||||
static values = {
|
static values = {
|
||||||
datestableUri: String,
|
datestableUri: String,
|
||||||
pricetableUri: String,
|
|
||||||
travelAlertUri: String,
|
|
||||||
loading: Boolean,
|
loading: Boolean,
|
||||||
loaded: Boolean,
|
loaded: Boolean,
|
||||||
mode: String,
|
mode: String,
|
||||||
@@ -53,13 +51,11 @@ export default class extends Controller {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
this.loadingValue = true
|
this.loadingValue = true
|
||||||
this.datesTableContainerTarget.innerHTML = ''
|
|
||||||
let paCode = this.getConfig().paCode
|
let paCode = this.getConfig().paCode
|
||||||
const data = new URLSearchParams()
|
const data = new URLSearchParams()
|
||||||
if (paCode) {
|
data.append('pa', paCode)
|
||||||
data.append('tx_epproducts_ajax[paCode]', paCode)
|
this.datesTableContainerTarget.innerHTML = ''
|
||||||
}
|
fetch(`${this.datestableUriValue}&${data}`)
|
||||||
fetch(this.datestableUriValue, { method: 'POST', body: data })
|
|
||||||
.then(this.checkStatus)
|
.then(this.checkStatus)
|
||||||
.then(this.parseHTML)
|
.then(this.parseHTML)
|
||||||
.then(html => {
|
.then(html => {
|
||||||
@@ -71,19 +67,14 @@ export default class extends Controller {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
loadPrices(e) {
|
loadPrices({ params }) {
|
||||||
this.loadingValue = true
|
this.loadingValue = true
|
||||||
this.priceTableContainerTarget.innerHTML = ''
|
this.priceTableContainerTarget.innerHTML = ''
|
||||||
this.modeValue = 'prices'
|
this.modeValue = 'prices'
|
||||||
let dateUid = e.currentTarget.dataset.dateUid
|
|
||||||
const data = new URLSearchParams({
|
|
||||||
'tx_epproducts_ajax[date]': dateUid,
|
|
||||||
})
|
|
||||||
let paCode = this.getConfig().paCode
|
let paCode = this.getConfig().paCode
|
||||||
if (paCode) {
|
const data = new URLSearchParams()
|
||||||
data.append('tx_epproducts_ajax[paCode]', paCode)
|
data.append('pa', paCode)
|
||||||
}
|
fetch(`${params.pricesUrl}&${data}`)
|
||||||
fetch(this.pricetableUriValue, { method: 'POST', body: data })
|
|
||||||
.then(this.checkStatus)
|
.then(this.checkStatus)
|
||||||
.then(this.parseHTML)
|
.then(this.parseHTML)
|
||||||
.then(html => {
|
.then(html => {
|
||||||
|
|||||||
Reference in New Issue
Block a user