From 5f6ff89549c560655a5ca1b48511aac65fcbc635 Mon Sep 17 00:00:00 2001 From: Ryan Wyllie Date: Fri, 7 Apr 2017 06:29:15 +0000 Subject: [PATCH] MDL-58536 block_myoverview: use moodle user timezone for midnight calc Pass the user's midnight timestamp to the javascript to ensure that a user's timezone is respected when calculating the categories the events should be placed in on the event list. --- blocks/myoverview/amd/build/event_list.min.js | 2 +- .../amd/build/event_list_by_course.min.js | 2 +- blocks/myoverview/amd/src/event_list.js | 20 +++++++++---------- .../amd/src/event_list_by_course.js | 8 ++++---- blocks/myoverview/classes/output/main.php | 1 + .../templates/course-event-list.mustache | 1 + .../myoverview/templates/event-list.mustache | 1 + 7 files changed, 18 insertions(+), 17 deletions(-) diff --git a/blocks/myoverview/amd/build/event_list.min.js b/blocks/myoverview/amd/build/event_list.min.js index 7ebbaf32a39..cdc315e0ed1 100644 --- a/blocks/myoverview/amd/build/event_list.min.js +++ b/blocks/myoverview/amd/build/event_list.min.js @@ -1 +1 @@ -define(["jquery","core/notification","core/templates","core/custom_interaction_events","block_myoverview/calendar_events_repository"],function(a,b,c,d,e){var f=86400,g={EMPTY_MESSAGE:'[data-region="empty-message"]',ROOT:'[data-region="event-list-container"]',EVENT_LIST:'[data-region="event-list"]',EVENT_LIST_CONTENT:'[data-region="event-list-content"]',EVENT_LIST_GROUP_CONTAINER:'[data-region="event-list-group-container"]',LOADING_ICON_CONTAINER:'[data-region="loading-icon-container"]',VIEW_MORE_BUTTON:'[data-action="view-more"]'},h={EVENT_LIST_ITEMS:"block_myoverview/event-list-items",COURSE_EVENT_LIST_ITEMS:"block_myoverview/course-event-list-items"},i=function(a){a.attr("data-loaded-all",!0)},j=function(a){return!!a.attr("data-loaded-all")},k=function(a){var b=a.find(g.LOADING_ICON_CONTAINER),c=a.find(g.VIEW_MORE_BUTTON);a.addClass("loading"),b.removeClass("hidden"),c.prop("disabled",!0)},l=function(a){var b=a.find(g.LOADING_ICON_CONTAINER),c=a.find(g.VIEW_MORE_BUTTON);a.removeClass("loading"),b.addClass("hidden"),j(a)||c.prop("disabled",!1)},m=function(a){return a.hasClass("loading")},n=function(a){a.attr("data-has-events",!0)},o=function(a){return!!a.attr("data-has-events")},p=function(a,b){b?n(a):o(a)||q(a)},q=function(a){a.find(g.EVENT_LIST_CONTENT).addClass("hidden"),a.find(g.EMPTY_MESSAGE).removeClass("hidden")},r=function(a,b,d){return a.removeClass("hidden"),c.render(d,{events:b}).done(function(b,d){c.appendNodeContents(a.find(g.EVENT_LIST),b,d)})},s=function(a,b){var c=b.timesort||0;return c-a},t=function(a,b){var c=Math.floor((new Date).setHours(0,0,0,0)/1e3),d=+b.attr("data-start-day")*f,e=+b.attr("data-end-day")*f,g=s(c,a);return""===b.attr("data-end-day")?d<=g:d<=g&&gimage_url('activities', 'block_myoverview')->out(); return [ + 'midnight' => usergetmidnight(time()), 'coursesview' => $coursesview->export_for_template($output), 'urls' => [ 'nocourses' => $nocoursesurl, diff --git a/blocks/myoverview/templates/course-event-list.mustache b/blocks/myoverview/templates/course-event-list.mustache index 77cf57cbf9f..ac16e44b91a 100644 --- a/blocks/myoverview/templates/course-event-list.mustache +++ b/blocks/myoverview/templates/course-event-list.mustache @@ -28,6 +28,7 @@ data-limit="{{$limit}}20{{/limit}}" data-course-id="{{$courseid}}{{/courseid}}" data-last-id="{{$lastid}}{{/lastid}}" + data-midnight="{{midnight}}" id="event-list-container-{{$courseid}}{{/courseid}}">
diff --git a/blocks/myoverview/templates/event-list.mustache b/blocks/myoverview/templates/event-list.mustache index 83f62347ac4..ae5553bdf8a 100644 --- a/blocks/myoverview/templates/event-list.mustache +++ b/blocks/myoverview/templates/event-list.mustache @@ -27,6 +27,7 @@ data-limit="{{$limit}}20{{/limit}}" data-course-id="{{$courseid}}{{/courseid}}" data-last-id="{{$lastid}}{{/lastid}}" + data-midnight="{{midnight}}" id="event-list-container-{{$courseid}}{{/courseid}}">