-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Fix(planning): Avoid double AJAX call to get_events on FullCalendar initiazation #19462
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: 10.0/bugfixes
Are you sure you want to change the base?
Fix(planning): Avoid double AJAX call to get_events on FullCalendar initiazation #19462
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See #16439, the lines you removed prevent a fatal error when the current view is invalid (e.g. a view from a plugin that was since disabled).
If you want to improve this, maybe the options could be checked on the PHP side. |
A verification on the PHP side is not possible because the $PLUGIN_HOOKS['planning_scheduler_key']['advancedplanning'] = function () {
return 'GPL-My-Project-Is-Open-Source';
}; GLPI (on the PHP side) has no knowledge of which JavaScript plugins are effectively loaded. Furthermore, plugin names often differ from the view types used by the user. For instance, the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Indeed !! I did a small refactor. I removed the use of The idea is to handle the view only after initialization. If the requested view is valid, it will be applied. Otherwise, it will fall back to the default view. |
It seems to me that with the changes, If |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See last comment.
last commit should solve the problems |
The latest commit also removes code that caused the get_events AJAX endpoint to be called twice. // Save the original datesRender function, which is later overwritten by the "selectable" option
const originalDatesRender = GLPIPlanning.calendar.getOption('datesRender');
GLPIPlanning.calendar.setOption('selectable', false);
window.setTimeout(function() {
GLPIPlanning.calendar.setOption('selectable', true);
originalDatesRender(info); // Restore datesRender
}, 500); This code was only intended to temporarily disable and then re-enable date selection controls. However, the current implementation (since #19184) triggered a duplicate call to
Since events are added via a modal, the date selection controls aren't accessible at that point. |
Checklist before requesting a review
Please delete options that are not relevant.
Description
During the plugin initialization, we observe two AJAX calls made to load events.
The first one results from the calendar initialization,
while the second is triggered by the computation and loading of the last default view.
trigger by this
This second call is redundant, as the default view has already been computed server-side (in PHP) and does not need to be reloaded / check on the client side.
Screenshots (if appropriate):