MDL-59388 core_calendar: fix month view on clean theme

This commit is contained in:
Simey Lameze 2017-08-08 13:11:42 +08:00
parent a4af4c9633
commit 836aa3f64a
6 changed files with 11 additions and 30 deletions

View File

@ -1 +1 @@
define(["jquery","core/templates","core/notification","core_calendar/repository","core_calendar/events"],function(a,b,c,d,e){var f={ROOT:"[data-region='calendar']",CALENDAR_NAV_LINK:"span.calendarwrapper .arrow_link",CALENDAR_MONTH_WRAPPER:".calendarwrapper"},g=function(b){b=a(b),a(b).on("click",f.CALENDAR_NAV_LINK,function(c){var d=a(b).find(f.CALENDAR_MONTH_WRAPPER).data("courseid"),e=a(c.currentTarget);h(e.attr("href"),e.data("time"),d),c.preventDefault()})},h=function(g,h,i){d.getCalendarMonthData(h,i).then(function(a){return window.history.pushState({},"",g),b.render("core_calendar/month_detailed",a)}).then(function(c,d){return a(f.CALENDAR_MONTH_WRAPPER).replaceWith(c),b.runTemplateJS(d)}).done(function(){a("body").trigger(e.monthChanged,[])}).fail(c.exception)};return{init:function(){g(f.ROOT)}}});
define(["jquery","core/templates","core/notification","core_calendar/repository","core_calendar/events"],function(a,b,c,d,e){var f={ROOT:"[data-region='calendar']",CALENDAR_NAV_LINK:"span.calendarwrapper .arrow_link",CALENDAR_MONTH_WRAPPER:".calendarwrapper"},g=function(b){b=a(b),b.on("click",f.CALENDAR_NAV_LINK,function(c){var d=a(b).find(f.CALENDAR_MONTH_WRAPPER).data("courseid"),e=a(c.currentTarget);h(e.attr("href"),e.data("time"),d),c.preventDefault()})},h=function(g,h,i){d.getCalendarMonthData(h,i).then(function(a){return window.history.pushState({},"",g),b.render("core_calendar/month_detailed",a)}).then(function(a,c){return b.replaceNodeContents(f.CALENDAR_MONTH_WRAPPER,a,c)}).done(function(){a("body").trigger(e.monthChanged,[h,i])}).fail(c.exception)};return{init:function(){g(f.ROOT)}}});

View File

@ -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);
@ -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);
};

View File

@ -95,7 +95,7 @@ class day_exporter extends exporter {
'optional' => true,
],
'events' => [
'type' => event_exporter::read_properties_definition(),
'type' => calendar_event_exporter::read_properties_definition(),
'multiple' => true,
]
];

View File

@ -857,8 +857,6 @@ class core_calendar_external extends external_api {
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,

View File

@ -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
@ -3507,23 +3507,9 @@ function calendar_get_view(\calendar_information $calendar, $view) {
'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];
}

View File

@ -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 }}
@ -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}}