core_calendar/modal_quick_add_event

Contain the logic for the quick add or update event modal.

Source:
License:
  • http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later

Methods

(inner) disableButtons()

Source:

Disable the buttons in the footer.

(inner) enableButtons()

Source:

Enable the buttons in the footer.

(inner) getCategoryId() → {int|null}

Source:

Retrieve the current category id, if any.

Returns:

The event id

Type
int | null

(inner) getContextId() → {Number|null}

Source:

Retrieve the current context id, if any.

Returns:

The event id

Type
Number | null

(inner) getCourseId() → {int|null}

Source:

Retrieve the current course id, if any.

Returns:

The event id

Type
int | null

(inner) getEventId() → {int|null}

Source:

Retrieve the current event id, if any.

Returns:

The event id

Type
int | null

(inner) getForm() → {object}

Source:

Get the form element from the modal.

Returns:
Type
object

(inner) getFormData() → {string}

Source:

Get the serialised form data.

Returns:

serialised form data

Type
string

(inner) getStartTime() → {int|null}

Source:

Retrieve the current start time, if any.

Returns:

The start time

Type
int | null

(inner) hasCategoryId() → {bool}

Source:

Check if the modal has an category id.

Returns:
Type
bool

(inner) hasCourseId() → {bool}

Source:

Check if the modal has an course id.

Returns:
Type
bool

(inner) hasEventId() → {bool}

Source:

Check if the modal has an event id.

Returns:
Type
bool

(inner) hasStartTime() → {bool}

Source:

Check if the modal has start time.

Returns:
Type
bool

(inner) hide()

Source:

Clear the event id from the modal when it's closed so that it is loaded fresh next time it's displayed.

The event id will be set by the calling code if it wants to edit a specific event.

(inner) registerEventListeners()

Source:

Set up all of the event handling for the modal.

Fires:
  • event:uploadStarted
  • event:formSubmittedByJavascript

(inner) reloadAllContent() → {object}

Source:

Reload both the title and body content.

Returns:

promise

Type
object

(inner) reloadBodyContent(formData) → {object}

Source:

Send a request to the server to get the event_form in a fragment and render the result in the body of the modal.

If serialised form data is provided then it will be sent in the request to the server to have the form rendered with the data. This is used when the form had a server side error and we need the server to re-render it for us to display the error to the user.

Parameters:
Name Type Description
formData string

The serialised form data

Returns:

A promise resolved with the fragment html and js from

Type
object

(inner) reloadTitleContent() → {object}

Source:

Reload the title for the modal to the appropriate value depending on whether we are creating a new event or editing an existing event.

Returns:

A promise resolved with the new title text

Type
object

(inner) save() → {object}

Source:

Send the form data to the server to create or update an event.

If there is a server side validation error then we re-request the rendered form (with the data) from the server in order to get the server side errors to display.

On success the modal is hidden and the page is reloaded so that the new event will display.

Returns:

A promise

Type
object

(inner) setCategoryId(id)

Source:

Set the category id to the given value.

Parameters:
Name Type Description
id int

The event id

(inner) setContextId(id)

Source:

Set the context id to the given value.

Parameters:
Name Type Description
id Number

The event id

(inner) setCourseId(id)

Source:

Set the course id to the given value.

Parameters:
Name Type Description
id int

The event id

(inner) setEventId(id)

Source:

Set the event id to the given value.

Parameters:
Name Type Description
id int

The event id

(inner) setStartTime(time)

Source:

Set the start time to the given value.

Parameters:
Name Type Description
time int

The start time

(inner) show()

Source:

Kick off a reload the modal content before showing it. This is to allow us to re-use the same modal for creating and editing different events within the page.

We do the reload when showing the modal rather than hiding it to save a request to the server if the user closes the modal and never re-opens it.