e37014eff359784becf608b8203971545487d32c
[moodle.git] / mod / forum / templates / discussion_list.mustache
1 {{!
2     This file is part of Moodle - http://moodle.org/
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.
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.
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
20     Template to display the list of forum discussions.
22     Classes required for JS:
23     * none
25     Data attributes required for JS:
26     * none
28     Context variables required for this template:
29     * TODO
31     Example context (json):
32     {
33     }
34 }}
35 <div id="discussion-list-{{uniqid}}">
36     {{{groupchangemenu}}}
38     {{#notifications}}
39         {{> core/notification}}
40     {{/notifications}}
42     {{#forum.capabilities.create}}
43         <div class="p-t-1 p-b-1">
44             <a class="btn btn-primary" data-toggle="collapse" href="#collapseAddForm">
45                 {{$discussion_create_text}}
46                     {{#str}}addanewdiscussion, forum{{/str}}
47                 {{/discussion_create_text}}
48             </a>
49             <div class="collapse m-t-1" id="collapseAddForm">
50                 {{{newdiscussionhtml}}}
51             </div>
52         </div>
53     {{/forum.capabilities.create}}
55     {{#state.hasdiscussions}}
56         {{$discussion_top_pagination}}
57             {{{ pagination }}}
58         {{/discussion_top_pagination}}
59         {{$discussion_list_output}}
60             <span id="discussion-table-description-{{uniqid}}" class="sr-only">
61                 {{#str}} showingcountoftotaldiscussions, mod_forum, {"count": "{{visiblediscussioncount}}", "total":"{{totaldiscussioncount}}"} {{/str}}
62             </span>
63             <table
64                 class="table table-hover table-striped"
65                 aria-label='{{#str}} showingcountoftotaldiscussions, mod_forum, {"count": "{{visiblediscussioncount}}", "total":"{{totaldiscussioncount}}"} {{/str}}'
66                 aria-describedby="discussion-table-description-{{uniqid}}"
67             >
68                 {{$discussion_list_header}}
69                 <thead>
70                     <tr>
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}}
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>
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}}
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>
125                         <th scope="col">&nbsp;</th>
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}}
135                         <!-- The discussion class is only required for behat tests to identify the row -->
136                         <tr class="discussion {{#discussion.timed}}{{#istimed}}{{^visible}}dimmed_text{{/visible}}{{/istimed}}{{/discussion.timed}}">
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}}
141                                 {{^discussion.pinned}}
142                                     {{#discussion}}
143                                         {{> mod_forum/forum_discussion_favourite_toggle}}
144                                     {{/discussion}}
145                                 {{/discussion.pinned}}
146                             </td>
147                             <td scope="col" class="topic p-0 align-middle">
148                                 <a class="p-3 p-l-0 w-100 h-100 d-block" href="{{discussion.urls.view}}">{{{discussion.name}}}</a>
149                             </td>
150                             <td scope="col" class="author align-middle">
151                                 {{#firstpostauthor}}
152                                     <div class="d-flex flex-row">
153                                         <div class="align-middle p-0">
154                                             <img
155                                                 class="h-auto rounded-circle userpicture"
156                                                 src="{{urls.profileimage}}"
157                                                 alt="{{#str}}pictureof, moodle, {{fullname}}{{/str}}"
158                                             >
159                                         </div>
160                                         <div class="align-middle p-2">
161                                             {{fullname}}
162                                         </div>
163                                     </div>
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}}
191                                 <td scope="col" class="p-0 text-center align-middle">
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}}
197                                     <td scope="col" class="p-0 text-center align-middle">
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}}
216                                     <div class="d-flex flex-row">
217                                         <div class="align-middle p-0">
218                                             <a href="{{latestpostauthor.urls.profile}}">
219                                                 <img {{!
220                                                     }} class="h-auto rounded-circle userpicture" {{!
221                                                     }} src="{{latestpostauthor.urls.profileimage}}" {{!
222                                                     }} alt="{{#str}}pictureof, moodle, {{latestpostauthor.fullname}}{{/str}}" {{!
223                                                     }}>
224                                             </a>
225                                         </div>
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>
235                                         </div>
236                                     </div>
237                                 {{/latestpostid}}
238                             </td>
239                             <td scope="col" class="text-left align-middle">
240                                 {{#userdate}}{{discussion.times.created}}, {{#str}}strftimerecentfull{{/str}}{{/userdate}}
241                             </td>
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>
263                             <td scope="col" class="p-0 align-middle" data-container="discussion-summary-actions">
264                                 {{#discussion}}
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>
270                                             {{> mod_forum/discussion_subscription_toggle}}
271                                         </div>
272                                         <div class="mt-3" data-container='discussion-tools'>
273                                             {{> mod_forum/forum_action_menu}}
274                                         </div>
275                                     </div>
276                                 {{/discussion}}
277                             </td>
278                         </tr>
279                     {{/summaries}}
280                 </tbody>
281                 {{/discussion_list_body}}
282             </table>
283         {{/discussion_list_output}}
284         {{$discussion_bottom_pagination}}
285             {{{ pagination }}}
286         {{/discussion_bottom_pagination}}
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}}
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}}