Proyectos de Subversion Moodle

Rev

Rev 1 | Mostrar el archivo completo | | | Autoría | Ultima modificación | Ver Log |

Rev 1 Rev 11
Línea 31... Línea 31...
31
    'core_calendar/repository',
31
    'core_calendar/repository',
32
    'core_calendar/events',
32
    'core_calendar/events',
33
    'core_calendar/view_manager',
33
    'core_calendar/view_manager',
34
    'core_calendar/crud',
34
    'core_calendar/crud',
35
    'core_calendar/selectors',
35
    'core_calendar/selectors',
36
    'core/config',
-
 
37
    'core/url',
36
    'core/url',
38
    'core/str',
37
    'core/str',
39
],
38
],
40
function(
39
function(
41
    $,
40
    $,
Línea 44... Línea 43...
44
    CalendarRepository,
43
    CalendarRepository,
45
    CalendarEvents,
44
    CalendarEvents,
46
    CalendarViewManager,
45
    CalendarViewManager,
47
    CalendarCrud,
46
    CalendarCrud,
48
    CalendarSelectors,
47
    CalendarSelectors,
49
    Config,
-
 
50
    Url,
48
    Url,
51
    Str,
49
    Str,
52
) {
50
) {
Línea 53... Línea 51...
53
 
51
 
Línea 169... Línea 167...
169
 
167
 
170
    /**
168
    /**
171
     * Register event listeners for the module.
169
     * Register event listeners for the module.
172
     *
170
     *
-
 
171
     * @param {object} root The calendar root element
173
     * @param {object} root The calendar root element
172
     * @param {boolean} isCalendarBlock - A flag indicating whether this is a calendar block.
174
     */
173
     */
175
    var registerEventListeners = function(root) {
174
    var registerEventListeners = function(root, isCalendarBlock) {
176
        const viewingFullCalendar = document.getElementById(CalendarSelectors.fullCalendarView);
175
        const viewingFullCalendar = document.getElementById(CalendarSelectors.fullCalendarView);
177
        // Listen the click on the day link to render the day view.
176
        // Listen the click on the day link to render the day view.
178
        root.on('click', SELECTORS.VIEW_DAY_LINK, function(e) {
177
        root.on('click', SELECTORS.VIEW_DAY_LINK, function(e) {
179
            var dayLink = $(e.target).closest(SELECTORS.VIEW_DAY_LINK);
178
            var dayLink = $(e.target).closest(SELECTORS.VIEW_DAY_LINK);
Línea 191... Línea 190...
191
                // Construct the URL parameter string from the urlParams object.
190
                // Construct the URL parameter string from the urlParams object.
192
                const urlParamString = Object.entries(urlParams)
191
                const urlParamString = Object.entries(urlParams)
193
                    .map(([key, value]) => `${encodeURIComponent(key)}=${encodeURIComponent(value)}`)
192
                    .map(([key, value]) => `${encodeURIComponent(key)}=${encodeURIComponent(value)}`)
194
                    .join('&');
193
                    .join('&');
195
                CalendarViewManager.refreshDayContent(root, year, month, day, courseId, categoryId, root,
194
                CalendarViewManager.refreshDayContent(root, year, month, day, courseId, categoryId, root,
196
                    'core_calendar/calendar_day').then(function() {
195
                    'core_calendar/calendar_day', isCalendarBlock).then(function() {
197
                    e.preventDefault();
196
                    e.preventDefault();
-
 
197
                    // Update the URL if it's not calendar block.
-
 
198
                    if (!isCalendarBlock) {
198
                    return CalendarViewManager.updateUrl(urlParamString);
199
                        CalendarViewManager.updateUrl('?' + urlParamString);
-
 
200
                    }
-
 
201
                    return;
199
                }).catch(Notification.exception);
202
                }).catch(Notification.exception);
200
            } else {
203
            } else {
201
                window.location.assign(Url.relativeUrl('calendar/view.php', urlParams));
204
                window.location.assign(Url.relativeUrl('calendar/view.php', urlParams));
202
            }
205
            }
203
        });
206
        });
Línea 264... Línea 267...
264
            });
267
            });
265
        }
268
        }
266
    };
269
    };
Línea 267... Línea 270...
267
 
270
 
-
 
271
    return {
-
 
272
        /**
-
 
273
         * Initializes the calendar view manager and registers event listeners.
-
 
274
         *
-
 
275
         * @param {HTMLElement} root - The root element where the calendar view manager and event listeners will be attached.
-
 
276
         * @param {boolean} [isCalendarBlock=false] - A flag indicating whether this is a calendar block.
268
    return {
277
         */
269
        init: function(root) {
278
        init: function(root, isCalendarBlock = false) {
270
            root = $(root);
279
            root = $(root);
271
            CalendarViewManager.init(root);
280
            CalendarViewManager.init(root, 'month', isCalendarBlock);
272
            registerEventListeners(root);
281
            registerEventListeners(root, isCalendarBlock);
273
        }
282
        }
274
    };
283
    };