Commit 78511321 authored by David Monllaó's avatar David Monllaó
Browse files

Merge branch 'MDL-60516-master' of git://github.com/andrewnicols/moodle

parents 4f7a8034 80e4426a
File suppressed by a .gitattributes entry or the file's encoding is unsupported.
File suppressed by a .gitattributes entry or the file's encoding is unsupported.
File suppressed by a .gitattributes entry or the file's encoding is unsupported.
...@@ -70,7 +70,6 @@ define([ ...@@ -70,7 +70,6 @@ define([
LOADING_ICON: '.loading-icon', LOADING_ICON: '.loading-icon',
VIEW_DAY_LINK: "[data-action='view-day-link']", VIEW_DAY_LINK: "[data-action='view-day-link']",
CALENDAR_MONTH_WRAPPER: ".calendarwrapper", CALENDAR_MONTH_WRAPPER: ".calendarwrapper",
COURSE_SELECTOR: 'select[name="course"]',
TODAY: '.today', TODAY: '.today',
}; };
...@@ -268,13 +267,13 @@ define([ ...@@ -268,13 +267,13 @@ define([
renderEventSummaryModal(eventId); renderEventSummaryModal(eventId);
}); });
root.on('change', SELECTORS.COURSE_SELECTOR, function() { root.on('change', CalendarSelectors.elements.courseSelector, function() {
var selectElement = $(this); var selectElement = $(this);
var courseId = selectElement.val(); var courseId = selectElement.val();
CalendarViewManager.reloadCurrentMonth(root, courseId, null) CalendarViewManager.reloadCurrentMonth(root, courseId, null)
.then(function() { .then(function() {
// We need to get the selector again because the content has changed. // We need to get the selector again because the content has changed.
return root.find(SELECTORS.COURSE_SELECTOR).val(courseId); return root.find(CalendarSelectors.elements.courseSelector).val(courseId);
}) })
.fail(Notification.exception); .fail(Notification.exception);
}); });
......
...@@ -69,10 +69,10 @@ function( ...@@ -69,10 +69,10 @@ function(
} else { } else {
// The root has been removed. // The root has been removed.
// Remove all events in the namespace. // Remove all events in the namespace.
body.on(CalendarEvents.created + namespace); body.off(CalendarEvents.created + namespace);
body.on(CalendarEvents.deleted + namespace); body.off(CalendarEvents.deleted + namespace);
body.on(CalendarEvents.updated + namespace); body.off(CalendarEvents.updated + namespace);
body.on(CalendarEvents.eventMoved + namespace); body.off(CalendarEvents.eventMoved + namespace);
} }
}; };
...@@ -82,6 +82,20 @@ function( ...@@ -82,6 +82,20 @@ function(
daysWithEvent.toggleClass('calendar_event_' + data.type, !data.hidden); daysWithEvent.toggleClass('calendar_event_' + data.type, !data.hidden);
}); });
var namespace = '.' + root.attr('id');
$('body').on('change' + namespace, CalendarSelectors.elements.courseSelector, function() {
if (root.is(':visible')) {
var selectElement = $(this);
var courseId = selectElement.val();
var categoryId = null;
CalendarViewManager.reloadCurrentMonth(root, courseId, categoryId);
} else {
$('body').off('change' + namespace);
}
});
}; };
return { return {
......
...@@ -47,6 +47,9 @@ define([], function() { ...@@ -47,6 +47,9 @@ define([], function() {
edit: '[data-action="edit"]', edit: '[data-action="edit"]',
remove: '[data-action="delete"]', remove: '[data-action="delete"]',
}, },
elements: {
courseSelector: 'select[name="course"]',
},
today: '.today', today: '.today',
day: '[data-region="day"]', day: '[data-region="day"]',
wrapper: '.calendarwrapper', wrapper: '.calendarwrapper',
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment