Merge pull request 'Collapse the lesson-type filter behind a Show Only button' (#120) from feature/lesson-type-filter-collapsed into main
CI / No Debug Code (push) Successful in 2s
CI / Tests (PHP 8.2) (push) Successful in 46s
CI / Tests (PHP 8.1) (push) Successful in 53s
CI / PHPStan (push) Successful in 2m56s
CI / Coding Standards (push) Successful in 2m58s
CI / Tests (PHP 8.3) (push) Successful in 2m42s
CI / Build Plugin Zip (push) Successful in 2m48s
Release / Build and Publish Release (push) Successful in 2m49s
Release / Open next-version bump PR (push) Successful in 4s
CI / No Debug Code (push) Successful in 2s
CI / Tests (PHP 8.2) (push) Successful in 46s
CI / Tests (PHP 8.1) (push) Successful in 53s
CI / PHPStan (push) Successful in 2m56s
CI / Coding Standards (push) Successful in 2m58s
CI / Tests (PHP 8.3) (push) Successful in 2m42s
CI / Build Plugin Zip (push) Successful in 2m48s
Release / Build and Publish Release (push) Successful in 2m49s
Release / Open next-version bump PR (push) Successful in 4s
Reviewed-on: #120
This commit was merged in pull request #120.
This commit is contained in:
@@ -50,7 +50,7 @@ either as an agenda-style list grouped by day or as a **weekly calendar** with
|
||||
previous/next-week navigation (toggle rendered by `assets/js/booking.js`; the
|
||||
site's `start_of_week` option is passed through the `usScheduler` JS config).
|
||||
Both views can be narrowed to the slots bookable as chosen private-lesson types
|
||||
with the lesson-type filter — see `lesson-booking.md`.
|
||||
with the **Show Only** lesson-type filter — see `lesson-booking.md`.
|
||||
|
||||
## REST API
|
||||
| Method | Endpoint | Permission |
|
||||
|
||||
@@ -27,6 +27,9 @@ Four blocks have sidebar (inspector) options:
|
||||
|---|---|---|---|
|
||||
| `us-scheduler/booking` | `loginPageId` (number) | `0` | Page the "log in to book a lesson" link points to for logged-out visitors. `0` = the WordPress login screen (with a redirect back to the current page). |
|
||||
| `us-scheduler/booking` | `autoRedirect` (boolean) | `false` | Send logged-out visitors straight to the login page instead of showing the link. |
|
||||
| `us-scheduler/booking` | `lessonTypeId` (number) | `0` | Pin the calendar to a single private-lesson type: only the times bookable as that type are listed, and it is the only type students can book here (auto-selected on the registration form). `0` = every type. Shortcode equivalent: `[us_booking lesson_type="…"]`. |
|
||||
| `us-scheduler/booking` | `showTypeFilter` (boolean) | `true` | Whether students get the **Show Only** button that narrows the calendar to chosen lesson types. Unused when a single type is pinned (there is nothing to choose). Shortcode equivalent: `[us_booking show_filter="no"]`. |
|
||||
| `us-scheduler/booking` | `displayMode` (string) | `both` | Which halves of the page to embed: `both`, `booking` (calendar only, no upcoming-lessons panel) or `upcoming` (the student's lessons only, nothing bookable) — so the two halves can live on different pages. Anything unrecognised falls back to `both`. Shortcode equivalent: `[us_booking show="booking"]`. |
|
||||
| `us-scheduler/student-login` | `bookingPageId` (number) | `0` | Page the "View available lessons" link points to for logged-in visitors, and the post-login redirect target. `0` = the current page. |
|
||||
| `us-scheduler/student-login` | `autoRedirect` (boolean) | `false` | Send logged-in visitors straight to the booking page instead of showing the link. Does nothing until a booking page is chosen. |
|
||||
| `us-scheduler/student-register` | `loginPageId` (number) | `0` | Page students continue to once registration finishes — the "Sign in to your account" link after they confirm their email, and the "Continue to your account" link an invited student gets on the spot. `0` = the WordPress login screen for the confirmation link, and no link at all for the (already signed-in) invited student. Shortcode equivalent: `[us_student_register login_page_id="…"]`. |
|
||||
@@ -38,7 +41,15 @@ the blocks fall back to their defaults. The group-classes block's class
|
||||
select is a dropdown of active group classes fetched from
|
||||
`GET /us-scheduler/v1/offerings?kind=group_class`; a stored class that is no
|
||||
longer offered shows as "Unavailable class #N" rather than silently falling
|
||||
back to all classes. The link targets are also available
|
||||
back to all classes. The booking block's lesson-type select works the same way
|
||||
against `?kind=private_lesson` ("Unavailable lesson type #N"), and the live
|
||||
page says so plainly when the pinned type has been withdrawn.
|
||||
|
||||
The booking block's options reach the front end as data attributes on
|
||||
`#us-booking-app` (`data-lesson-type`, `data-type-filter`) or as omitted
|
||||
containers (`displayMode`), which `assets/js/booking.js` reads on load — see
|
||||
`lesson-booking.md`. Its editor preview follows `displayMode`, showing the
|
||||
calendar, the upcoming-lessons panel, or both. The link targets are also available
|
||||
to the shortcodes as `[us_booking login_page_id="…"]` and
|
||||
`[us_student_login booking_page_id="…"]`; auto-redirect is block-only.
|
||||
|
||||
|
||||
@@ -20,7 +20,7 @@ Students register for a private lesson by choosing an offering, picking a time (
|
||||
| `created_at` | DATETIME | Insertion time |
|
||||
|
||||
## Registration Flow
|
||||
1. Student opens the page with the `[us_booking]` shortcode and browses open slots as a weekly calendar (the default, anchored to the week of the earliest open slot) or an agenda list (view toggle with previous/next-week navigation; times shown in 12-hour AM/PM form). A **lesson-type filter** above the calendar narrows the open times to those bookable as the chosen types (see **Lesson-Type Filter**).
|
||||
1. Student opens the page with the `[us_booking]` shortcode and browses open slots as a weekly calendar (the default, anchored to the week of the earliest open slot) or an agenda list (view toggle with previous/next-week navigation; times shown in 12-hour AM/PM form). A **Show Only** button beside the view toggle opens a lesson-type filter that narrows the open times to those bookable as the chosen types (see **Lesson-Type Filter**).
|
||||
2. Student picks a slot and an **offering** (a 30 or 60-minute private-lesson type). When the slot is tied to an offering the form shows it locked (the student sees exactly what they are booking); otherwise the form presents the instructor's active private-lesson offerings whose duration fits the slot, narrowed to the filtered types. When exactly one type remains it is pre-selected (its intake questions load immediately). Every booking requires an offering — a generic slot with no fitting offering cannot be booked online.
|
||||
3. For a `weekly` reservation, the same weekday/time is held for the rest of the offering's term.
|
||||
4. Student answers the offering's questions (`GET /offerings/{id}/questions`).
|
||||
@@ -34,18 +34,23 @@ Students register for a private lesson by choosing an offering, picking a time (
|
||||
## Lesson-Type Filter
|
||||
Not every open slot can be booked as every private-lesson type — a slot tied to
|
||||
an offering takes that offering only, and a generic slot only takes types whose
|
||||
length fits. The booking calendar therefore carries a lesson-type filter above
|
||||
the view toggle: a checkbox per active private-lesson type (from
|
||||
length fits. The booking calendar therefore carries a lesson-type filter,
|
||||
collapsed behind a **Show Only** button that sits in the calendar's control row
|
||||
beside the List/Week toggle. Opening it reveals the type list between that row
|
||||
and the calendar: a checkbox per active private-lesson type (from
|
||||
`GET /offerings?kind=private_lesson`, fetched once per page load), showing the
|
||||
instructor's name alongside the title when the catalog spans more than one
|
||||
instructor. The filter is hidden when there is only one bookable type.
|
||||
instructor. The button carries the number of ticked types and stays highlighted
|
||||
while the filter is on, so a collapsed filter is never invisible. Both button and
|
||||
list are hidden when there is only one bookable type.
|
||||
|
||||
Ticking one or more types narrows the calendar to the slots bookable as one of
|
||||
them; no ticks means no filter. Picking a filtered slot narrows the registration
|
||||
form's **Lesson type** picker the same way, and when exactly one type remains it
|
||||
is pre-selected and its intake questions load immediately. Changing the filter
|
||||
re-anchors the week view on the earliest matching slot, so the student never
|
||||
lands on an empty week. **Show all types** clears the filter.
|
||||
them; no ticks means no filter, and collapsing the list leaves the filter
|
||||
applied. Picking a filtered slot narrows the registration form's **Lesson type**
|
||||
picker the same way, and when exactly one type remains it is pre-selected and its
|
||||
intake questions load immediately. Changing the filter re-anchors the week view
|
||||
on the earliest matching slot, so the student never lands on an empty week.
|
||||
**Show all types** clears the filter.
|
||||
|
||||
Bookability is decided client-side by `offeringFitsSlot()` in
|
||||
`assets/js/booking.js` — the mirror of the rule `POST /bookings` enforces (same
|
||||
@@ -53,6 +58,28 @@ instructor, the tied offering when there is one, otherwise a matching
|
||||
`duration_minutes`). The filter is a browsing aid only: the server re-checks
|
||||
every booking regardless.
|
||||
|
||||
Two block/shortcode options change what the filter has to work with (see
|
||||
`editor-blocks.md`), passed to the script as data attributes on
|
||||
`#us-booking-app`:
|
||||
|
||||
- **A pinned lesson type** (`data-lesson-type`) narrows the catalog to that one
|
||||
offering, so the page lists only the times bookable as it and books nothing
|
||||
else — the filter control hides itself, there being one type left. A pinned
|
||||
type that is no longer offered shows "This lesson type is not available for
|
||||
booking right now" rather than an empty calendar.
|
||||
- **Filter off** (`data-type-filter="0"`) drops the **Show Only** button
|
||||
entirely; every open time is listed, as before the filter existed.
|
||||
|
||||
## Embedding Halves of the Page
|
||||
The page has two halves — the booking calendar and the student's upcoming
|
||||
lessons — and the block/shortcode can embed either on its own (`displayMode` /
|
||||
`show`: `both` (default), `booking`, `upcoming`). The template simply omits the
|
||||
containers of the half that is not wanted, and the script skips the work that
|
||||
belongs to a missing container: an upcoming-only embed never requests
|
||||
availability or the offering catalog, and a booking-only embed never requests
|
||||
`GET /bookings`. An unrecognised value renders the whole page, so a typo cannot
|
||||
silently hide half of it.
|
||||
|
||||
## Cancellation
|
||||
Students cancel their own lessons via `POST /bookings/{id}/cancel` (idempotent).
|
||||
Cancelling marks the lesson `cancelled`, frees the availability slot for
|
||||
@@ -115,7 +142,7 @@ acceptance time and IP), and their intake-question answers. On **My Lessons** an
|
||||
instructor may only open their own lessons; the studio **Scheduler** may open any.
|
||||
|
||||
## Frontend Shortcodes
|
||||
- `[us_booking]` — student calendar + registration flow; requires `book_lesson` capability
|
||||
- `[us_booking]` — student calendar + registration flow; requires `book_lesson` capability. Attributes: `login_page_id`, `lesson_type` (pin one private-lesson offering), `show_filter` (`no` hides the **Show Only** filter), `show` (`both` / `booking` / `upcoming`)
|
||||
- `[us_student_login]` — front-end login form for students
|
||||
|
||||
## Implementation
|
||||
|
||||
Reference in New Issue
Block a user