MDL-65658 mod_forum: Group images links and titles groups
[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 discussion-list"
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="rounded-circle userpicture"
156                                                 src="{{urls.profileimage}}"
157                                                 alt="{{#str}}pictureof, moodle, {{fullname}}{{/str}}"
158                                                 title="{{fullname}}"
159                                             >
160                                         </div>
161                                         <div class="align-middle p-2">
162                                             {{fullname}}
163                                         </div>
164                                     </div>
165                                 {{/firstpostauthor}}
166                             </td>
167                             {{#forum.state.groupmode}}
168                                 <td scope="col" class="group align-middle">
169                                     {{#discussion.group}}
170                                         {{#urls.picture}}
171                                             {{#urls.userlist}}
172                                                 <a href="{{{urls.userlist}}}" role="button" aria-label='{{#str}} memberofgroup, group, {{name}}{{/str}}'>
173                                                     <img alt="{{#str}} pictureof, core, {{name}} {{/str}}"
174                                                          aria-hidden="true"
175                                                          class="border rounded h-auto rounded-circle grouppicture"
176                                                          src="{{{urls.picture}}}"
177                                                          title="{{name}}">
178                                                 </a>
179                                             {{/urls.userlist}}
180                                             {{^urls.userlist}}
181                                                 <img alt="{{#str}} pictureof, core, {{name}} {{/str}}"
182                                                      class="border rounded h-auto rounded-circle grouppicture"
183                                                      src="{{{urls.picture}}}"
184                                                      title="{{name}}">
185                                             {{/urls.userlist}}
186                                         {{/urls.picture}}
187                                         {{^urls.picture}}
188                                             {{#urls.userlist}}
189                                                 <a href="{{{urls.userlist}}}" aria-label='{{#str}} memberofgroup, group, {{name}}{{/str}}'>{{name}}</a>
190                                             {{/urls.userlist}}
191                                             {{^urls.userlist}}
192                                                 {{name}}
193                                             {{/urls.userlist}}
194                                         {{/urls.picture}}
195                                     {{/discussion.group}}
196                                 </td>
197                             {{/forum.state.groupmode}}
198                             {{#forum.capabilities.viewdiscussions}}
199                                 <td scope="col" class="p-0 text-center align-middle">
200                                     <a href="{{discussion.urls.view}}" class="p-3 w-100 h-100 d-block">
201                                         {{replies}}
202                                     </a>
203                                 </td>
204                                 {{#forum.userstate.tracked}}
205                                     <td scope="col" class="p-0 text-center align-middle">
206                                         {{#unread}}
207                                             {{! TODO Rewrite as AJAX}}
208                                             <div class="p-3 w-100 h-100 d-block">
209                                                 <a href="{{{discussion.urls.viewfirstunread}}}">{{unread}}</a>
210                                                 <a href="{{{discussion.urls.markasread}}}">{{#pix}}t/markasread, core, {{#str}}markalldread, mod_forum{{/str}}{{/pix}}</a>
211                                             </div>
212                                         {{/unread}}
213                                         {{^unread}}
214                                             <span class="p-3 w-100 h-100 d-block">
215                                                 0
216                                             </span>
217                                         {{/unread}}
218                                     </td>
219                                 {{/forum.userstate.tracked}}
220                             {{/forum.capabilities.viewdiscussions}}
221                             <td scope="col" class="text-left">
222                                 {{! TODO Check q&a, eachuser }}
223                                 {{#latestpostid}}
224                                     <div class="d-flex flex-row">
225                                         <div class="align-middle p-0">
226                                             <a href="{{latestpostauthor.urls.profile}}">
227                                                 <img
228                                                     class="rounded-circle userpicture"
229                                                     src="{{latestpostauthor.urls.profileimage}}"
230                                                     alt="{{#str}}pictureof, moodle, {{latestpostauthor.fullname}}{{/str}}"
231                                                     title="{{latestpostauthor.fullname}}"
232                                                 >
233                                             </a>
234                                         </div>
235                                         <div class="p-2 p-t-0 p-b-0 d-inline-flex flex-column">
236                                             <div>
237                                                 <a href="{{latestpostauthor.urls.profile}}">{{latestpostauthor.fullname}}</a>
238                                             </div>
239                                             <div>
240                                                 <a href="{{{discussion.urls.viewlatest}}}">{{#userdate}}
241                                                     {{discussion.times.modified}}, {{#str}}strftimerecentfull{{/str}}
242                                                 {{/userdate}}</a>
243                                             </div>
244                                         </div>
245                                     </div>
246                                 {{/latestpostid}}
247                             </td>
248                             <td scope="col" class="text-left align-middle">
249                                 {{#userdate}}{{discussion.times.created}}, {{#str}}strftimerecentfull{{/str}}{{/userdate}}
250                             </td>
251                             <td scope="col" class="timed p-0 text-center align-middle">
252                                 {{#discussion.timed.istimed}}
253                                 <div class="timedpost">
254                                     {{#pix}}
255                                     i/calendar, moodle,
256                                     {{#discussion.times.start}}
257                                     {{!                                           }}{{#str}} displaystart, mod_forum {{/str}}: {{#userdate}}{{.}}, {{#str}}strftimerecentfull {{/str}}{{/userdate}}
258                                     {{/discussion.times.start}}
259                                     {{#discussion.times.end}}
260                                     {{!                                           }}{{#str}} displayend, mod_forum {{/str}}: {{#userdate}}{{.}}, {{#str}} strftimerecentfull {{/str}}{{/userdate}}
261                                     {{/discussion.times.end}}
262                                     {{#discussion.timed.visible}}
263                                     {{!                                           }}{{#str}} timedvisible, mod_forum {{/str}}
264                                     {{/discussion.timed.visible}}
265                                     {{^discussion.timed.visible}}
266                                     {{!                                           }}{{#str}} timedhidden, mod_forum {{/str}}
267                                     {{/discussion.timed.visible}}
268                                     {{/pix}}
269                                 </div>
270                                 {{/discussion.timed.istimed}}
271                             </td>
272                             <td scope="col" class="p-0 align-middle" data-container="discussion-summary-actions">
273                                 {{#discussion}}
274                                     <div class="d-flex flex-wrap justify-content-end pr-4">
275                                         <div class="pt-1 mt-2  {{^discussion.locked}}hidden{{/discussion.locked}}" data-region="locked-icon">
276                                             <span class="btn" >{{#pix}}i/lock, core, {{#str}}locked, forum{{/str}}{{/pix}}</span>
277                                         </div>
278                                         <div>
279                                             {{> mod_forum/discussion_subscription_toggle}}
280                                         </div>
281                                         <div class="mt-3" data-container='discussion-tools'>
282                                             {{> mod_forum/forum_action_menu}}
283                                         </div>
284                                     </div>
285                                 {{/discussion}}
286                             </td>
287                         </tr>
288                     {{/summaries}}
289                 </tbody>
290                 {{/discussion_list_body}}
291             </table>
292         {{/discussion_list_output}}
293         {{$discussion_bottom_pagination}}
294             {{{ pagination }}}
295         {{/discussion_bottom_pagination}}
296         {{#can_create_discussion}}
297             <div class="forumaddnew">
298                 <a href="{{create_discussion_link}}" class="btn btn-primary">{{create_discussion_link_text}}</a>
299             </div>
300         {{/can_create_discussion}}
301     {{/state.hasdiscussions}}
302     {{^state.hasdiscussions}}
303         <div class="forumnodiscuss">
304             {{$no_discussions_text}}
305                 ({{#str}}nodiscussions, forum{{/str}})
306             {{/no_discussions_text}}
307         </div>
308     {{/state.hasdiscussions}}
310 </div>
311 {{#js}}
312     require(['jquery', 'mod_forum/discussion_list'], function($, View) {
313         var root = $('#discussion-list-{{uniqid}}');
314         View.init(root);
315     });
316 {{/js}}