Merge branch 'MDL-59753-master' of git://github.com/lameze/moodle
authorEloy Lafuente (stronk7) <stronk7@moodle.org>
Tue, 5 Sep 2017 11:28:53 +0000 (13:28 +0200)
committerDavid Monllao <davidm@moodle.com>
Thu, 7 Sep 2017 08:53:32 +0000 (10:53 +0200)
calendar/amd/build/calendar.min.js
calendar/amd/build/view_manager.min.js
calendar/amd/src/calendar.js
calendar/amd/src/view_manager.js
calendar/renderer.php

index a96ce0b..aac1c29 100644 (file)
Binary files a/calendar/amd/build/calendar.min.js and b/calendar/amd/build/calendar.min.js differ
index cb96bd8..d502824 100644 (file)
Binary files a/calendar/amd/build/view_manager.min.js and b/calendar/amd/build/view_manager.min.js differ
index 8a74ee4..947bac0 100644 (file)
@@ -65,7 +65,8 @@ define([
         DAY_CONTENT: "[data-region='day-content']",
         LOADING_ICON: '.loading-icon',
         VIEW_DAY_LINK: "[data-action='view-day-link']",
-        CALENDAR_MONTH_WRAPPER: ".calendarwrapper"
+        CALENDAR_MONTH_WRAPPER: ".calendarwrapper",
+        COURSE_SELECTOR: 'select[name="course"]'
     };
 
     /**
@@ -317,6 +318,17 @@ define([
             renderEventSummaryModal(eventId);
         });
 
+        root.on('change', SELECTORS.COURSE_SELECTOR, function() {
+            var selectElement = $(this);
+            var courseId = selectElement.val();
+            CalendarViewManager.reloadCurrentMonth(root, courseId)
+                .then(function() {
+                    // We need to get the selector again because the content has changed.
+                    return root.find(SELECTORS.COURSE_SELECTOR).val(courseId);
+                })
+                .fail(Notification.exception);
+        });
+
         var eventFormPromise = registerEventFormModal(root);
         registerCalendarEventListeners(root, eventFormPromise);
 
index 836b011..5604d6e 100644 (file)
@@ -96,13 +96,17 @@ define(['jquery', 'core/templates', 'core/notification', 'core_calendar/reposito
         /**
          * Reload the current month view data.
          *
+         * @param {object} root The container element.
+         * @param {Number} courseId The course id.
          * @return {promise}
          */
-        var reloadCurrentMonth = function(root) {
-            var courseid = root.find(SELECTORS.CALENDAR_MONTH_WRAPPER).data('courseid'),
-                time = root.find(SELECTORS.CALENDAR_MONTH_WRAPPER).data('current-time');
+        var reloadCurrentMonth = function(root, courseId) {
+            var time = root.find(SELECTORS.CALENDAR_MONTH_WRAPPER).data('current-time');
 
-            return refreshMonthContent(time, courseid);
+            if (!courseId) {
+                courseId = root.find(SELECTORS.CALENDAR_MONTH_WRAPPER).data('courseid');
+            }
+            return refreshMonthContent(time, courseId);
         };
 
         /**
index e3cc6fc..1818234 100644 (file)
@@ -389,14 +389,15 @@ class core_calendar_renderer extends plugin_renderer_base {
         }
         $courseurl = new moodle_url($returnurl);
         $courseurl->remove_params('course');
-        $select = new single_select($courseurl, 'course', $courseoptions, $selected, null);
-        $select->class = 'm-r-1';
-        if ($label !== null) {
-            $select->set_label($label);
-        } else {
-            $select->set_label(get_string('listofcourses'), array('class' => 'accesshide'));
+
+        if ($label === null) {
+            $label = get_string('listofcourses');
         }
-        return $this->output->render($select);
+
+        $select = html_writer::label($label, 'course', false, ['class' => 'm-r-1']);
+        $select .= html_writer::select($courseoptions, 'course', $selected, false, ['class' => 'cal_courses_flt']);
+
+        return $select;
     }
 
     /**