MDL-60558 calendar: Upcoming should support categories
[moodle.git] / calendar / templates / upcoming_mini.mustache
CommitLineData
666d03e1
SL
1{{!
2 This file is part of Moodle - http://moodle.org/
3
4 Moodle is free software: you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation, either version 3 of the License, or
7 (at your option) any later version.
8
9 Moodle is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
13
14 You should have received a copy of the GNU General Public License
15 along with Moodle. If not, see <http://www.gnu.org/licenses/>.
16}}
17{{!
18 @template calendar/upcoming_mini
19
20 Calendar upcoming view for blocks.
21
22 The purpose of this template is to render the upcoming view for blocks.
23
24 Classes required for JS:
25 * none
26
27 Data attributes required for JS:
28 * none
29
30 Example context (json):
31 {
32 }
33}}
9da0be8c 34<div class="card-text content" id="month-upcoming-mini-{{uniqid}}">
666d03e1 35 {{#events}}
9da0be8c
AN
36 <div{{!
37 }} class="event"{{!
38 }} data-eventtype-{{calendareventtype}}="1"{{!
39 }}>
666d03e1
SL
40 <span>{{#icon}}{{#pix}} {{key}}, {{component}}, {{alttext}} {{/pix}}{{/icon}}</span>
41 <a href="{{viewurl}}">{{{name}}}</a>
42 <div class="date">{{{formattedtime}}}</div>
9da0be8c 43 <hr>
666d03e1 44 </div>
666d03e1
SL
45 {{/events}}
46</div>
9da0be8c
AN
47{{#js}}
48require([
49 'jquery',
50 'core_calendar/selectors',
51 'core_calendar/events',
52], function(
53 $,
54 CalendarSelectors,
55 CalendarEvents
56) {
57 var root = $('#month-upcoming-mini-{{uniqid}}');
58
59 $('body').on(CalendarEvents.filterChanged, function(e, data) {
60 M.util.js_pending("month-upcoming-mini-{{uniqid}}-filterChanged");
61
62 // A filter value has been changed.
63 // Find all matching cells in the popover data, and hide them.
64 var target = $("#month-upcoming-mini-{{uniqid}}").find(CalendarSelectors.eventType[data.type]);
65
66 var transitionPromise = $.Deferred();
67 if (data.hidden) {
68 transitionPromise.then(function() {
69 return target.slideUp('fast').promise();
70 });
71 } else {
72 transitionPromise.then(function() {
73 return target.slideDown('fast').promise();
74 });
75 }
76
77 transitionPromise.then(function() {
78 M.util.js_complete("month-upcoming-mini-{{uniqid}}-filterChanged");
79
80 return;
81 });
82
83 transitionPromise.resolve();
84 });
85});
86{{/js}}