MDL-58301 block_myoverview: Show overdue items in Timeline

Part of MDL-55611 epic.
This commit is contained in:
Andrew Nicols 2017-03-21 10:53:47 +08:00 committed by Damyon Wiese
parent 7737c79792
commit 5e52a8a9fc
8 changed files with 40 additions and 10 deletions

View File

@ -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 e?d<=g&&g<e:d<=g},u=function(b){return function(c){return t(c,a(b))}},v=function(b,c){var d=0,e=h.EVENT_LIST_ITEMS;return b.attr("data-course-id")&&(e=h.COURSE_EVENT_LIST_ITEMS),a.when.apply(a,a.map(b.find(g.EVENT_LIST_GROUP_CONTAINER),function(b){var f=c.filter(u(b));return f.length?(d+=f.length,r(a(b),f,e)):null})).then(function(){return d})},w=function(c,d){c=a(c);var f=+c.attr("data-limit"),g=+c.attr("data-course-id"),h=c.attr("data-last-id"),j=new Date,n=Math.floor(j.setHours(0,0,0,0)/1e3);if(m(c))return a.Deferred().resolve();if(k(c),"undefined"==typeof d){var o={starttime:n,limit:f};h&&(o.aftereventid=h),g?(o.courseid=g,d=e.queryByCourse(o)):d=e.queryByTime(o)}return d.then(function(a){return a.events}).then(function(a){return(!a.length||a.length<f)&&i(c),a.length?(c.attr("data-last-id",a[a.length-1].id),v(c,a).then(function(b){p(c,a.length),b<a.length&&i(c)})):void p(c,a.length)}).fail(b.exception).always(function(){l(c)})},x=function(a){d.define(a,[d.events.activate]),a.on(d.events.activate,g.VIEW_MORE_BUTTON,function(){w(a)})};return{init:function(b){b=a(b),w(b),x(b)},registerEventListeners:x,load:w,rootSelector:g.ROOT}});
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&&g<e},u=function(b){return function(c){return t(c,a(b))}},v=function(b,c){var d=0,e=h.EVENT_LIST_ITEMS;return b.attr("data-course-id")&&(e=h.COURSE_EVENT_LIST_ITEMS),a.when.apply(a,a.map(b.find(g.EVENT_LIST_GROUP_CONTAINER),function(b){var f=c.filter(u(b));return f.length?(d+=f.length,r(a(b),f,e)):null})).then(function(){return d})},w=function(c,d){c=a(c);var f,g=+c.attr("data-limit"),h=+c.attr("data-course-id"),j=c.attr("data-last-id"),n=new Date;if(n.setDate(n.getDate()-14),n.setHours(0,0,0,0),f=Math.floor(n/1e3),m(c))return a.Deferred().resolve();if(k(c),"undefined"==typeof d){var o={starttime:f,limit:g};j&&(o.aftereventid=j),h?(o.courseid=h,d=e.queryByCourse(o)):d=e.queryByTime(o)}return d.then(function(a){return a.events}).then(function(a){return(!a.length||a.length<g)&&i(c),a.length?(c.attr("data-last-id",a[a.length-1].id),v(c,a).then(function(b){p(c,a.length),b<a.length&&i(c)})):void p(c,a.length)}).fail(b.exception).always(function(){l(c)})},x=function(a){d.define(a,[d.events.activate]),a.on(d.events.activate,g.VIEW_MORE_BUTTON,function(){w(a)})};return{init:function(b){b=a(b),w(b),x(b)},registerEventListeners:x,load:w,rootSelector:g.ROOT}});

View File

