Permalink
Browse files

Merge branch 'MDL-60967-master' of git://github.com/ryanwyllie/moodle

  • Loading branch information...
dmonllao committed Jan 16, 2018
2 parents 174fbac + 60908b2 commit abf089f2a30e7c691f025ac4c639d85821793649

Some generated files are not rendered by default. Learn more.

Oops, something went wrong.

Some generated files are not rendered by default. Learn more.

Oops, something went wrong.

Some generated files are not rendered by default. Learn more.

Oops, something went wrong.
@@ -71,6 +71,7 @@ function(
var placeHolder = $('<span>');
placeHolder.attr('data-template', 'core_calendar/threemonth_month');
placeHolder.attr('data-includenavigation', false);
placeHolder.attr('data-mini', true);
var placeHolderContainer = $('<div>');
placeHolderContainer.hide();
placeHolderContainer.append(placeHolder);
@@ -95,9 +95,10 @@ define(['jquery', 'core/ajax'], function($, Ajax) {
* @param {Number} courseid The course id.
* @param {Number} categoryid The category id.
* @param {Bool} includenavigation Whether to include navigation.
* @param {Bool} mini Whether the month is in mini view.
* @return {promise} Resolved with the month view data.
*/
var getCalendarMonthData = function(year, month, courseid, categoryid, includenavigation) {
var getCalendarMonthData = function(year, month, courseid, categoryid, includenavigation, mini) {
var request = {
methodname: 'core_calendar_get_calendar_monthly_view',
args: {
@@ -106,6 +107,7 @@ define(['jquery', 'core/ajax'], function($, Ajax) {
courseid: courseid,
categoryid: categoryid,
includenavigation: includenavigation,
mini: mini
}
};
@@ -121,7 +121,8 @@ define([
M.util.js_pending([root.get('id'), year, month, courseid].join('-'));
var includenavigation = root.data('includenavigation');
return CalendarRepository.getCalendarMonthData(year, month, courseid, categoryid, includenavigation)
var mini = root.data('mini');
return CalendarRepository.getCalendarMonthData(year, month, courseid, categoryid, includenavigation, mini)
.then(function(context) {
return Templates.render(root.attr('data-template'), context);
})
@@ -64,6 +64,11 @@ class month_exporter extends exporter {
*/
protected $initialeventsloaded = true;
/**
* @var bool $showcoursefilter Whether to render the course filter selector as well.
*/
protected $showcoursefilter = false;
/**
* Constructor for month_exporter.
*
@@ -120,6 +125,7 @@ protected static function define_other_properties() {
],
'filter_selector' => [
'type' => PARAM_RAW,
'optional' => true,
],
'weeks' => [
'type' => week_exporter::read_properties_definition(),
@@ -206,7 +212,6 @@ protected function get_other_values(renderer_base $output) {
$return = [
'courseid' => $this->calendar->courseid,
'filter_selector' => $this->get_course_filter_selector($output),
'weeks' => $this->get_weeks($output),
'daynames' => $this->get_day_names($output),
'view' => 'month',
@@ -224,6 +229,10 @@ protected function get_other_values(renderer_base $output) {
'initialeventsloaded' => $this->initialeventsloaded,
];
if ($this->showcoursefilter) {
$return['filter_selector'] = $this->get_course_filter_selector($output);
}
if ($context = $this->get_default_add_context()) {
$return['defaulteventcontext'] = $context->id;
}
@@ -405,6 +414,18 @@ public function set_initialeventsloaded(bool $loaded) {
return $this;
}
/**
* Set whether the course filter selector should be shown.
*
* @param bool $show
* @return $this
*/
public function set_showcoursefilter(bool $show) {
$this->showcoursefilter = $show;
return $this;
}
/**
* Get the default context for use when adding a new event.
*
@@ -945,9 +945,10 @@ public static function submit_create_update_form_returns() {
* @param int $courseid The course to be included
* @param int $categoryid The category to be included
* @param bool $includenavigation Whether to include navigation
* @param bool $mini Whether to return the mini month view or not
* @return array
*/
public static function get_calendar_monthly_view($year, $month, $courseid, $categoryid, $includenavigation) {
public static function get_calendar_monthly_view($year, $month, $courseid, $categoryid, $includenavigation, $mini) {
global $CFG, $DB, $USER, $PAGE;
require_once($CFG->dirroot."/calendar/lib.php");
@@ -958,6 +959,7 @@ public static function get_calendar_monthly_view($year, $month, $courseid, $cate
'courseid' => $courseid,
'categoryid' => $categoryid,
'includenavigation' => $includenavigation,
'mini' => $mini,
]);
$context = \context_user::instance($USER->id);
@@ -970,7 +972,8 @@ public static function get_calendar_monthly_view($year, $month, $courseid, $cate
$calendar = \calendar_information::create($time, $params['courseid'], $params['categoryid']);
self::validate_context($calendar->context);
list($data, $template) = calendar_get_view($calendar, 'month', $params['includenavigation']);
$view = $params['mini'] ? 'mini' : 'month';
list($data, $template) = calendar_get_view($calendar, $view, $params['includenavigation']);
return $data;
}
@@ -994,6 +997,13 @@ public static function get_calendar_monthly_view_parameters() {
true,
NULL_ALLOWED
),
'mini' => new external_value(
PARAM_BOOL,
'Whether to return the mini month view or not',
VALUE_DEFAULT,
false,
NULL_ALLOWED
),
]
);
}
@@ -3490,6 +3490,7 @@ function ($event) {
$month = new \core_calendar\external\month_exporter($calendar, $type, $related);
$month->set_includenavigation($includenavigation);
$month->set_initialeventsloaded(!$skipevents);
$month->set_showcoursefilter($view == "month");
$data = $month->export($renderer);
} else if ($view == "day") {
$day = new \core_calendar\external\calendar_day_exporter($calendar, $related);
Oops, something went wrong.

0 comments on commit abf089f

Please sign in to comment.