Merge branch 'MDL-65696-MOODLE-master' of https://github.com/kristian-94/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>
54d38a73
MG
138 {{#forum.capabilities.subscribe}}
139 <th scope="col" class="discussionsubscription"></th>
140 {{/forum.capabilities.subscribe}}
141 </tr>
142 </thead>
143 {{/discussion_list_header}}
144 {{$discussion_list_body}}
145 <tbody>
146 {{#summaries}}
c5477bfc 147 <!-- The discussion class is only required for behat tests to identify the row -->
7661ccdd 148 <tr class="discussion {{#discussion.timed}}{{#istimed}}{{^visible}}dimmed_text{{/visible}}{{/istimed}}{{/discussion.timed}}">
54d38a73
MG
149 <td scope="col" class="pinned p-0 text-center align-middle">
150 {{#discussion.pinned}}
151 {{#pix}}i/pinned, mod_forum, {{#str}}discussionpinned, mod_forum{{/str}}{{/pix}}
152 {{/discussion.pinned}}
99bda8a7 153 {{^discussion.pinned}}
e7e6a721
P
154 {{#discussion}}
155 {{> mod_forum/forum_discussion_favourite_toggle}}
156 {{/discussion}}
99bda8a7 157 {{/discussion.pinned}}
54d38a73 158 </td>
7661ccdd 159 <td scope="col" class="topic p-0 align-middle">
c5477bfc 160 <a class="p-3 p-l-0 w-100 h-100 d-block" href="{{discussion.urls.view}}">{{{discussion.name}}}</a>
54d38a73 161 </td>
7661ccdd 162 <td scope="col" class="author align-middle">
54d38a73 163 {{#firstpostauthor}}
c27e8d50
RW
164 <div class="d-flex flex-row">
165 <div class="align-middle p-0">
166 <img
6489aa2a 167 class="rounded-circle userpicture"
c27e8d50
RW
168 src="{{urls.profileimage}}"
169 alt="{{#str}}pictureof, moodle, {{fullname}}{{/str}}"
c939a043 170 title="{{fullname}}"
c27e8d50 171 >
54d38a73 172 </div>
c27e8d50
RW
173 <div class="align-middle p-2">
174 {{fullname}}
175 </div>
176 </div>
54d38a73
MG
177 {{/firstpostauthor}}
178 </td>
179 {{#forum.state.groupmode}}
c939a043 180 <td scope="col" class="group align-middle">
54d38a73
MG
181 {{#discussion.group}}
182 {{#urls.picture}}
183 {{#urls.userlist}}
c939a043
MM
184 <a href="{{{urls.userlist}}}" role="button" aria-label='{{#str}} memberofgroup, group, {{name}}{{/str}}'>
185 <img alt="{{#str}} pictureof, core, {{name}} {{/str}}"
186 aria-hidden="true"
187 class="border rounded h-auto rounded-circle grouppicture"
188 src="{{{urls.picture}}}"
189 title="{{name}}">
54d38a73
MG
190 </a>
191 {{/urls.userlist}}
192 {{^urls.userlist}}
c939a043
MM
193 <img alt="{{#str}} pictureof, core, {{name}} {{/str}}"
194 class="border rounded h-auto rounded-circle grouppicture"
195 src="{{{urls.picture}}}"
196 title="{{name}}">
54d38a73
MG
197 {{/urls.userlist}}
198 {{/urls.picture}}
199 {{^urls.picture}}
200 {{#urls.userlist}}
c939a043 201 <a href="{{{urls.userlist}}}" aria-label='{{#str}} memberofgroup, group, {{name}}{{/str}}'>{{name}}</a>
54d38a73
MG
202 {{/urls.userlist}}
203 {{^urls.userlist}}
204 {{name}}
205 {{/urls.userlist}}
206 {{/urls.picture}}
207 {{/discussion.group}}
208 </td>
209 {{/forum.state.groupmode}}
210 {{#forum.capabilities.viewdiscussions}}
7661ccdd 211 <td scope="col" class="p-0 text-center align-middle">
54d38a73
MG
212 <a href="{{discussion.urls.view}}" class="p-3 w-100 h-100 d-block">
213 {{replies}}
214 </a>
215 </td>
216 {{#forum.userstate.tracked}}
7661ccdd 217 <td scope="col" class="p-0 text-center align-middle">
54d38a73
MG
218 {{#unread}}
219 {{! TODO Rewrite as AJAX}}
220 <div class="p-3 w-100 h-100 d-block">
221 <a href="{{{discussion.urls.viewfirstunread}}}">{{unread}}</a>
222 <a href="{{{discussion.urls.markasread}}}">{{#pix}}t/markasread, core, {{#str}}markalldread, mod_forum{{/str}}{{/pix}}</a>
223 </div>
224 {{/unread}}
225 {{^unread}}
226 <span class="p-3 w-100 h-100 d-block">
227 0
228 </span>
229 {{/unread}}
230 </td>
231 {{/forum.userstate.tracked}}
232 {{/forum.capabilities.viewdiscussions}}
233 <td scope="col" class="text-left">
234 {{! TODO Check q&a, eachuser }}
235 {{#latestpostid}}
47d38303
RW
236 <div class="d-flex flex-row">
237 <div class="align-middle p-0">
54d38a73 238 <a href="{{latestpostauthor.urls.profile}}">
6489aa2a
RW
239 <img
240 class="rounded-circle userpicture"
241 src="{{latestpostauthor.urls.profileimage}}"
242 alt="{{#str}}pictureof, moodle, {{latestpostauthor.fullname}}{{/str}}"
c939a043 243 title="{{latestpostauthor.fullname}}"
6489aa2a 244 >
47d38303
RW
245 </a>
246 </div>
54d38a73
MG
247 <div class="p-2 p-t-0 p-b-0 d-inline-flex flex-column">
248 <div>
249 <a href="{{latestpostauthor.urls.profile}}">{{latestpostauthor.fullname}}</a>
250 </div>
251 <div>
252 <a href="{{{discussion.urls.viewlatest}}}">{{#userdate}}
253 {{discussion.times.modified}}, {{#str}}strftimerecentfull{{/str}}
254 {{/userdate}}</a>
255 </div>
47d38303
RW
256 </div>
257 </div>
54d38a73 258 {{/latestpostid}}
47d38303 259 </td>
1a9c60e9
MG
260 <td scope="col" class="text-left align-middle">
261 {{#userdate}}{{discussion.times.created}}, {{#str}}strftimerecentfull{{/str}}{{/userdate}}
262 </td>
9b4f09ba
P
263 <td scope="col" class="timed p-0 text-center align-middle">
264 {{#discussion.timed.istimed}}
265 <div class="timedpost">
266 {{#pix}}
267 i/calendar, moodle,
268 {{#discussion.times.start}}
269 {{! }}{{#str}} displaystart, mod_forum {{/str}}: {{#userdate}}{{.}}, {{#str}}strftimerecentfull {{/str}}{{/userdate}}
270 {{/discussion.times.start}}
271 {{#discussion.times.end}}
272 {{! }}{{#str}} displayend, mod_forum {{/str}}: {{#userdate}}{{.}}, {{#str}} strftimerecentfull {{/str}}{{/userdate}}
273 {{/discussion.times.end}}
274 {{#discussion.timed.visible}}
275 {{! }}{{#str}} timedvisible, mod_forum {{/str}}
276 {{/discussion.timed.visible}}
277 {{^discussion.timed.visible}}
278 {{! }}{{#str}} timedhidden, mod_forum {{/str}}
279 {{/discussion.timed.visible}}
280 {{/pix}}
281 </div>
282 {{/discussion.timed.istimed}}
283 </td>
da04a0a9 284 <td scope="col" class="p-0 align-middle" data-container="discussion-summary-actions">
54d38a73 285 {{#discussion}}
da04a0a9
P
286 <div class="d-flex flex-wrap justify-content-end pr-4">
287 <div class="pt-1 mt-2 {{^discussion.locked}}hidden{{/discussion.locked}}" data-region="locked-icon">
288 <span class="btn" >{{#pix}}i/lock, core, {{#str}}locked, forum{{/str}}{{/pix}}</span>
289 </div>
290 <div>
e7e6a721
P
291 {{> mod_forum/discussion_subscription_toggle}}
292 </div>
da04a0a9 293 <div class="mt-3" data-container='discussion-tools'>
e7e6a721
P
294 {{> mod_forum/forum_action_menu}}
295 </div>
296 </div>
54d38a73 297 {{/discussion}}
47d38303 298 </td>
54d38a73
MG
299 </tr>
300 {{/summaries}}
301 </tbody>
302 {{/discussion_list_body}}
303 </table>
304 {{/discussion_list_output}}
23f5e65e 305 {{$discussion_bottom_pagination}}
54d38a73 306 {{{ pagination }}}
23f5e65e 307 {{/discussion_bottom_pagination}}
47d38303
RW
308 {{#can_create_discussion}}
309 <div class="forumaddnew">
310 <a href="{{create_discussion_link}}" class="btn btn-primary">{{create_discussion_link_text}}</a>
311 </div>
312 {{/can_create_discussion}}
313 {{/state.hasdiscussions}}
314 {{^state.hasdiscussions}}
315 <div class="forumnodiscuss">
316 {{$no_discussions_text}}
317 ({{#str}}nodiscussions, forum{{/str}})
318 {{/no_discussions_text}}
319 </div>
320 {{/state.hasdiscussions}}
321
2646e9d6
RW
322</div>
323{{#js}}
324 require(['jquery', 'mod_forum/discussion_list'], function($, View) {
325 var root = $('#discussion-list-{{uniqid}}');
326 View.init(root);
327 });
328{{/js}}