Skip to content

Commit abf089f

Browse files
author
David Monllao
committed
Merge branch 'MDL-60967-master' of git://github.com/ryanwyllie/moodle
2 parents 174fbac + 60908b2 commit abf089f

11 files changed

+68
-9
lines changed

calendar/amd/build/calendar_threemonth.min.js

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

calendar/amd/build/repository.min.js

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

calendar/amd/build/view_manager.min.js

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

calendar/amd/src/calendar_threemonth.js

+1
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ function(
7171
var placeHolder = $('<span>');
7272
placeHolder.attr('data-template', 'core_calendar/threemonth_month');
7373
placeHolder.attr('data-includenavigation', false);
74+
placeHolder.attr('data-mini', true);
7475
var placeHolderContainer = $('<div>');
7576
placeHolderContainer.hide();
7677
placeHolderContainer.append(placeHolder);

calendar/amd/src/repository.js

+3-1
Original file line numberDiff line numberDiff line change
@@ -95,9 +95,10 @@ define(['jquery', 'core/ajax'], function($, Ajax) {
9595
* @param {Number} courseid The course id.
9696
* @param {Number} categoryid The category id.
9797
* @param {Bool} includenavigation Whether to include navigation.
98+
* @param {Bool} mini Whether the month is in mini view.
9899
* @return {promise} Resolved with the month view data.
99100
*/
100-
var getCalendarMonthData = function(year, month, courseid, categoryid, includenavigation) {
101+
var getCalendarMonthData = function(year, month, courseid, categoryid, includenavigation, mini) {
101102
var request = {
102103
methodname: 'core_calendar_get_calendar_monthly_view',
103104
args: {
@@ -106,6 +107,7 @@ define(['jquery', 'core/ajax'], function($, Ajax) {
106107
courseid: courseid,
107108
categoryid: categoryid,
108109
includenavigation: includenavigation,
110+
mini: mini
109111
}
110112
};
111113

calendar/amd/src/view_manager.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,8 @@ define([
121121

122122
M.util.js_pending([root.get('id'), year, month, courseid].join('-'));
123123
var includenavigation = root.data('includenavigation');
124-
return CalendarRepository.getCalendarMonthData(year, month, courseid, categoryid, includenavigation)
124+
var mini = root.data('mini');
125+
return CalendarRepository.getCalendarMonthData(year, month, courseid, categoryid, includenavigation, mini)
125126
.then(function(context) {
126127
return Templates.render(root.attr('data-template'), context);
127128
})

calendar/classes/external/month_exporter.php

+22-1
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,11 @@ class month_exporter extends exporter {
6464
*/
6565
protected $initialeventsloaded = true;
6666

67+
/**
68+
* @var bool $showcoursefilter Whether to render the course filter selector as well.
69+
*/
70+
protected $showcoursefilter = false;
71+
6772
/**
6873
* Constructor for month_exporter.
6974
*
@@ -120,6 +125,7 @@ protected static function define_other_properties() {
120125
],
121126
'filter_selector' => [
122127
'type' => PARAM_RAW,
128+
'optional' => true,
123129
],
124130
'weeks' => [
125131
'type' => week_exporter::read_properties_definition(),
@@ -206,7 +212,6 @@ protected function get_other_values(renderer_base $output) {
206212

207213
$return = [
208214
'courseid' => $this->calendar->courseid,
209-
'filter_selector' => $this->get_course_filter_selector($output),
210215
'weeks' => $this->get_weeks($output),
211216
'daynames' => $this->get_day_names($output),
212217
'view' => 'month',
@@ -224,6 +229,10 @@ protected function get_other_values(renderer_base $output) {
224229
'initialeventsloaded' => $this->initialeventsloaded,
225230
];
226231

232+
if ($this->showcoursefilter) {
233+
$return['filter_selector'] = $this->get_course_filter_selector($output);
234+
}
235+
227236
if ($context = $this->get_default_add_context()) {
228237
$return['defaulteventcontext'] = $context->id;
229238
}
@@ -405,6 +414,18 @@ public function set_initialeventsloaded(bool $loaded) {
405414
return $this;
406415
}
407416

417+
/**
418+
* Set whether the course filter selector should be shown.
419+
*
420+
* @param bool $show
421+
* @return $this
422+
*/
423+
public function set_showcoursefilter(bool $show) {
424+
$this->showcoursefilter = $show;
425+
426+
return $this;
427+
}
428+
408429
/**
409430
* Get the default context for use when adding a new event.
410431
*

calendar/externallib.php

+12-2
Original file line numberDiff line numberDiff line change
@@ -945,9 +945,10 @@ public static function submit_create_update_form_returns() {
945945
* @param int $courseid The course to be included
946946
* @param int $categoryid The category to be included
947947
* @param bool $includenavigation Whether to include navigation
948+
* @param bool $mini Whether to return the mini month view or not
948949
* @return array
949950
*/
950-
public static function get_calendar_monthly_view($year, $month, $courseid, $categoryid, $includenavigation) {
951+
public static function get_calendar_monthly_view($year, $month, $courseid, $categoryid, $includenavigation, $mini) {
951952
global $CFG, $DB, $USER, $PAGE;
952953
require_once($CFG->dirroot."/calendar/lib.php");
953954

@@ -958,6 +959,7 @@ public static function get_calendar_monthly_view($year, $month, $courseid, $cate
958959
'courseid' => $courseid,
959960
'categoryid' => $categoryid,
960961
'includenavigation' => $includenavigation,
962+
'mini' => $mini,
961963
]);
962964

963965
$context = \context_user::instance($USER->id);
@@ -970,7 +972,8 @@ public static function get_calendar_monthly_view($year, $month, $courseid, $cate
970972
$calendar = \calendar_information::create($time, $params['courseid'], $params['categoryid']);
971973
self::validate_context($calendar->context);
972974

973-
list($data, $template) = calendar_get_view($calendar, 'month', $params['includenavigation']);
975+
$view = $params['mini'] ? 'mini' : 'month';
976+
list($data, $template) = calendar_get_view($calendar, $view, $params['includenavigation']);
974977

975978
return $data;
976979
}
@@ -994,6 +997,13 @@ public static function get_calendar_monthly_view_parameters() {
994997
true,
995998
NULL_ALLOWED
996999
),
1000+
'mini' => new external_value(
1001+
PARAM_BOOL,
1002+
'Whether to return the mini month view or not',
1003+
VALUE_DEFAULT,
1004+
false,
1005+
NULL_ALLOWED
1006+
),
9971007
]
9981008
);
9991009
}

calendar/lib.php

+1
Original file line numberDiff line numberDiff line change
@@ -3490,6 +3490,7 @@ function ($event) {
34903490
$month = new \core_calendar\external\month_exporter($calendar, $type, $related);
34913491
$month->set_includenavigation($includenavigation);
34923492
$month->set_initialeventsloaded(!$skipevents);
3493+
$month->set_showcoursefilter($view == "month");
34933494
$data = $month->export($renderer);
34943495
} else if ($view == "day") {
34953496
$day = new \core_calendar\external\calendar_day_exporter($calendar, $related);

0 commit comments

Comments
 (0)