CoolCMS API

ModalTrait

Modal window of the wizard (the booking form and the calendar on the "my time slots" page).

IMPORTANT: a front modal is not an admin modal. It runs through ModalRegistry (session) + ModalWindowEvents and the Front\System\Components\ModalWindow(s) components, like ModalTrait.

There is one modal, not two stacked. ModalWindows.latte puts data-naja-snippet-append on the inner #modals-container, while Naja looks for the flag on the snippet element itself, so the whole container is replaced, not appended. Opening a second modal would redraw the first one too, and ModalWindow marks show only the one that just got update(); the first would disappear. Therefore the second modal replaces the content of the first one (ModalRegistry::update() + ModalWindowEvents::UPDATE) and the way back is the backToCalendar! arrow. It is also the only variant that never mixes two DOM elements with the same id after reopening.

Table of Contents

Constants

MODAL_TARGET  : string = 'companyBookingWizardModal'
The only target of the wizard modal; the calendar and the form share the same window.

Methods

handleBackToCalendar()  : void
Back arrow from the booking form to the calendar (modal mode only).
handleShowCalendarModal()  : void
Handles the "book a time slot" button on the "my time slots" page: opens the wizard (month grid) in a modal window. From now on the component is in modal mode and all its links carry it in the persistent `inModal`.
createFormContent()  : string
Second view: recap + booking form.
createModalEvent()  : ModalWindowEvent
createResultContent()  : string
Second view after submit: the result message instead of the form (the form is no longer offered).
createWizardContent()  : string
First view: the same wizard (header + month/day) as in inline mode, rendered into a string.
openOrUpdateModal()  : void
Opens the modal or, when it already exists in the registry, only replaces its content.
refreshWizardView()  : void
Redraws the wizard after a navigation signal: in inline mode through the `wizard` snippet, in modal mode by replacing the modal content.
renderPartial()  : string
Renders a partial into a string (like `WatchdogFormComponent\Traits\ModalTrait`).

Constants

MODAL_TARGET

The only target of the wizard modal; the calendar and the form share the same window.

private string MODAL_TARGET = 'companyBookingWizardModal'

Methods

handleBackToCalendar()

Back arrow from the booking form to the calendar (modal mode only).

public handleBackToCalendar() : void

handleShowCalendarModal()

Handles the "book a time slot" button on the "my time slots" page: opens the wizard (month grid) in a modal window. From now on the component is in modal mode and all its links carry it in the persistent `inModal`.

public handleShowCalendarModal() : void

createFormContent()

Second view: recap + booking form.

private createFormContent() : string
Return values
string

createModalEvent()

private createModalEvent(string $content[, array<string, mixed> $extraOptions = [] ]) : ModalWindowEvent
Parameters
$content : string
$extraOptions : array<string, mixed> = []
Return values
ModalWindowEvent

createResultContent()

Second view after submit: the result message instead of the form (the form is no longer offered).

private createResultContent() : string
Return values
string

createWizardContent()

First view: the same wizard (header + month/day) as in inline mode, rendered into a string.

private createWizardContent() : string
Return values
string

openOrUpdateModal()

Opens the modal or, when it already exists in the registry, only replaces its content.

private openOrUpdateModal(string $content) : void

IMPORTANT: the distinction is required. ADDED redraws the whole modal container, which would drop the Bootstrap instance of an already open window; UPDATE touches only the modalBody snippet, so the window stays open and only its inside changes (flash inside the modal plus a redrawn calendar).

Parameters
$content : string

refreshWizardView()

Redraws the wizard after a navigation signal: in inline mode through the `wizard` snippet, in modal mode by replacing the modal content.

private refreshWizardView() : void

renderPartial()

Renders a partial into a string (like `WatchdogFormComponent\Traits\ModalTrait`).

private renderPartial(string $file, string $errorMessageKey) : string

A template failure must not crash the request; the modal shows a message instead of the content.

Parameters
$file : string
$errorMessageKey : string
Return values
string
On this page

Search results