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