Merge branch 'MDL-65651-master' of https://github.com/lucaboesch/moodle
[moodle.git] / mod / forum / templates / discussion_list.mustache
CommitLineData
47d38303
RW
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 mod_forum/discussion_list
19
20 Template to display the list of forum discussions.
21
22 Classes required for JS:
23 * none
24
25 Data attributes required for JS:
26 * none
27
28 Context variables required for this template:
29 * TODO
30
31 Example context (json):
32 {
33 }
34}}
2646e9d6 35<div id="discussion-list-{{uniqid}}">
47d38303
RW
36 {{{groupchangemenu}}}
37
38 {{#notifications}}
39 {{> core/notification}}
40 {{/notifications}}
41
42 {{#forum.capabilities.create}}
43 <div class="p-t-1 p-b-1">
9ff7cae7 44 <a class="btn btn-primary" data-toggle="collapse" href="#collapseAddForm">
47d38303
RW
45 {{$discussion_create_text}}
46 {{#str}}addanewdiscussion, forum{{/str}}
47 {{/discussion_create_text}}
48 </a>
97babbf7 49 <div class="collapse m-t-1" id="collapseAddForm">
9ff7cae7
P
50 {{{newdiscussionhtml}}}
51 </div>
47d38303
RW
52 </div>
53 {{/forum.capabilities.create}}
92ba55ee
P
54 {{^forum.capabilities.create}}
55 {{#forum.capabilities.selfenrol}}
56 <div class="p-t-1 p-b-1">
57 <a class="btn btn-primary" href="{{forum.urls.create}}">
58 {{$discussion_create_text}}
59 {{#str}}addanewdiscussion, forum{{/str}}
60 {{/discussion_create_text}}
61 </a>
62 </div>
63 {{/forum.capabilities.selfenrol}}
64 {{/forum.capabilities.create}}
65
47d38303
RW
66
67 {{#state.hasdiscussions}}
23f5e65e
AN
68 {{$discussion_top_pagination}}
69 {{{ pagination }}}
70 {{/discussion_top_pagination}}
54d38a73 71 {{$discussion_list_output}}
23129586
RW
72 <span id="discussion-table-description-{{uniqid}}" class="sr-only">
73 {{#str}} showingcountoftotaldiscussions, mod_forum, {"count": "{{visiblediscussioncount}}", "total":"{{totaldiscussioncount}}"} {{/str}}
74 </span>
75 <table
6489aa2a 76 class="table table-hover table-striped discussion-list"
23129586
RW
77 aria-label='{{#str}} showingcountoftotaldiscussions, mod_forum, {"count": "{{visiblediscussioncount}}", "total":"{{totaldiscussioncount}}"} {{/str}}'
78 aria-describedby="discussion-table-description-{{uniqid}}"
79 >
54d38a73
MG
80 {{$discussion_list_header}}
81 <thead>
47d38303 82 <tr>
54d38a73
MG
83 <th scope="col">&nbsp;</th>
84 <th scope="col" class="p-l-0">{{#str}}discussion, mod_forum{{/str}}</th>
85 <th scope="col" class="author">{{#str}}startedby, mod_forum{{/str}}</th>
86 {{#forum.state.groupmode}}
87 <th scope="col" class="group">{{#str}}group{{/str}}</th>
88 {{/forum.state.groupmode}}
89 {{#forum.capabilities.viewdiscussions}}
1a9c60e9
MG
90 <th scope="col" class="text-center">
91 {{#state.sortorder.isrepliesdesc}}
92 <a href="{{{forum.urls.sortrepliesasc}}}" aria-label="{{#str}}discussionlistsortbyrepliesasc, mod_forum{{/str}}">{{#str}}replies, mod_forum{{/str}}</a> <span class="text-primary">{{#pix}}t/downlong, core, {{#str}}desc, core{{/str}}{{/pix}}</span>
93 {{/state.sortorder.isrepliesdesc}}
94 {{#state.sortorder.isrepliesasc}}
95 <a href="{{{forum.urls.sortrepliesdesc}}}" aria-label="{{#str}}discussionlistsortbyrepliesdesc, mod_forum{{/str}}">{{#str}}replies, mod_forum{{/str}}</a> <span class="text-primary">{{#pix}}t/uplong, core, {{#str}}asc, core{{/str}}{{/pix}}</span>
96 {{/state.sortorder.isrepliesasc}}
97 {{^state.sortorder.isrepliesdesc}}
98 {{^state.sortorder.isrepliesasc}}
99 <a href="{{{forum.urls.sortrepliesdesc}}}" aria-label="{{#str}}discussionlistsortbyrepliesdesc, mod_forum{{/str}}">{{#str}}replies, mod_forum{{/str}}</a>
100 {{/state.sortorder.isrepliesasc}}
101 {{/state.sortorder.isrepliesdesc}}
102 </th>
103
54d38a73
MG
104 {{#forum.userstate.tracked}}
105 <th scope="col" class="text-center">
106 {{#str}}unread, mod_forum{{/str}}
107 <a href="{{{forum.urls.markasread}}}">{{#pix}}t/markasread, core, {{#str}}markallread, mod_forum{{/str}}{{/pix}}</a>
108 </th>
109 {{/forum.userstate.tracked}}
110 {{/forum.capabilities.viewdiscussions}}
1a9c60e9
MG
111 <th scope="col" class="lastpost">
112 {{#state.sortorder.islastpostdesc}}
113 <a href="{{{forum.urls.sortlastpostasc}}}" aria-label="{{#str}}discussionlistsortbylastpostasc, mod_forum{{/str}}">{{#str}}lastpost, mod_forum{{/str}}</a> <span class="text-primary">{{#pix}}t/downlong, core, {{#str}}desc, core{{/str}}{{/pix}}</span>
114 {{/state.sortorder.islastpostdesc}}
115 {{#state.sortorder.islastpostasc}}
116 <a href="{{{forum.urls.sortlastpostdesc}}}" aria-label="{{#str}}discussionlistsortbylastpostdesc, mod_forum{{/str}}">{{#str}}lastpost, mod_forum{{/str}}</a> <span class="text-primary">{{#pix}}t/uplong, core, {{#str}}asc, core{{/str}}{{/pix}}</span>
117 {{/state.sortorder.islastpostasc}}
118 {{^state.sortorder.islastpostdesc}}
119 {{^state.sortorder.islastpostasc}}
120 <a href="{{{forum.urls.sortlastpostdesc}}}" aria-label="{{#str}}discussionlistsortbylastpostdesc, mod_forum{{/str}}">{{#str}}lastpost, mod_forum{{/str}}</a>
121 {{/state.sortorder.islastpostasc}}
122 {{/state.sortorder.islastpostdesc}}
123 </th>
124 <th scope="col" class="created">
125 {{#state.sortorder.iscreateddesc}}
126 <a href="{{{forum.urls.sortcreatedasc}}}" aria-label="{{#str}}discussionlistsortbycreatedasc, mod_forum{{/str}}">{{#str}}created, mod_forum{{/str}}</a> <span class="text-primary">{{#pix}}t/downlong, core, {{#str}}desc, core{{/str}}{{/pix}}</span>
127 {{/state.sortorder.iscreateddesc}}
128 {{#state.sortorder.iscreatedasc}}
129 <a href="{{{forum.urls.sortcreateddesc}}}" aria-label="{{#str}}discussionlistsortbycreateddesc, mod_forum{{/str}}">{{#str}}created, mod_forum{{/str}}</a> <span class="text-primary">{{#pix}}t/uplong, core, {{#str}}asc, core{{/str}}{{/pix}}</span>
130 {{/state.sortorder.iscreatedasc}}
131 {{^state.sortorder.iscreateddesc}}
132 {{^state.sortorder.iscreatedasc}}
133 <a href="{{{forum.urls.sortcreateddesc}}}" aria-label="{{#str}}discussionlistsortbycreateddesc, mod_forum{{/str}}">{{#str}}created, mod_forum{{/str}}</a>
134 {{/state.sortorder.iscreatedasc}}
135 {{/state.sortorder.iscreateddesc}}
136 </th>
9b4f09ba 137 <th scope="col">&nbsp;</th>
4b6e0328 138 <th scope="col" class="discussionsubscription"></th>
54d38a73
MG
139 </tr>
140 </thead>
141 {{/discussion_list_header}}
142 {{$discussion_list_body}}
143 <tbody>
144 {{#summaries}}
c5477bfc 145 <!-- The discussion class is only required for behat tests to identify the row -->
7661ccdd 146 <tr class="discussion {{#discussion.timed}}{{#istimed}}{{^visible}}dimmed_text{{/visible}}{{/istimed}}{{/discussion.timed}}">
54d38a73
MG
147 <td scope="col" class="pinned p-0 text-center align-middle">
148 {{#discussion.pinned}}
149 {{#pix}}i/pinned, mod_forum, {{#str}}discussionpinned, mod_forum{{/str}}{{/pix}}
150 {{/discussion.pinned}}
99bda8a7 151 {{^discussion.pinned}}
e7e6a721
P
152 {{#discussion}}
153 {{> mod_forum/forum_discussion_favourite_toggle}}
154 {{/discussion}}
99bda8a7 155 {{/discussion.pinned}}
54d38a73 156 </td>
7661ccdd 157 <td scope="col" class="topic p-0 align-middle">
c5477bfc 158 <a class="p-3 p-l-0 w-100 h-100 d-block" href="{{discussion.urls.view}}">{{{discussion.name}}}</a>
54d38a73 159 </td>
7661ccdd 160 <td scope="col" class="author align-middle">
54d38a73 161 {{#firstpostauthor}}
c27e8d50
RW
162 <div class="d-flex flex-row">
163 <div class="align-middle p-0">
164 <img
6489aa2a 165 class="rounded-circle userpicture"
c27e8d50
RW
166 src="{{urls.profileimage}}"
167 alt="{{#str}}pictureof, moodle, {{fullname}}{{/str}}"
dd287e7d 168 title="{{#str}}pictureof, moodle, {{fullname}}{{/str}}"
c27e8d50 169 >
54d38a73 170 </div>
c27e8d50
RW
171 <div class="align-middle p-2">
172 {{fullname}}
173 </div>
174 </div>
54d38a73
MG
175 {{/firstpostauthor}}
176 </td>
177 {{#forum.state.groupmode}}
c939a043 178 <td scope="col" class="group align-middle">
54d38a73
MG
179 {{#discussion.group}}
180 {{#urls.picture}}
181 {{#urls.userlist}}
c939a043
MM
182 <a href="{{{urls.userlist}}}" role="button" aria-label='{{#str}} memberofgroup, group, {{name}}{{/str}}'>
183 <img alt="{{#str}} pictureof, core, {{name}} {{/str}}"
184 aria-hidden="true"
185 class="border rounded h-auto rounded-circle grouppicture"
186 src="{{{urls.picture}}}"
dd287e7d 187 title="{{#str}} pictureof, core, {{name}} {{/str}}">
54d38a73
MG
188 </a>
189 {{/urls.userlist}}
190 {{^urls.userlist}}
c939a043
MM
191 <img alt="{{#str}} pictureof, core, {{name}} {{/str}}"
192 class="border rounded h-auto rounded-circle grouppicture"
193 src="{{{urls.picture}}}"
dd287e7d 194 title="{{#str}} pictureof, core, {{name}} {{/str}}">
54d38a73
MG
195 {{/urls.userlist}}
196 {{/urls.picture}}
197 {{^urls.picture}}
198 {{#urls.userlist}}
c939a043 199 <a href="{{{urls.userlist}}}" aria-label='{{#str}} memberofgroup, group, {{name}}{{/str}}'>{{name}}</a>
54d38a73
MG
200 {{/urls.userlist}}
201 {{^urls.userlist}}
202 {{name}}
203 {{/urls.userlist}}
204 {{/urls.picture}}
205 {{/discussion.group}}
206 </td>
207 {{/forum.state.groupmode}}
208 {{#forum.capabilities.viewdiscussions}}
7661ccdd 209 <td scope="col" class="p-0 text-center align-middle">
54d38a73
MG
210 <a href="{{discussion.urls.view}}" class="p-3 w-100 h-100 d-block">
211 {{replies}}
212 </a>
213 </td>
214 {{#forum.userstate.tracked}}
7661ccdd 215 <td scope="col" class="p-0 text-center align-middle">
54d38a73
MG
216 {{#unread}}
217 {{! TODO Rewrite as AJAX}}
a7174ddf 218 <span class="p-1 w-100 h-100 d-block unread">
54d38a73
MG
219 <a href="{{{discussion.urls.viewfirstunread}}}">{{unread}}</a>
220 <a href="{{{discussion.urls.markasread}}}">{{#pix}}t/markasread, core, {{#str}}markalldread, mod_forum{{/str}}{{/pix}}</a>
a7174ddf 221 </span>
54d38a73
MG
222 {{/unread}}
223 {{^unread}}
224 <span class="p-3 w-100 h-100 d-block">
225 0
226 </span>
227 {{/unread}}
228 </td>
229 {{/forum.userstate.tracked}}
230 {{/forum.capabilities.viewdiscussions}}
766bb9a5 231 <td scope="col" class="text-left align-middle">
54d38a73
MG
232 {{! TODO Check q&a, eachuser }}
233 {{#latestpostid}}
47d38303
RW
234 <div class="d-flex flex-row">
235 <div class="align-middle p-0">
54d38a73 236 <a href="{{latestpostauthor.urls.profile}}">
6489aa2a
RW
237 <img
238 class="rounded-circle userpicture"
239 src="{{latestpostauthor.urls.profileimage}}"
240 alt="{{#str}}pictureof, moodle, {{latestpostauthor.fullname}}{{/str}}"
dd287e7d 241 title="{{#str}}pictureof, moodle, {{latestpostauthor.fullname}}{{/str}}"
6489aa2a 242 >
47d38303
RW
243 </a>
244 </div>
54d38a73
MG
245 <div class="p-2 p-t-0 p-b-0 d-inline-flex flex-column">
246 <div>
247 <a href="{{latestpostauthor.urls.profile}}">{{latestpostauthor.fullname}}</a>
248 </div>
249 <div>
250 <a href="{{{discussion.urls.viewlatest}}}">{{#userdate}}
251 {{discussion.times.modified}}, {{#str}}strftimerecentfull{{/str}}
252 {{/userdate}}</a>
253 </div>
47d38303
RW
254 </div>
255 </div>
54d38a73 256 {{/latestpostid}}
47d38303 257 </td>
1a9c60e9
MG
258 <td scope="col" class="text-left align-middle">
259 {{#userdate}}{{discussion.times.created}}, {{#str}}strftimerecentfull{{/str}}{{/userdate}}
260 </td>
9b4f09ba
P
261 <td scope="col" class="timed p-0 text-center align-middle">
262 {{#discussion.timed.istimed}}
263 <div class="timedpost">
264 {{#pix}}
265 i/calendar, moodle,
266 {{#discussion.times.start}}
267 {{! }}{{#str}} displaystart, mod_forum {{/str}}: {{#userdate}}{{.}}, {{#str}}strftimerecentfull {{/str}}{{/userdate}}
268 {{/discussion.times.start}}
269 {{#discussion.times.end}}
270 {{! }}{{#str}} displayend, mod_forum {{/str}}: {{#userdate}}{{.}}, {{#str}} strftimerecentfull {{/str}}{{/userdate}}
271 {{/discussion.times.end}}
272 {{#discussion.timed.visible}}
273 {{! }}{{#str}} timedvisible, mod_forum {{/str}}
274 {{/discussion.timed.visible}}
275 {{^discussion.timed.visible}}
276 {{! }}{{#str}} timedhidden, mod_forum {{/str}}
277 {{/discussion.timed.visible}}
278 {{/pix}}
279 </div>
280 {{/discussion.timed.istimed}}
281 </td>
da04a0a9 282 <td scope="col" class="p-0 align-middle" data-container="discussion-summary-actions">
54d38a73 283 {{#discussion}}
da04a0a9
P
284 <div class="d-flex flex-wrap justify-content-end pr-4">
285 <div class="pt-1 mt-2 {{^discussion.locked}}hidden{{/discussion.locked}}" data-region="locked-icon">
286 <span class="btn" >{{#pix}}i/lock, core, {{#str}}locked, forum{{/str}}{{/pix}}</span>
287 </div>
4b6e0328 288 {{#forum.capabilities.subscribe}}
da04a0a9 289 <div>
e7e6a721
P
290 {{> mod_forum/discussion_subscription_toggle}}
291 </div>
4b6e0328
AN
292 {{/forum.capabilities.subscribe}}
293 {{#hasanyactions}}
da04a0a9 294 <div class="mt-3" data-container='discussion-tools'>
e7e6a721
P
295 {{> mod_forum/forum_action_menu}}
296 </div>
4b6e0328 297 {{/hasanyactions}}
e7e6a721 298 </div>
54d38a73 299 {{/discussion}}
47d38303 300 </td>
54d38a73
MG
301 </tr>
302 {{/summaries}}
303 </tbody>
304 {{/discussion_list_body}}
305 </table>
306 {{/discussion_list_output}}
23f5e65e 307 {{$discussion_bottom_pagination}}
54d38a73 308 {{{ pagination }}}
23f5e65e 309 {{/discussion_bottom_pagination}}
47d38303
RW
310 {{#can_create_discussion}}
311 <div class="forumaddnew">
312 <a href="{{create_discussion_link}}" class="btn btn-primary">{{create_discussion_link_text}}</a>
313 </div>
314 {{/can_create_discussion}}
315 {{/state.hasdiscussions}}
316 {{^state.hasdiscussions}}
317 <div class="forumnodiscuss">
318 {{$no_discussions_text}}
319 ({{#str}}nodiscussions, forum{{/str}})
320 {{/no_discussions_text}}
321 </div>
322 {{/state.hasdiscussions}}
323
2646e9d6
RW
324</div>
325{{#js}}
326 require(['jquery', 'mod_forum/discussion_list'], function($, View) {
327 var root = $('#discussion-list-{{uniqid}}');
328 View.init(root);
329 });
330{{/js}}