@ -1 +1 @@
define(["jquery","block_myoverview/event_list","block_myoverview/calendar_events_repository"],function(a,b,c){var d={EVENTS_BY_COURSE_CONTAINER:'[data-region="course-events-container"]'},e=function(e){var f=e.find(d.EVENTS_BY_COURSE_CONTAINER);if(f.length){var g=new Date,h=Math.floor(g.setHours(0,0,0,0)/1e3),i=f.attr("data-limit"),j=f.map(function(){return a(this).attr("data-course-id")}).get(),k=c.queryByCourses({courseids:j,starttime:h,limit:i});f.each(function(c,d){d=a(d);var e=d.attr("data-course-id"),f=d.find(b.rootSelector),g=a.Deferred();k.done(function(a){var b=[],c=a.groupedbycourse.filter(function(a){return a.courseid==e});c.length&&(b=c[0].events),g.resolve({events:b})}).fail(function(a){g.reject(a)}),b.load(f,g)})}};return{init:function(b){b=a(b),e(b)}}});
define(["jquery","block_myoverview/event_list","block_myoverview/calendar_events_repository"],function(a,b,c){var d={EVENTS_BY_COURSE_CONTAINER:'[data-region="course-events-container"]'},e=function(e){var f=e.find(d.EVENTS_BY_COURSE_CONTAINER);if(f.length){var g=new Date;g.setDate(g.getDate()-14),g.setHours(0,0,0,0);var h=Math.floor(g/1e3),i=f.attr("data-limit"),j=f.map(function(){return a(this).attr("data-course-id")}).get(),k=c.queryByCourses({courseids:j,starttime:h,limit:i});f.each(function(c,d){d=a(d);var e=d.attr("data-course-id"),f=d.find(b.rootSelector),g=a.Deferred();k.done(function(a){var b=[],c=a.groupedbycourse.filter(function(a){return a.courseid==e});c.length&&(b=c[0].events),g.resolve({events:b})}).fail(function(a){g.reject(a)}),b.load(f,g)})}};return{init:function(b){b=a(b),e(b)}}});

View File

