Commit 80e4426a authored by Andrew Nicols's avatar Andrew Nicols
Browse files

MDL-60516 calendar: Update mini calendar on course change

parent 84940517
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([
LOADING_ICON: '.loading-icon',
VIEW_DAY_LINK: "[data-action='view-day-link']",
CALENDAR_MONTH_WRAPPER: ".calendarwrapper",
COURSE_SELECTOR: 'select[name="course"]',
TODAY: '.today',
};
......@@ -268,13 +267,13 @@ define([
renderEventSummaryModal(eventId);
});
root.on('change', SELECTORS.COURSE_SELECTOR, function() {
root.on('change', CalendarSelectors.elements.courseSelector, function() {
var selectElement = $(this);
var courseId = selectElement.val();
CalendarViewManager.reloadCurrentMonth(root, courseId, null)
.then(function() {
// 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);
});
......
......@@ -69,10 +69,10 @@ function(
} else {
// The root has been removed.
// Remove all events in the namespace.
body.on(CalendarEvents.created + namespace);
body.on(CalendarEvents.deleted + namespace);
body.on(CalendarEvents.updated + namespace);
body.on(CalendarEvents.eventMoved + namespace);
body.off(CalendarEvents.created + namespace);
body.off(CalendarEvents.deleted + namespace);
body.off(CalendarEvents.updated + namespace);
body.off(CalendarEvents.eventMoved + namespace);
}
};
......@@ -82,6 +82,20 @@ function(
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 {
......
......@@ -47,6 +47,9 @@ define([], function() {
edit: '[data-action="edit"]',
remove: '[data-action="delete"]',
},
elements: {
courseSelector: 'select[name="course"]',
},
today: '.today',
day: '[data-region="day"]',
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