Feat: Use GET to fetch tables via ajax to make use of cache
This commit is contained in:
+8
-17
@@ -1,4 +1,4 @@
|
||||
import { Controller } from 'stimulus'
|
||||
import { Controller } from '@hotwired/stimulus'
|
||||
import { useFetch } from '../mixins/use_fetch'
|
||||
import { useConfig } from '../mixins/use_config'
|
||||
|
||||
@@ -13,8 +13,6 @@ export default class extends Controller {
|
||||
|
||||
static values = {
|
||||
datestableUri: String,
|
||||
pricetableUri: String,
|
||||
travelAlertUri: String,
|
||||
loading: Boolean,
|
||||
loaded: Boolean,
|
||||
mode: String,
|
||||
@@ -53,13 +51,11 @@ export default class extends Controller {
|
||||
return
|
||||
}
|
||||
this.loadingValue = true
|
||||
this.datesTableContainerTarget.innerHTML = ''
|
||||
let paCode = this.getConfig().paCode
|
||||
const data = new URLSearchParams()
|
||||
if (paCode) {
|
||||
data.append('tx_epproducts_ajax[paCode]', paCode)
|
||||
}
|
||||
fetch(this.datestableUriValue, { method: 'POST', body: data })
|
||||
data.append('pa', paCode)
|
||||
this.datesTableContainerTarget.innerHTML = ''
|
||||
fetch(`${this.datestableUriValue}&${data}`)
|
||||
.then(this.checkStatus)
|
||||
.then(this.parseHTML)
|
||||
.then(html => {
|
||||
@@ -71,19 +67,14 @@ export default class extends Controller {
|
||||
})
|
||||
}
|
||||
|
||||
loadPrices(e) {
|
||||
loadPrices({ params }) {
|
||||
this.loadingValue = true
|
||||
this.priceTableContainerTarget.innerHTML = ''
|
||||
this.modeValue = 'prices'
|
||||
let dateUid = e.currentTarget.dataset.dateUid
|
||||
const data = new URLSearchParams({
|
||||
'tx_epproducts_ajax[date]': dateUid,
|
||||
})
|
||||
let paCode = this.getConfig().paCode
|
||||
if (paCode) {
|
||||
data.append('tx_epproducts_ajax[paCode]', paCode)
|
||||
}
|
||||
fetch(this.pricetableUriValue, { method: 'POST', body: data })
|
||||
const data = new URLSearchParams()
|
||||
data.append('pa', paCode)
|
||||
fetch(`${params.pricesUrl}&${data}`)
|
||||
.then(this.checkStatus)
|
||||
.then(this.parseHTML)
|
||||
.then(html => {
|
||||
|
||||
Reference in New Issue
Block a user