MDL-65671 calendar: remove course selector label from exporters

This commit is contained in:
Simey Lameze
2019-06-12 15:54:24 +08:00
parent 4cc9d7c83a
commit 859bc931d8
12 changed files with 15 additions and 23 deletions
+1 -1
View File
@@ -1 +1 @@
define(["jquery","core/templates","core/str","core/notification","core_calendar/repository","core_calendar/events","core_calendar/selectors","core/modal_factory","core/modal_events","core_calendar/summary_modal","core/custom_interaction_events"],function(a,b,c,d,e,f,g,h,i,j,k){var l=function(b){b=a(b),b.on("click",g.links.eventLink,function(b){var c,d=a(b.target),e=null;c=d.is(g.actions.viewEvent)?d:d.closest(g.actions.viewEvent),e=c.length?c.data("eventId"):d.find(g.actions.viewEvent).data("eventId"),e&&(b.preventDefault(),b.stopPropagation(),w(e))}),b.on("click",g.links.navLink,function(c){var d=b.find(g.wrapper),e=d.data("view"),f=d.data("courseid"),h=d.data("categoryid"),i=a(c.currentTarget);"month"===e?(n(b,i.attr("href"),i.data("year"),i.data("month"),f,h),c.preventDefault()):"day"===e&&(r(b,i.attr("href"),i.data("year"),i.data("month"),i.data("day"),f,h),c.preventDefault())});var c=b.find(g.viewSelector);k.define(c,[k.events.activate]),c.on(k.events.activate,function(c){c.preventDefault();var e=a(c.target);if(!e.hasClass("active")){var f=e.data("view"),g=e.data("year"),h=e.data("month"),i=e.data("day"),j=e.data("courseid"),k=e.data("categoryid");"month"==f?m(b,g,h,j,k,b,"core_calendar/calendar_month").then(function(){return window.history.pushState({},"","?view=month")}).fail(d.exception):"day"==f?p(b,g,h,i,j,k,b,"core_calendar/calendar_day").then(function(){return window.history.pushState({},"","?view=day")}).fail(d.exception):"upcoming"==f&&u(b,j,k,"core_calendar/calendar_upcoming").then(function(){return window.history.pushState({},"","?view=upcoming")}).fail(d.exception)}})},m=function(c,h,i,j,k,l,m){s(c),l=l||c.find(g.wrapper),m=m||c.attr("data-template"),M.util.js_pending([c.get("id"),h,i,j].join("-"));var n=c.data("includenavigation"),o=c.data("mini");return e.getCalendarMonthData(h,i,j,k,n,o).then(function(a){return a.viewingmonth=!0,b.render(m,a)}).then(function(a,c){return b.replaceNode(l,a,c)}).then(function(){a("body").trigger(f.viewUpdated)}).always(function(){return M.util.js_complete([c.get("id"),h,i,j].join("-")),t(c)}).fail(d.exception)},n=function(b,c,d,e,g,h){return m(b,d,e,g,h).then(function(){return c.length&&"#"!==c&&window.history.pushState({},"",c),arguments}).then(function(){return a("body").trigger(f.monthChanged,[d,e,g,h]),arguments})},o=function(a,b,c){var d=a.find(g.wrapper).data("year"),e=a.find(g.wrapper).data("month");return"undefined"==typeof b&&(b=a.find(g.wrapper).data("courseid")),"undefined"==typeof c&&(c=a.find(g.wrapper).data("categoryid")),m(a,d,e,b,c)},p=function(c,h,i,j,k,l,m,n){s(c),m=m||c.find(g.wrapper),n=n||c.attr("data-template"),M.util.js_pending([c.get("id"),h,i,j,k,l].join("-"));var o=c.data("includenavigation");return e.getCalendarDayData(h,i,j,k,l,o).then(function(a){return a.viewingday=!0,b.render(n,a)}).then(function(a,c){return b.replaceNode(m,a,c)}).then(function(){a("body").trigger(f.viewUpdated)}).always(function(){return M.util.js_complete([c.get("id"),h,i,j,k,l].join("-")),t(c)}).fail(d.exception)},q=function(a,b,c){var d=a.find(g.wrapper),e=d.data("year"),f=d.data("month"),h=d.data("day");return b||(b=a.find(g.wrapper).data("courseid")),"undefined"==typeof c&&(c=a.find(g.wrapper).data("categoryid")),p(a,e,f,h,b,c)},r=function(b,c,d,e,g,h,i){return p(b,d,e,g,h,i).then(function(){return c.length&&"#"!==c&&window.history.pushState({},"",c),arguments}).then(function(){return a("body").trigger(f.dayChanged,[d,e,g,h,i]),arguments})},s=function(a){var b=a.find(g.containers.loadingIcon);b.removeClass("hidden")},t=function(a){var b=a.find(g.containers.loadingIcon);b.addClass("hidden")},u=function(c,h,i,j){s(c);var k=c.find(g.wrapper);return j=j||c.attr("data-template"),"undefined"==typeof h&&(h=c.find(g.wrapper).data("courseid")),"undefined"==typeof i&&(i=c.find(g.wrapper).data("categoryid")),e.getCalendarUpcomingData(h,i).then(function(a){return a.viewingupcoming=!0,b.render(j,a)}).then(function(a,c){return b.replaceNode(k,a,c)}).then(function(){a("body").trigger(f.viewUpdated)}).always(function(){return t(c)}).fail(d.exception)},v=function(a){return"calendar_event_"+a},w=function(a){var c="";e.getEventById(a).then(function(b){if(!b.event)throw new Error("Error encountered while trying to fetch calendar event with ID: "+a);var d=b.event;return c=v(d.normalisedeventtype),d}).then(function(a){var d={title:a.name,type:j.TYPE,body:b.render("core_calendar/event_summary_body",a),templateContext:{canedit:a.canedit,candelete:a.candelete,headerclasses:c,isactionevent:a.isactionevent,url:a.url}};return h.create(d)}).done(function(a){a.getRoot().on(i.hidden,function(){a.destroy()}),a.show()}).fail(d.exception)};return{init:function(a,b){l(a,b)},reloadCurrentMonth:o,changeMonth:n,refreshMonthContent:m,reloadCurrentDay:q,changeDay:r,refreshDayContent:p,reloadCurrentUpcoming:u}});
define(["jquery","core/templates","core/str","core/notification","core_calendar/repository","core_calendar/events","core_calendar/selectors","core/modal_factory","core/modal_events","core_calendar/summary_modal","core/custom_interaction_events"],function(a,b,c,d,e,f,g,h,i,j,k){var l=function(b){b=a(b),b.on("click",g.links.eventLink,function(b){var c,d=a(b.target),e=null;c=d.is(g.actions.viewEvent)?d:d.closest(g.actions.viewEvent),e=c.length?c.data("eventId"):d.find(g.actions.viewEvent).data("eventId"),e&&(b.preventDefault(),b.stopPropagation(),w(e))}),b.on("click",g.links.navLink,function(c){var d=b.find(g.wrapper),e=d.data("view"),f=d.data("courseid"),h=d.data("categoryid"),i=a(c.currentTarget);"month"===e?(n(b,i.attr("href"),i.data("year"),i.data("month"),f,h),c.preventDefault()):"day"===e&&(r(b,i.attr("href"),i.data("year"),i.data("month"),i.data("day"),f,h),c.preventDefault())});var c=b.find(g.viewSelector);k.define(c,[k.events.activate]),c.on(k.events.activate,function(c){c.preventDefault();var e=a(c.target);if(!e.hasClass("active")){var f=e.data("view"),g=e.data("year"),h=e.data("month"),i=e.data("day"),j=e.data("courseid"),k=e.data("categoryid");"month"==f?m(b,g,h,j,k,b,"core_calendar/calendar_month").then(function(){return window.history.pushState({},"","?view=month")}).fail(d.exception):"day"==f?p(b,g,h,i,j,k,b,"core_calendar/calendar_day").then(function(){return window.history.pushState({},"","?view=day")}).fail(d.exception):"upcoming"==f&&u(b,j,k,b,"core_calendar/calendar_upcoming").then(function(){return window.history.pushState({},"","?view=upcoming")}).fail(d.exception)}})},m=function(c,h,i,j,k,l,m){s(c),l=l||c.find(g.wrapper),m=m||c.attr("data-template"),M.util.js_pending([c.get("id"),h,i,j].join("-"));var n=c.data("includenavigation"),o=c.data("mini");return e.getCalendarMonthData(h,i,j,k,n,o).then(function(a){return a.viewingmonth=!0,b.render(m,a)}).then(function(a,c){return b.replaceNode(l,a,c)}).then(function(){a("body").trigger(f.viewUpdated)}).always(function(){return M.util.js_complete([c.get("id"),h,i,j].join("-")),t(c)}).fail(d.exception)},n=function(b,c,d,e,g,h){return m(b,d,e,g,h).then(function(){return c.length&&"#"!==c&&window.history.pushState({},"",c),arguments}).then(function(){return a("body").trigger(f.monthChanged,[d,e,g,h]),arguments})},o=function(a,b,c){var d=a.find(g.wrapper).data("year"),e=a.find(g.wrapper).data("month");return"undefined"==typeof b&&(b=a.find(g.wrapper).data("courseid")),"undefined"==typeof c&&(c=a.find(g.wrapper).data("categoryid")),m(a,d,e,b,c)},p=function(c,h,i,j,k,l,m,n){s(c),m=m||c.find(g.wrapper),n=n||c.attr("data-template"),M.util.js_pending([c.get("id"),h,i,j,k,l].join("-"));var o=c.data("includenavigation");return e.getCalendarDayData(h,i,j,k,l,o).then(function(a){return a.viewingday=!0,b.render(n,a)}).then(function(a,c){return b.replaceNode(m,a,c)}).then(function(){a("body").trigger(f.viewUpdated)}).always(function(){return M.util.js_complete([c.get("id"),h,i,j,k,l].join("-")),t(c)}).fail(d.exception)},q=function(a,b,c){var d=a.find(g.wrapper),e=d.data("year"),f=d.data("month"),h=d.data("day");return b||(b=a.find(g.wrapper).data("courseid")),"undefined"==typeof c&&(c=a.find(g.wrapper).data("categoryid")),p(a,e,f,h,b,c)},r=function(b,c,d,e,g,h,i){return p(b,d,e,g,h,i).then(function(){return c.length&&"#"!==c&&window.history.pushState({},"",c),arguments}).then(function(){return a("body").trigger(f.dayChanged,[d,e,g,h,i]),arguments})},s=function(a){var b=a.find(g.containers.loadingIcon);b.removeClass("hidden")},t=function(a){var b=a.find(g.containers.loadingIcon);b.addClass("hidden")},u=function(c,h,i,j,k){return s(c),j=j||c.find(g.wrapper),k=k||c.attr("data-template"),"undefined"==typeof h&&(h=c.find(g.wrapper).data("courseid")),"undefined"==typeof i&&(i=c.find(g.wrapper).data("categoryid")),e.getCalendarUpcomingData(h,i).then(function(a){return a.viewingupcoming=!0,b.render(k,a)}).then(function(a,c){return b.replaceNode(j,a,c)}).then(function(){a("body").trigger(f.viewUpdated)}).always(function(){return t(c)}).fail(d.exception)},v=function(a){return"calendar_event_"+a},w=function(a){var c="";e.getEventById(a).then(function(b){if(!b.event)throw new Error("Error encountered while trying to fetch calendar event with ID: "+a);var d=b.event;return c=v(d.normalisedeventtype),d}).then(function(a){var d={title:a.name,type:j.TYPE,body:b.render("core_calendar/event_summary_body",a),templateContext:{canedit:a.canedit,candelete:a.candelete,headerclasses:c,isactionevent:a.isactionevent,url:a.url}};return h.create(d)}).done(function(a){a.getRoot().on(i.hidden,function(){a.destroy()}),a.show()}).fail(d.exception)};return{init:function(a,b){l(a,b)},reloadCurrentMonth:o,changeMonth:n,refreshMonthContent:m,reloadCurrentDay:q,changeDay:r,refreshDayContent:p,reloadCurrentUpcoming:u}});
+5 -3
View File
@@ -134,7 +134,7 @@ define([
return window.history.pushState({}, '', '?view=day');
}).fail(Notification.exception);
} else if (view == 'upcoming') {
reloadCurrentUpcoming(root, courseId, categoryId, 'core_calendar/calendar_upcoming')
reloadCurrentUpcoming(root, courseId, categoryId, root, 'core_calendar/calendar_upcoming')
.then(function() {
return window.history.pushState({}, '', '?view=upcoming');
}).fail(Notification.exception);
@@ -353,13 +353,15 @@ define([
* @param {Number} courseId The course id.
* @param {Number} categoryId The id of the category whose events are shown
* @param {String} template The template to be rendered.
* @param {object} target The element being replaced. If not specified, the calendarwrapper is used.
* @return {promise}
*/
var reloadCurrentUpcoming = function(root, courseId, categoryId, template) {
var reloadCurrentUpcoming = function(root, courseId, categoryId, target, template) {
startLoading(root);
var target = root.find(CalendarSelectors.wrapper);
target = target || root.find(CalendarSelectors.wrapper);
template = template || root.attr('data-template');
if (typeof courseId === 'undefined') {
courseId = root.find(CalendarSelectors.wrapper).data('courseid');
}
+1 -2
View File
@@ -240,8 +240,7 @@ class calendar_day_exporter extends exporter {
* @return string The html code for the course filter selector.
*/
protected function get_course_filter_selector(renderer_base $output) {
$langstr = get_string('dayviewfor', 'calendar');
return $output->course_filter_selector($this->url, $langstr, $this->calendar->course->id);
return $output->course_filter_selector($this->url, '', $this->calendar->course->id);
}
/**
+1 -2
View File
@@ -170,8 +170,7 @@ class calendar_upcoming_exporter extends exporter {
* @return string The html code for the course filter selector.
*/
protected function get_course_filter_selector(renderer_base $output) {
$langstr = get_string('upcomingeventsfor', 'calendar');
return $output->course_filter_selector($this->url, $langstr, $this->calendar->course->id);
return $output->course_filter_selector($this->url, '', $this->calendar->course->id);
}
/**
+1 -2
View File
@@ -252,8 +252,7 @@ class month_exporter extends exporter {
*/
protected function get_course_filter_selector(renderer_base $output) {
$content = '';
$content .= $output->course_filter_selector($this->url, get_string('detailedmonthviewfor', 'calendar'),
$this->calendar->course->id);
$content .= $output->course_filter_selector($this->url, '', $this->calendar->course->id);
return $content;
}
+1 -3
View File
@@ -32,9 +32,7 @@
}
}}
<div id="calendar-day-{{uniqid}}" data-template="core_calendar/day_detailed">
<div class="mb-5">
{{> core_calendar/view_selector}}
</div>
{{> core_calendar/header}}
{{> core_calendar/day_detailed}}
</div>
{{#js}}
+1 -4
View File
@@ -32,10 +32,7 @@
}
}}
<div id="calendar-month-{{uniqid}}" data-template="core_calendar/month_detailed">
<div class="mb-5">
{{> core_calendar/view_selector}}
</div>
{{> core_calendar/header}}
{{> core_calendar/month_detailed}}
</div>
{{#js}}
@@ -32,7 +32,7 @@
}
}}
<div id="calendar-upcoming-{{uniqid}}" data-template="core_calendar/upcoming_detailed">
{{> core_calendar/header}}
{{> core_calendar/upcoming_detailed}}
</div>
{{#js}}
-1
View File
@@ -43,7 +43,6 @@
}} data-region="day"{{!
}} data-new-event-timestamp="{{neweventtimestamp}}"{{!
}}>
{{> core_calendar/header}}
{{> core_calendar/day_navigation }}
{{> core/overlay_loading}}
{{> core_calendar/event_list }}
+3 -2
View File
@@ -31,9 +31,10 @@
{
}
}}
<div class="header">
<div class="header d-flex flex-wrap mb-5">
{{> core_calendar/view_selector}}
{{#filter_selector}}
{{{filter_selector}}}
{{/filter_selector}}
{{> core_calendar/add_event_button}}
</div>
</div>
@@ -40,7 +40,6 @@
}} data-year="{{date.year}}"{{!
}} data-view="month"{{!
}}>
{{> core_calendar/header }}
{{> core_calendar/month_navigation }}
{{> core/overlay_loading}}
<table id="month-detailed-{{uniqid}}" class="calendarmonth calendartable mb-0">
@@ -32,7 +32,6 @@
}
}}
<div class="calendarwrapper" data-view="upcoming" data-context-id="{{defaulteventcontext}}" data-courseid="{{courseid}}">
{{> core_calendar/header}}
{{> core/overlay_loading}}
<h2 class="current">{{#str}}upcomingevents, core_calendar{{/str}}</h2>
{{> core_calendar/event_list }}