weekly release 3.8dev
[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}}
54
55 {{#state.hasdiscussions}}
23f5e65e
AN
56 {{$discussion_top_pagination}}
57 {{{ pagination }}}
58 {{/discussion_top_pagination}}
54d38a73 59 {{$discussion_list_output}}
23129586
RW
60 <span id="discussion-table-description-{{uniqid}}" class="sr-only">
61 {{#str}} showingcountoftotaldiscussions, mod_forum, {"count": "{{visiblediscussioncount}}", "total":"{{totaldiscussioncount}}"} {{/str}}
62 </span>
63 <table
6489aa2a 64 class="table table-hover table-striped discussion-list"
23129586
RW
65 aria-label='{{#str}} showingcountoftotaldiscussions, mod_forum, {"count": "{{visiblediscussioncount}}", "total":"{{totaldiscussioncount}}"} {{/str}}'
66 aria-describedby="discussion-table-description-{{uniqid}}"
67 >
54d38a73
MG
68 {{$discussion_list_header}}
69 <thead>
47d38303 70 <tr>
54d38a73
MG
71 <th scope="col">&nbsp;</th>
72 <th scope="col" class="p-l-0">{{#str}}discussion, mod_forum{{/str}}</th>
73 <th scope="col" class="author">{{#str}}startedby, mod_forum{{/str}}</th>
74 {{#forum.state.groupmode}}
75 <th scope="col" class="group">{{#str}}group{{/str}}</th>
76 {{/forum.state.groupmode}}
77 {{#forum.capabilities.viewdiscussions}}
1a9c60e9
MG
78 <th scope="col" class="text-center">
79 {{#state.sortorder.isrepliesdesc}}
80 <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>
81 {{/state.sortorder.isrepliesdesc}}
82 {{#state.sortorder.isrepliesasc}}
83 <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>
84 {{/state.sortorder.isrepliesasc}}
85 {{^state.sortorder.isrepliesdesc}}
86 {{^state.sortorder.isrepliesasc}}
87 <a href="{{{forum.urls.sortrepliesdesc}}}" aria-label="{{#str}}discussionlistsortbyrepliesdesc, mod_forum{{/str}}">{{#str}}replies, mod_forum{{/str}}</a>
88 {{/state.sortorder.isrepliesasc}}
89 {{/state.sortorder.isrepliesdesc}}
90 </th>
91
54d38a73
MG
92 {{#forum.userstate.tracked}}
93 <th scope="col" class="text-center">
94 {{#str}}unread, mod_forum{{/str}}
95 <a href="{{{forum.urls.markasread}}}">{{#pix}}t/markasread, core, {{#str}}markallread, mod_forum{{/str}}{{/pix}}</a>
96 </th>
97 {{/forum.userstate.tracked}}
98 {{/forum.capabilities.viewdiscussions}}
1a9c60e9
MG
99 <th scope="col" class="lastpost">
100 {{#state.sortorder.islastpostdesc}}
101 <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>
102 {{/state.sortorder.islastpostdesc}}
103 {{#state.sortorder.islastpostasc}}
104 <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>
105 {{/state.sortorder.islastpostasc}}
106 {{^state.sortorder.islastpostdesc}}
107 {{^state.sortorder.islastpostasc}}
108 <a href="{{{forum.urls.sortlastpostdesc}}}" aria-label="{{#str}}discussionlistsortbylastpostdesc, mod_forum{{/str}}">{{#str}}lastpost, mod_forum{{/str}}</a>
109 {{/state.sortorder.islastpostasc}}
110 {{/state.sortorder.islastpostdesc}}
111 </th>
112 <th scope="col" class="created">
113 {{#state.sortorder.iscreateddesc}}
114 <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>
115 {{/state.sortorder.iscreateddesc}}
116 {{#state.sortorder.iscreatedasc}}
117 <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>
118 {{/state.sortorder.iscreatedasc}}
119 {{^state.sortorder.iscreateddesc}}
120 {{^state.sortorder.iscreatedasc}}
121 <a href="{{{forum.urls.sortcreateddesc}}}" aria-label="{{#str}}discussionlistsortbycreateddesc, mod_forum{{/str}}">{{#str}}created, mod_forum{{/str}}</a>
122 {{/state.sortorder.iscreatedasc}}
123 {{/state.sortorder.iscreateddesc}}
124 </th>
9b4f09ba 125 <th scope="col">&nbsp;</th>
54d38a73
MG
126 {{#forum.capabilities.subscribe}}
127 <th scope="col" class="discussionsubscription"></th>
128 {{/forum.capabilities.subscribe}}
129 </tr>
130 </thead>
131 {{/discussion_list_header}}
132 {{$discussion_list_body}}
133 <tbody>
134 {{#summaries}}
c5477bfc 135 <!-- The discussion class is only required for behat tests to identify the row -->
7661ccdd 136 <tr class="discussion {{#discussion.timed}}{{#istimed}}{{^visible}}dimmed_text{{/visible}}{{/istimed}}{{/discussion.timed}}">
54d38a73
MG
137 <td scope="col" class="pinned p-0 text-center align-middle">
138 {{#discussion.pinned}}
139 {{#pix}}i/pinned, mod_forum, {{#str}}discussionpinned, mod_forum{{/str}}{{/pix}}
140 {{/discussion.pinned}}
99bda8a7 141 {{^discussion.pinned}}
e7e6a721
P
142 {{#discussion}}
143 {{> mod_forum/forum_discussion_favourite_toggle}}
144 {{/discussion}}
99bda8a7 145 {{/discussion.pinned}}
54d38a73 146 </td>
7661ccdd 147 <td scope="col" class="topic p-0 align-middle">
c5477bfc 148 <a class="p-3 p-l-0 w-100 h-100 d-block" href="{{discussion.urls.view}}">{{{discussion.name}}}</a>
54d38a73 149 </td>
7661ccdd 150 <td scope="col" class="author align-middle">
54d38a73 151 {{#firstpostauthor}}
c27e8d50
RW
152 <div class="d-flex flex-row">
153 <div class="align-middle p-0">
154 <img
6489aa2a 155 class="rounded-circle userpicture"
c27e8d50
RW
156 src="{{urls.profileimage}}"
157 alt="{{#str}}pictureof, moodle, {{fullname}}{{/str}}"
158 >
54d38a73 159 </div>
c27e8d50
RW
160 <div class="align-middle p-2">
161 {{fullname}}
162 </div>
163 </div>
54d38a73
MG
164 {{/firstpostauthor}}
165 </td>
166 {{#forum.state.groupmode}}
167 <td scope="col" class="group">
168 {{#discussion.group}}
169 {{#urls.picture}}
170 {{#urls.userlist}}
171 <a href="{{{urls.userlist}}}">
172 <img class="border rounded h-auto rounded-circle" src="{{{urls.picture}}}">
173 </a>
174 {{/urls.userlist}}
175 {{^urls.userlist}}
176 <img class="border rounded h-auto rounded-circle" src="{{{urls.picture}}}">
177 {{/urls.userlist}}
178 {{/urls.picture}}
179 {{^urls.picture}}
180 {{#urls.userlist}}
181 <a href="{{{urls.userlist}}}">{{name}}</a>
182 {{/urls.userlist}}
183 {{^urls.userlist}}
184 {{name}}
185 {{/urls.userlist}}
186 {{/urls.picture}}
187 {{/discussion.group}}
188 </td>
189 {{/forum.state.groupmode}}
190 {{#forum.capabilities.viewdiscussions}}
7661ccdd 191 <td scope="col" class="p-0 text-center align-middle">
54d38a73
MG
192 <a href="{{discussion.urls.view}}" class="p-3 w-100 h-100 d-block">
193 {{replies}}
194 </a>
195 </td>
196 {{#forum.userstate.tracked}}
7661ccdd 197 <td scope="col" class="p-0 text-center align-middle">
54d38a73
MG
198 {{#unread}}
199 {{! TODO Rewrite as AJAX}}
200 <div class="p-3 w-100 h-100 d-block">
201 <a href="{{{discussion.urls.viewfirstunread}}}">{{unread}}</a>
202 <a href="{{{discussion.urls.markasread}}}">{{#pix}}t/markasread, core, {{#str}}markalldread, mod_forum{{/str}}{{/pix}}</a>
203 </div>
204 {{/unread}}
205 {{^unread}}
206 <span class="p-3 w-100 h-100 d-block">
207 0
208 </span>
209 {{/unread}}
210 </td>
211 {{/forum.userstate.tracked}}
212 {{/forum.capabilities.viewdiscussions}}
213 <td scope="col" class="text-left">
214 {{! TODO Check q&a, eachuser }}
215 {{#latestpostid}}
47d38303
RW
216 <div class="d-flex flex-row">
217 <div class="align-middle p-0">
54d38a73 218 <a href="{{latestpostauthor.urls.profile}}">
6489aa2a
RW
219 <img
220 class="rounded-circle userpicture"
221 src="{{latestpostauthor.urls.profileimage}}"
222 alt="{{#str}}pictureof, moodle, {{latestpostauthor.fullname}}{{/str}}"
223 >
47d38303
RW
224 </a>
225 </div>
54d38a73
MG
226 <div class="p-2 p-t-0 p-b-0 d-inline-flex flex-column">
227 <div>
228 <a href="{{latestpostauthor.urls.profile}}">{{latestpostauthor.fullname}}</a>
229 </div>
230 <div>
231 <a href="{{{discussion.urls.viewlatest}}}">{{#userdate}}
232 {{discussion.times.modified}}, {{#str}}strftimerecentfull{{/str}}
233 {{/userdate}}</a>
234 </div>
47d38303
RW
235 </div>
236 </div>
54d38a73 237 {{/latestpostid}}
47d38303 238 </td>
1a9c60e9
MG
239 <td scope="col" class="text-left align-middle">
240 {{#userdate}}{{discussion.times.created}}, {{#str}}strftimerecentfull{{/str}}{{/userdate}}
241 </td>
9b4f09ba
P
242 <td scope="col" class="timed p-0 text-center align-middle">
243 {{#discussion.timed.istimed}}
244 <div class="timedpost">
245 {{#pix}}
246 i/calendar, moodle,
247 {{#discussion.times.start}}
248 {{! }}{{#str}} displaystart, mod_forum {{/str}}: {{#userdate}}{{.}}, {{#str}}strftimerecentfull {{/str}}{{/userdate}}
249 {{/discussion.times.start}}
250 {{#discussion.times.end}}
251 {{! }}{{#str}} displayend, mod_forum {{/str}}: {{#userdate}}{{.}}, {{#str}} strftimerecentfull {{/str}}{{/userdate}}
252 {{/discussion.times.end}}
253 {{#discussion.timed.visible}}
254 {{! }}{{#str}} timedvisible, mod_forum {{/str}}
255 {{/discussion.timed.visible}}
256 {{^discussion.timed.visible}}
257 {{! }}{{#str}} timedhidden, mod_forum {{/str}}
258 {{/discussion.timed.visible}}
259 {{/pix}}
260 </div>
261 {{/discussion.timed.istimed}}
262 </td>
da04a0a9 263 <td scope="col" class="p-0 align-middle" data-container="discussion-summary-actions">
54d38a73 264 {{#discussion}}
da04a0a9
P
265 <div class="d-flex flex-wrap justify-content-end pr-4">
266 <div class="pt-1 mt-2 {{^discussion.locked}}hidden{{/discussion.locked}}" data-region="locked-icon">
267 <span class="btn" >{{#pix}}i/lock, core, {{#str}}locked, forum{{/str}}{{/pix}}</span>
268 </div>
269 <div>
e7e6a721
P
270 {{> mod_forum/discussion_subscription_toggle}}
271 </div>
da04a0a9 272 <div class="mt-3" data-container='discussion-tools'>
e7e6a721
P
273 {{> mod_forum/forum_action_menu}}
274 </div>
275 </div>
54d38a73 276 {{/discussion}}
47d38303 277 </td>
54d38a73
MG
278 </tr>
279 {{/summaries}}
280 </tbody>
281 {{/discussion_list_body}}
282 </table>
283 {{/discussion_list_output}}
23f5e65e 284 {{$discussion_bottom_pagination}}
54d38a73 285 {{{ pagination }}}
23f5e65e 286 {{/discussion_bottom_pagination}}
47d38303
RW
287 {{#can_create_discussion}}
288 <div class="forumaddnew">
289 <a href="{{create_discussion_link}}" class="btn btn-primary">{{create_discussion_link_text}}</a>
290 </div>
291 {{/can_create_discussion}}
292 {{/state.hasdiscussions}}
293 {{^state.hasdiscussions}}
294 <div class="forumnodiscuss">
295 {{$no_discussions_text}}
296 ({{#str}}nodiscussions, forum{{/str}})
297 {{/no_discussions_text}}
298 </div>
299 {{/state.hasdiscussions}}
300
2646e9d6
RW
301</div>
302{{#js}}
303 require(['jquery', 'mod_forum/discussion_list'], function($, View) {
304 var root = $('#discussion-list-{{uniqid}}');
305 View.init(root);
306 });
307{{/js}}