Skip to content

Commit

Permalink
MDL-59388 core_calendar: fix month view on clean theme
Browse files Browse the repository at this point in the history
  • Loading branch information
lameze committed Aug 16, 2017
1 parent a4af4c9 commit 836aa3f
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 30 deletions.
2 changes: 1 addition & 1 deletion calendar/amd/build/view_manager.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 3 additions & 6 deletions calendar/amd/src/view_manager.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ define(['jquery', 'core/templates', 'core/notification', 'core_calendar/reposito
var registerEventListeners = function(root) {
root = $(root);

$(root).on('click', SELECTORS.CALENDAR_NAV_LINK, function(e) {
root.on('click', SELECTORS.CALENDAR_NAV_LINK, function(e) {
var courseId = $(root).find(SELECTORS.CALENDAR_MONTH_WRAPPER).data('courseid');
var link = $(e.currentTarget);
changeMonth(link.attr('href'), link.data('time'), courseId);
Expand All @@ -58,16 +58,13 @@ define(['jquery', 'core/templates', 'core/notification', 'core_calendar/reposito
CalendarRepository.getCalendarMonthData(time, courseid)
.then(function(context) {
window.history.pushState({}, '', url);

return Templates.render('core_calendar/month_detailed', context);
})
.then(function(html, js) {
$(SELECTORS.CALENDAR_MONTH_WRAPPER).replaceWith(html);

return Templates.runTemplateJS(js);
return Templates.replaceNodeContents(SELECTORS.CALENDAR_MONTH_WRAPPER, html, js);
})
.done(function() {
$('body').trigger(CalendarEvents.monthChanged, []);
$('body').trigger(CalendarEvents.monthChanged, [time, courseid]);
})
.fail(Notification.exception);
};
Expand Down
2 changes: 1 addition & 1 deletion calendar/classes/external/day_exporter.php
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ protected static function define_other_properties() {
'optional' => true,
],
'events' => [
'type' => event_exporter::read_properties_definition(),
'type' => calendar_event_exporter::read_properties_definition(),
'multiple' => true,
]
];
Expand Down
2 changes: 0 additions & 2 deletions calendar/externallib.php
Original file line number Diff line number Diff line change
Expand Up @@ -857,8 +857,6 @@ public static function get_calendar_monthly_view($time, $courseid) {
global $CFG, $DB, $USER, $PAGE;
require_once($CFG->dirroot."/calendar/lib.php");

$warnings = [];

// Parameter validation.
$params = self::validate_parameters(self::get_calendar_monthly_view_parameters(), [
'time' => $time,
Expand Down
22 changes: 4 additions & 18 deletions calendar/lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -3424,7 +3424,7 @@ function calendar_get_legacy_events($tstart, $tend, $users, $groups, $courses, $


/**
* Get theh calendar view output.
* Get the calendar view output.
*
* @param \calendar_information $calendar The calendar being represented
* @param string $view The type of calendar to have displayed
Expand Down Expand Up @@ -3507,23 +3507,9 @@ function ($event) {
'cache' => new \core_calendar\external\events_related_objects_cache($events),
];

if ($view === 'upcoming') {
$defaultlookahead = CALENDAR_DEFAULT_UPCOMING_LOOKAHEAD;
if (isset($CFG->calendar_lookahead)) {
$defaultlookahead = intval($CFG->calendar_lookahead);
}
$lookahead = get_user_preferences('calendar_lookahead', $defaultlookahead);

$defaultmaxevents = CALENDAR_DEFAULT_UPCOMING_MAXEVENTS;
if (isset($CFG->calendar_maxevents)) {
$defaultmaxevents = intval($CFG->calendar_maxevents);
}
$maxevents = get_user_preferences('calendar_maxevents', $defaultmaxevents);
} else {
$month = new \core_calendar\external\month_exporter($calendar, $type, $related);
$data = $month->export($renderer);
$template = 'core_calendar/month_detailed';
}
$month = new \core_calendar\external\month_exporter($calendar, $type, $related);
$data = $month->export($renderer);
$template = 'core_calendar/month_detailed';

return [$data, $template];
}
Expand Down
4 changes: 2 additions & 2 deletions calendar/templates/month_detailed.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
<span class="calendarwrapper" data-courseid="{{courseid}}">
{{> core_calendar/month_header }}
{{> core_calendar/month_navigation }}
<table class="calendarmonth calendartable table card-deck m-b-0">
<table class="calendarmonth calendartable card-deck m-b-0">
<thead>
<tr>
{{# daynames }}
Expand Down Expand Up @@ -79,7 +79,7 @@
</ul>
{{/events.0}}
</div>
<div class="hidden-md-up">
<div class="hidden-md-up hidden-desktop">
{{#events.0}}
<a href="{{viewdaylink}}" class="day" title="{{viewdaylinktitle}}">{{mday}}</a>
{{/events.0}}
Expand Down

0 comments on commit 836aa3f

Please sign in to comment.