feat: availability calendar in the product detail sidebar is back

TYPO3 10 showed a "Belegungskalender" in the sidebar of every product
with a calendar hotel. It was dropped when the price calendar arrived,
and the price calendar is limited to summer products, so winter
products showed no availability at all.

The sidebar calendar is shown for products with a calendar hotel that
are not summer products. AjaxCalendar::availability reads the
availability from MyE&P (contingents/availability, as the iCal feed
does) instead of bpn-connect, and renders all months in one cacheable
response; the month select only switches between them. Months with
prices in the price config (summer, covered by the price calendar) are
left out. If the price config is unavailable, all months are shown
without caching.

The plain availability-* classes are safelisted in Tailwind: they were
only kept on TYPO3 10 because the ContingentViewHelper named them, and
the class names are now built in the controller.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
frommeandClaude Opus 5.5 committed 2026-10-29 14:03:59 +01:00
1 parent c63cbdd3a6
commit 5d41660a9a
6 files changed
+204 -60

No files matched your search

@@ -1,68 +1,16 @@
import { Controller } from '@hotwired/stimulus'
import { useFetch } from '../mixins/use_fetch'
export default class extends Controller {
static targets = [
'container',
'field',
'loadingIndicator',
'month',
]
static values = {
loading: Boolean,
uri: String,
hotelUid: Number,
}
initialize() {
useFetch(this)
}
connect() {
let months = []
let today = new Date()
let year = today.getFullYear()
let month = today.getMonth()
for (let i = 0; i < 20; i++) {
let selectableDate = new Date(year, month, 1)
months.push(selectableDate)
if (month < 12) {
month++
} else {
month = 1
year++
}
this.fieldTarget.options[i] = new Option(selectableDate.toLocaleDateString('de-DE', {year: 'numeric', month: 'long'}), i.toString())
}
this.selectableMonths = months
this.load(0)
}
select(e) {
let selectedIndex = e.currentTarget.value
this.load(selectedIndex)
}
load(selectedIndex) {
this.loadingValue = true
let selectedMonth = this.selectableMonths[selectedIndex]
let data = new URLSearchParams()
data.set('tx_epproducts_ajax[hotel]', this.hotelUidValue)
data.set('tx_epproducts_ajax[month]', selectedMonth.getMonth() + 1)
data.set('tx_epproducts_ajax[year]', selectedMonth.getFullYear())
fetch(this.uriValue, { method: 'POST', body: data })
.then(this.checkStatus)
.then(this.parseHTML)
.then(html => (
this.containerTarget.innerHTML = html
))
.finally(() => {
this.loadingValue = false
})
}
loadingValueChanged() {
this.loadingIndicatorTarget.classList.toggle('hidden', this.loadingValue === false)
select() {
const selectedIndex = parseInt(this.fieldTarget.value, 10)
this.monthTargets.forEach((month, index) => {
month.classList.toggle('hidden', index !== selectedIndex)
})
}
}