@ -230,7 +230,7 @@ define(['jquery', 'core/notification', 'core/templates',
timeUntilContainerEnd = +container.attr('data-end-day') * SECONDS_IN_DAY,
timeUntilEventNeedsAction = timeUntilEvent(todayTime, event);
if (!timeUntilContainerEnd) {
if (container.attr('data-end-day') === '') {
return timeUntilContainerStart <= timeUntilEventNeedsAction;
} else {
return timeUntilContainerStart <= timeUntilEventNeedsAction &&
@ -313,7 +313,11 @@ define(['jquery', 'core/notification', 'core/templates',
courseId = +root.attr('data-course-id'),
lastId = root.attr('data-last-id'),
date = new Date(),
todayTime = Math.floor(date.setHours(0, 0, 0, 0) / 1000);
startTime;
date.setDate(date.getDate() - 14);
date.setHours(0, 0, 0, 0);
startTime = Math.floor(date / 1000);
// Don't load twice.
if (isLoading(root)) {
@ -326,7 +330,7 @@ define(['jquery', 'core/notification', 'core/templates',
// data then we will load our own.
if (typeof promise == 'undefined') {
var args = {
starttime: todayTime,
starttime: startTime,
limit: limit,
};

View File

@ -47,7 +47,9 @@ function($, EventList, EventsRepository) {
}
var date = new Date();
var todayTime = Math.floor(date.setHours(0, 0, 0, 0) / 1000);
date.setDate(date.getDate() - 14);
date.setHours(0, 0, 0, 0);
var startTime = Math.floor(date / 1000);
var limit = courseBlocks.attr('data-limit');
var courseIds = courseBlocks.map(function() {
return $(this).attr('data-course-id');
@ -58,7 +60,7 @@ function($, EventList, EventsRepository) {
// there could be lots of them.
var coursesPromise = EventsRepository.queryByCourses({
courseids: courseIds,
starttime: todayTime,
starttime: startTime,
limit: limit
});

View File

@ -34,3 +34,4 @@ $string['pluginname'] = 'My overview';
$string['sortbycourses'] = 'Sort by courses';
$string['sortbydates'] = 'Sort by dates';
$string['timeline'] = 'Timeline';
$string['recentlyoverdue'] = 'Recently overdue';

View File

@ -31,8 +31,18 @@
id="event-list-container-{{$courseid}}{{/courseid}}">
<div data-region="event-list-content">
{{< block_myoverview/event-list-group }}
{{$title}}{{#str}} recentlyoverdue, block_myoverview {{/str}}{{/title}}
{{$extratitleclasses}}text-danger{{/extratitleclasses}}
{{$startday}}-14{{/startday}}
{{$endday}}0{{/endday}}
{{$eventlistitems}}
{{> block_myoverview/course-event-list-items }}
{{/eventlistitems}}
{{/ block_myoverview/event-list-group }}
{{< block_myoverview/event-list-group }}
{{$title}}{{#str}} today {{/str}}{{/title}}
{{$extratitleclasses}}{{/extratitleclasses}}
{{$startday}}0{{/startday}}
{{$endday}}1{{/endday}}
{{$eventlistitems}}
@ -41,6 +51,7 @@
{{/ block_myoverview/event-list-group }}
{{< block_myoverview/event-list-group }}
{{$title}}{{#str}} next7days, block_myoverview {{/str}}{{/title}}
{{$extratitleclasses}}{{/extratitleclasses}}
{{$startday}}1{{/startday}}
{{$endday}}7{{/endday}}
{{$eventlistitems}}
@ -49,6 +60,7 @@
{{/ block_myoverview/event-list-group }}
{{< block_myoverview/event-list-group }}
{{$title}}{{#str}} next30days, block_myoverview {{/str}}{{/title}}
{{$extratitleclasses}}{{/extratitleclasses}}
{{$startday}}7{{/startday}}
{{$endday}}30{{/endday}}
{{$eventlistitems}}
@ -57,8 +69,9 @@
{{/ block_myoverview/event-list-group }}
{{< block_myoverview/event-list-group }}
{{$title}}{{#str}} future, block_myoverview {{/str}}{{/title}}
{{$extratitleclasses}}{{/extratitleclasses}}
{{$startday}}30{{/startday}}
{{$endday}}0{{/endday}}
{{$endday}}{{/endday}}
{{$eventlistitems}}
{{> block_myoverview/course-event-list-items }}
{{/eventlistitems}}

View File

@ -66,7 +66,7 @@
data-end-day="{{$endday}}{{/endday}}"
class="hidden">
<h5 class="h6 m-t-1" id="event-list-title-{{uniqid}}"><strong>{{$title}}{{/title}}</strong></h5>
<h5 class="h6 m-t-1 {{$extratitleclasses}}{{/extratitleclasses}}" id="event-list-title-{{uniqid}}"><strong>{{$title}}{{/title}}</strong></h5>
<ul class="list-group unstyled" data-region="event-list" aria-describedby="event-list-title-{{uniqid}}">
{{$eventlistitems}}
{{> block_myoverview/event-list-items }}

View File

@ -30,25 +30,35 @@
id="event-list-container-{{$courseid}}{{/courseid}}">
<div data-region="event-list-content">
{{< block_myoverview/event-list-group }}
{{$title}}{{#str}} recentlyoverdue, block_myoverview {{/str}}{{/title}}
{{$extratitleclasses}}text-danger{{/extratitleclasses}}
{{$startday}}-14{{/startday}}
{{$endday}}0{{/endday}}
{{/ block_myoverview/event-list-group }}
{{< block_myoverview/event-list-group }}
{{$title}}{{#str}} today {{/str}}{{/title}}
{{$extratitleclasses}}{{/extratitleclasses}}
{{$startday}}0{{/startday}}
{{$endday}}1{{/endday}}
{{/ block_myoverview/event-list-group }}
{{< block_myoverview/event-list-group }}
{{$title}}{{#str}} next7days, block_myoverview {{/str}}{{/title}}
{{$extratitleclasses}}{{/extratitleclasses}}
{{$startday}}1{{/startday}}
{{$endday}}7{{/endday}}
{{/ block_myoverview/event-list-group }}
{{< block_myoverview/event-list-group }}
{{$title}}{{#str}} next30days, block_myoverview {{/str}}{{/title}}
{{$extratitleclasses}}{{/extratitleclasses}}
{{$startday}}7{{/startday}}
{{$endday}}30{{/endday}}
{{/ block_myoverview/event-list-group }}
{{< block_myoverview/event-list-group }}
{{$title}}{{#str}} future, block_myoverview {{/str}}{{/title}}
{{$extratitleclasses}}{{/extratitleclasses}}
{{$startday}}30{{/startday}}
{{$endday}}0{{/endday}}
{{$endday}}{{/endday}}
{{/ block_myoverview/event-list-group }}
<div class="text-xs-center text-center m-y-2">