MDL-65658 mod_forum: Update the group image titles
[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}}
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}}
67     {{#state.hasdiscussions}}
68         {{$discussion_top_pagination}}
69             {{{ pagination }}}
70         {{/discussion_top_pagination}}
71         {{$discussion_list_output}}
72             <span id="discussion-table-description-{{uniqid}}" class="sr-only">
73                 {{#str}} showingcountoftotaldiscussions, mod_forum, {"count": "{{visiblediscussioncount}}", "total":"{{totaldiscussioncount}}"} {{/str}}
74             </span>
75             <table
76                 class="table table-hover table-striped discussion-list"
77                 aria-label='{{#str}} showingcountoftotaldiscussions, mod_forum, {"count": "{{visiblediscussioncount}}", "total":"{{totaldiscussioncount}}"} {{/str}}'
78                 aria-describedby="discussion-table-description-{{uniqid}}"
79             >
80                 {{$discussion_list_header}}
81                 <thead>
82                     <tr>
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}}
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>
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}}
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>
137                         <th scope="col">&nbsp;</th>
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}}
147                         <!-- The discussion class is only required for behat tests to identify the row -->
148                         <tr class="discussion {{#discussion.timed}}{{#istimed}}{{^visible}}dimmed_text{{/visible}}{{/istimed}}{{/discussion.timed}}">
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}}
153                                 {{^discussion.pinned}}
154                                     {{#discussion}}
155                                         {{> mod_forum/forum_discussion_favourite_toggle}}
156                                     {{/discussion}}
157                                 {{/discussion.pinned}}
158                             </td>
159                             <td scope="col" class="topic p-0 align-middle">
160                                 <a class="p-3 p-l-0 w-100 h-100 d-block" href="{{discussion.urls.view}}">{{{discussion.name}}}</a>
161                             </td>
162                             <td scope="col" class="author align-middle">
163                                 {{#firstpostauthor}}
164                                     <div class="d-flex flex-row">
165                                         <div class="align-middle p-0">
166                                             <img
167                                                 class="rounded-circle userpicture"
168                                                 src="{{urls.profileimage}}"
169                                                 alt="{{#str}}pictureof, moodle, {{fullname}}{{/str}}"
170                                                 title="{{#str}}pictureof, moodle, {{fullname}}{{/str}}"
171                                             >
172                                         </div>
173                                         <div class="align-middle p-2">
174                                             {{fullname}}
175                                         </div>
176                                     </div>
177                                 {{/firstpostauthor}}
178                             </td>
179                             {{#forum.state.groupmode}}
180                                 <td scope="col" class="group align-middle">
181                                     {{#discussion.group}}
182                                         {{#urls.picture}}
183                                             {{#urls.userlist}}
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="{{#str}} pictureof, core, {{name}} {{/str}}">
190                                                 </a>
191                                             {{/urls.userlist}}
192                                             {{^urls.userlist}}
193                                                 <img alt="{{#str}} pictureof, core, {{name}} {{/str}}"
194                                                      class="border rounded h-auto rounded-circle grouppicture"
195                                                      src="{{{urls.picture}}}"
196                                                      title="{{#str}} pictureof, core, {{name}} {{/str}}">
197                                             {{/urls.userlist}}
198                                         {{/urls.picture}}
199                                         {{^urls.picture}}
200                                             {{#urls.userlist}}
201                                                 <a href="{{{urls.userlist}}}" aria-label='{{#str}} memberofgroup, group, {{name}}{{/str}}'>{{name}}</a>
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}}
211                                 <td scope="col" class="p-0 text-center align-middle">
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}}
217                                     <td scope="col" class="p-0 text-center align-middle">
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}}
236                                     <div class="d-flex flex-row">
237                                         <div class="align-middle p-0">
238                                             <a href="{{latestpostauthor.urls.profile}}">
239                                                 <img
240                                                     class="rounded-circle userpicture"
241                                                     src="{{latestpostauthor.urls.profileimage}}"
242                                                     alt="{{#str}}pictureof, moodle, {{latestpostauthor.fullname}}{{/str}}"
243                                                     title="{{#str}}pictureof, moodle, {{latestpostauthor.fullname}}{{/str}}"
244                                                 >
245                                             </a>
246                                         </div>
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>
256                                         </div>
257                                     </div>
258                                 {{/latestpostid}}
259                             </td>
260                             <td scope="col" class="text-left align-middle">
261                                 {{#userdate}}{{discussion.times.created}}, {{#str}}strftimerecentfull{{/str}}{{/userdate}}
262                             </td>
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>
284                             <td scope="col" class="p-0 align-middle" data-container="discussion-summary-actions">
285                                 {{#discussion}}
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>
291                                             {{> mod_forum/discussion_subscription_toggle}}
292                                         </div>
293                                         <div class="mt-3" data-container='discussion-tools'>
294                                             {{> mod_forum/forum_action_menu}}
295                                         </div>
296                                     </div>
297                                 {{/discussion}}
298                             </td>
299                         </tr>
300                     {{/summaries}}
301                 </tbody>
302                 {{/discussion_list_body}}
303             </table>
304         {{/discussion_list_output}}
305         {{$discussion_bottom_pagination}}
306             {{{ pagination }}}
307         {{/discussion_bottom_pagination}}
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}}
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}}