Problem/Motivation

I came across the problem raised in this issue #1275686: FullCalendar drag-and-drop doesn't trigger node_validate() whilst working on a project recently. I solved it in my own plugin with a custom dropEvent callback as I had other advanced functionality I needed to implement. However had my requirement just been to use Resource Conflict to prevent conflicting event times some kind of hook in fullcalendar_update to validate and abort the node/entity_save would have been perfect.

Fullcalendar is a calendar and as such deals with events, it also allows for the editing of event via the drag/drop interface. I imagine a desire to prevent time/date conflicts of events is not uncommon and can easily be done using Resource Conflict via the standard add/edit form, this should also be possible when updating via fullcalendar.

Proposed resolution

The patch below provides a hook_fullcalendar_event_update_validate() that allows modules to modify the entity that is being updated and/or provide a veto response that would abort the entity/node_save.

Following on the ajax reponse includes 'success' or 'error' status that is used to apply a corresponding class to the fullcalendar-status div and also a corresponding message to be used.

Another approach was to check for Resource Conflict and run the entity through the two functions provided by this module to get this information. I did not feel this was a very flexible solution.

Remaining tasks

This patch does not allow for custom or multiple 'error' or 'success' messages to be returned by modules. Ideally all messages from all modules should be returned and displayed for user information.

The API documentation will likely need work.

This is a proof of concept to find out what everyone thinks of this approach.

User interface changes

A new message for 'error' status displayed to calendar user.

API changes

New hook addded hook_fullcalendar_event_update_validate(). This does not affect any current installations.

Original report by [username]

N/A

Comments

Status:Active» Needs work
StatusFileSize
new3.88 KB