Merge branch 'MDL-67233-master' of git://github.com/peterRd/moodle

This commit is contained in:
Adrian Greeve 2019-12-30 12:50:52 +08:00
commit a67ca1e0de
3 changed files with 7 additions and 4 deletions

View File

@ -1,2 +1,2 @@
define ("block_timeline/event_list",["jquery","core/notification","core/templates","core/paged_content_factory","core/str","core/user_date","block_timeline/calendar_events_repository"],function(a,b,c,d,e,f,g){var h={EMPTY_MESSAGE:"[data-region=\"empty-message\"]",ROOT:"[data-region=\"event-list-container\"]",EVENT_LIST_CONTENT:"[data-region=\"event-list-content\"]",EVENT_LIST_LOADING_PLACEHOLDER:"[data-region=\"event-list-loading-placeholder\"]"},i={EVENT_LIST_CONTENT:"block_timeline/event-list-content"},j={ignoreControlWhileLoading:!0,controlPlacementBottom:!0,ariaLabels:{itemsperpagecomponents:"ariaeventlistpagelimit, block_timeline"}},k=function(a){a.find(h.EVENT_LIST_CONTENT).addClass("hidden");a.find(h.EMPTY_MESSAGE).removeClass("hidden")},l=function(a){a.find(h.EVENT_LIST_CONTENT).removeClass("hidden");a.find(h.EMPTY_MESSAGE).addClass("hidden")},m=function(a){a.find(h.EVENT_LIST_CONTENT).empty()},n=function(a,b){var c={},d={eventsbyday:[]};a.forEach(function(a){var d=f.getUserMidnightForTimestamp(a.timesort,b);if(c[d]){c[d].push(a)}else{c[d]=[a]}});Object.keys(c).forEach(function(a){var e=c[a];d.eventsbyday.push({past:a<b,dayTimestamp:a,events:e})});return d},o=function(a,b){var d=n(a,b),e=i.EVENT_LIST_CONTENT;return c.render(e,d)},p=function(a,b,c,d,e,f){var h=d!=void 0?a+d*86400:!1,i={starttime:a+c*86400,limit:b};if(e){i.aftereventid=e}if(h){i.endtime=h}if(f){i.courseid=f;return g.queryByCourse(i)}else{return g.queryByTime(i)}},q=function(a,b,c,d,e,f,g,h){var i=a.pageNumber,j=a.limit,k=i;while(!d.hasOwnProperty(k)){k--}var l=d[k],m=null;if(e&&e.hasOwnProperty(i)){m=e[i]}else{m=p(c,j+1,g,h,l,f)}return m.then(function(a){if(!a.events.length){b.allItemsLoaded(i);return[]}var c=a.events.filter(function(a){return"open"!=a.eventtype&&"opensubmission"!=a.eventtype}),d=c.length<=j;if(d){b.allItemsLoaded(i)}else{c.pop()}return c})},r=function(c,f,g,h,i,k,l,m,n){var p={1:0},r=!1,s=a.extend({},j,n);return e.get_string("ariaeventlistpagelimit","block_timeline",a.isArray(c)?c[0].value:c).then(function(a){s.ariaLabels.itemsperpage=a;s.ariaLabels.paginationnav=m;return a}).then(function(){return d.createWithLimit(c,function(c,d){var e=[];c.forEach(function(a){var c=a.pageNumber,h=q(a,d,g,p,f,i,k,l).then(function(a){if(a.length){r=!0;var b=a[a.length-1].id;p[c+1]=b;return o(a,g)}else{return a}}).catch(b.exception);e.push(h)});a.when.apply(a,e).then(function(){h.resolve(r)}).catch(function(){h.resolve(r)});return e},s)})};return{init:function init(d,e,f,g,i){d=a(d);var j=a.Deferred(),n=d.find(h.EVENT_LIST_CONTENT),o=d.find(h.EVENT_LIST_LOADING_PLACEHOLDER),p=d.attr("data-course-id"),q=parseInt(d.attr("data-days-offset"),10),s=d.attr("data-days-limit"),t=parseInt(d.attr("data-midnight"),10);m(d);l(d);o.removeClass("hidden");if(s!=void 0){s=parseInt(s,10)}return r(e,f,t,j,p,q,s,g,i).then(function(b,e){b=a(b);b.addClass("hidden");c.replaceNodeContents(n,b,e);j.then(function(a){b.removeClass("hidden");o.addClass("hidden");if(!a){k(d)}return a}).catch(function(){return!1});return b}).catch(b.exception)},rootSelector:h.ROOT}});
define ("block_timeline/event_list",["jquery","core/notification","core/templates","core/paged_content_factory","core/str","core/user_date","block_timeline/calendar_events_repository"],function(a,b,c,d,e,f,g){var h={EMPTY_MESSAGE:"[data-region=\"empty-message\"]",ROOT:"[data-region=\"event-list-container\"]",EVENT_LIST_CONTENT:"[data-region=\"event-list-content\"]",EVENT_LIST_LOADING_PLACEHOLDER:"[data-region=\"event-list-loading-placeholder\"]"},i={EVENT_LIST_CONTENT:"block_timeline/event-list-content"},j={ignoreControlWhileLoading:!0,controlPlacementBottom:!0,ariaLabels:{itemsperpagecomponents:"ariaeventlistpagelimit, block_timeline"}},k=function(a){a.find(h.EVENT_LIST_CONTENT).addClass("hidden");a.find(h.EMPTY_MESSAGE).removeClass("hidden")},l=function(a){a.find(h.EVENT_LIST_CONTENT).removeClass("hidden");a.find(h.EMPTY_MESSAGE).addClass("hidden")},m=function(a){a.find(h.EVENT_LIST_CONTENT).empty()},n=function(a,b){var c={},d={eventsbyday:[]};a.forEach(function(a){var d=f.getUserMidnightForTimestamp(a.timesort,b);if(c[d]){c[d].push(a)}else{c[d]=[a]}});Object.keys(c).forEach(function(a){var e=c[a];d.eventsbyday.push({past:a<b,dayTimestamp:a,events:e})});return d},o=function(a,b){var d=n(a,b),e=i.EVENT_LIST_CONTENT;return c.render(e,d)},p=function(a,b,c,d,e,f){var h=d!=void 0?a+d*86400:!1,i={starttime:a+c*86400,limit:b};if(e){i.aftereventid=e}if(h){i.endtime=h}if(f){i.courseid=f;return g.queryByCourse(i)}else{return g.queryByTime(i)}},q=function(a,b,c,d,e,g,h,i){var j=a.pageNumber,k=a.limit,l=j;while(!d.hasOwnProperty(l)){l--}var m=d[l],n=null;if(e&&e.hasOwnProperty(j)){n=e[j]}else{n=p(c,k+1,h,i,m,g)}return n.then(function(a){if(!a.events.length){b.allItemsLoaded(j);return[]}var d=a.events.filter(function(a){if("open"==a.eventtype||"opensubmission"==a.eventtype){var b=f.getUserMidnightForTimestamp(a.timesort,c);return b>c}return!0}),e=d.length<=k;if(e){b.allItemsLoaded(j)}else{d.pop()}return d})},r=function(c,f,g,h,i,k,l,m,n){var p={1:0},r=!1,s=a.extend({},j,n);return e.get_string("ariaeventlistpagelimit","block_timeline",a.isArray(c)?c[0].value:c).then(function(a){s.ariaLabels.itemsperpage=a;s.ariaLabels.paginationnav=m;return a}).then(function(){return d.createWithLimit(c,function(c,d){var e=[];c.forEach(function(a){var c=a.pageNumber,h=q(a,d,g,p,f,i,k,l).then(function(a){if(a.length){r=!0;var b=a[a.length-1].id;p[c+1]=b;return o(a,g)}else{return a}}).catch(b.exception);e.push(h)});a.when.apply(a,e).then(function(){h.resolve(r)}).catch(function(){h.resolve(r)});return e},s)})};return{init:function init(d,e,f,g,i){d=a(d);var j=a.Deferred(),n=d.find(h.EVENT_LIST_CONTENT),o=d.find(h.EVENT_LIST_LOADING_PLACEHOLDER),p=d.attr("data-course-id"),q=parseInt(d.attr("data-days-offset"),10),s=d.attr("data-days-limit"),t=parseInt(d.attr("data-midnight"),10);m(d);l(d);o.removeClass("hidden");if(s!=void 0){s=parseInt(s,10)}return r(e,f,t,j,p,q,s,g,i).then(function(b,e){b=a(b);b.addClass("hidden");c.replaceNodeContents(n,b,e);j.then(function(a){b.removeClass("hidden");o.addClass("hidden");if(!a){k(d)}return a}).catch(function(){return!1});return b}).catch(b.exception)},rootSelector:h.ROOT}});
//# sourceMappingURL=event_list.min.js.map

File diff suppressed because one or more lines are too long

View File

@ -266,8 +266,11 @@ function(
}
var calendarEvents = result.events.filter(function(event) {
// Do not include events that does not have a due date.
return event.eventtype != "open" && event.eventtype != "opensubmission";
if (event.eventtype == "open" || event.eventtype == "opensubmission") {
var dayTimestamp = UserDate.getUserMidnightForTimestamp(event.timesort, midnight);
return dayTimestamp > midnight;
}
return true;
});
// We expect to receive limit + 1 events back from the server.
// Any less means there are no more events to load.