Repository navigation
Conversation
…lnode#254) A per-event-type setting, off by default, adds a button above the time list that opens the soonest free day. Worked out from the free slots only, bounded by max_future_days, and silent on a failed or degraded check. Shown on the booking and reschedule pages; the embed widget is left for a follow-up.
|
All contributors have signed the CLA. ✅ |
|
I have read the CLA Document and I hereby sign the CLA |
There was a problem hiding this comment.
Important
The new button's label renders as the literal string next_available_hint on every non-English locale. t() on both pages is I18N[key] || key, and I18N is loc.JSON() — the resolved locale's strings only, with no English merge — so the missing key surfaces on the page instead of falling back to English.
Approach: sound — one opt-in column threaded through create/PATCH/duplicate and both server-rendered surfaces, with the search itself in the shared, unit-tested booking-logic.js rather than reimplemented per page, and the embed widget deferred until it can load that module.
Reviewed changes
- Setting and API — migration 00073 (
DEFAULT 0, mirroring 00057), the shared column list and row scan, create and PATCH, the duplicate copy, and the admin type/checkbox withen/frcopy. - Booking and reschedule pages —
loadNextAvailableon both surfaces, the desktop/mobile pair of buttons,booking.css, and the one new public i18n key. - Shared helpers and tests —
earliestFreeSlot,monthsToProbeand six node tests, plus Go tests for the opt-in round-trip and for both pages' markup. - Docs — CHANGELOG entry and the ARCHITECTURE subsection beside the booked-times one.
deepseek-v4.1-flash | 𝕏
| "date_picker_aria": "Date picker", | ||
| "timezone_aria": "Timezone", | ||
| "select_day_hint": "Select a day to see available times.", | ||
| "next_available_hint": "Next available: %[1]s, %[2]s", |
There was a problem hiding this comment.
next_available_hint is only added here, and the page-side t() is I18N[key] || key with I18N built from loc.JSON() — the resolved locale's strings alone, no English merge. So on every other shipped catalogue the button shows the literal text next_available_hint; the Locale.T English fallback that makes partial locales safe is server-side only and does not extend to this blob.
Technical details
# Add `next_available_hint` to every locale file
## Affected sites
- `internal/i18n/locales/en.json:13` — the only file carrying the key
- missing from `de.json`, `de-x-neutral.json`, `el.json`, `es.json`, `fr.json`, `fr-CA.json`, `it.json`, `nl.json`, `pl.json`, `pt.json`, `sv.json`
- consumers: `internal/handler/templates/book.html:869` and `manage.html:579` (`BookingLogic.fmt(t('next_available_hint'), […])`); `t` falls back to the key, and `fmt` has no verbs to replace in the key, so the raw string is what lands in `textContent`
## Required outcome
Every locale file has the key, with the `%[1]s, %[2]s` indices preserved so a translation can reorder the day and the time.
## Suggested approach
LLM drafts are the repo convention for non-English files, so one pass over the 11 files is enough; alternatively the page could merge English into `I18NJSON`, but that is a cross-cutting change to every public-surface key and not worth doing inside this PR.| function earliestFreeSlot(slots, tz, excludeStart) { | ||
| var best = null; | ||
| (slots || []).forEach(function (s) { | ||
| if (excludeStart && s.start === excludeStart) return; |
There was a problem hiding this comment.
excludeStart is compared as a raw string, but /slots returns starts formatted in the request's timezone (slotJSON.Start = s.Start.Format(time.RFC3339), slots_handler.go:326), so they carry an offset, while CURRENT_ISO comes from b.StartAt.UTC().Format(time.RFC3339) and ends in Z. Outside a UTC browser the two can never be equal, so the reschedule exclusion the PR describes is inert today — the booking's own start stays out of the list only because bookings are counted as busy upstream.
Technical details
# Compare instants, not strings, when excluding a slot
## Affected sites
- `internal/handler/assets/booking-logic.js:76` — `s.start === excludeStart`
- `internal/handler/templates/manage.html:576` — the caller that relies on it (`earliestFreeSlot(data.slots, TZ, CURRENT_ISO)`)
- `internal/handler/assets/booking-logic.js:35` — `groupSlotsByDay` has the same comparison; pre-existing, same failure mode
## Required outcome
The excluded start is dropped regardless of the offset spelling the server chose, and a test with mixed offsets (`Z` vs `-04:00`) pins it.
## Suggested approach
`if (excludeStart && Date.parse(s.start) === Date.parse(excludeStart)) return;` — the same argument `mergeDaySlots` above already makes for sorting ("slot times carry a UTC offset"). The existing tests only pass `Z` on both sides, which is why they do not catch this.| // ── Init ────────────────────────────────────────────────────────────────── | ||
| populateTzSelect(); | ||
| loadMonthAvailability(navYear, navMonth); | ||
| loadNextAvailable(); |
There was a problem hiding this comment.
This fires a /slots request for the same month, with the same from/to/tz, two lines after loadMonthAvailability already requested it — so an opted-in event type doubles the cost of the heaviest public endpoint on every page view, and adds a further serial probe per month when the current one has nothing. Seeding the probe from the month the calendar already fetched would avoid the duplicate; manage.html:604 and manage.html:726 have the same overlap.
Technical details
# Avoid re-fetching the month the calendar already has
## Affected sites
- `internal/handler/templates/book.html:899` — `loadNextAvailable()` right after `loadMonthAvailability(navYear, navMonth)` (`:898`); also the tz-change handler at `:888` then `:889`
- `internal/handler/templates/manage.html:604` and `:726` — same pairing
## Required outcome
One `/slots` request per month range per load, not two, while keeping the "silent on failure/degraded" behaviour.
## Suggested approach
Have `loadNextAvailable` consume the already-cached `slotsByDay`/`availabilityLoaded` result for the visible month before probing later months, or have both callers await one shared in-flight promise per `(from, to, tz)`.
Adds an opt-in
show_next_availableevent type setting, default off. When on, a button above the time list shows the soonest free time, such as "Next available: Wed, Dec 9, 10:00 AM", and opens that day when clicked. This is the change agreed in #254.How it follows the points raised there:
event_type_duplicate.go, and a checkbox in the event type editor next to the booked-times one.maxDate, so it cannot run pastmax_future_days.degradedresponse shows nothing./slots. The page only formats, with the existing formatters. A timezone change restarts the search.<button>, styled like a time button inbooking.css.earliestFreeSlotandmonthsToProbeare inbooking-logic.jswith unit tests.next_available_hint. The admin strings areenandfr.book.htmlandmanage.htmlchange together. On the reschedule page the booking's own current time is left out, so it offers the next time the booking could move to.booking-logic.js, so it needs its own mirrored copy.On narrow screens the calendar step hides the right column, so a second copy of the button sits above the calendar there, and
booking.cssshows one at a time.ARCHITECTURE.mdhas a new subsection beside the booked-times one, and the CHANGELOG has an entry.Checked:
go test ./...,go vet ./...andgofmt -l .are clean.node --test internal/handler/assets/booking-logic.test.js: 20 pass.pnpm check,pnpm check:i18nandpnpm buildpass.pnpm test:visual(no change to the ui components,app.cssor the theme) and the embed widget (untouched).