MDL-64820 forum: add missing classes and tweaks to templates
[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">
44 <a href="{{forum.urls.create}}" class="btn btn-primary">
45 {{$discussion_create_text}}
46 {{#str}}addanewdiscussion, forum{{/str}}
47 {{/discussion_create_text}}
48 </a>
49 </div>
50 {{/forum.capabilities.create}}
51
52 {{#state.hasdiscussions}}
54d38a73
MG
53 {{{ pagination }}}
54 {{$discussion_list_output}}
55 <table class="table table-hover table-striped">
56 {{$discussion_list_header}}
57 <thead>
47d38303 58 <tr>
54d38a73
MG
59 <th scope="col">&nbsp;</th>
60 <th scope="col" class="p-l-0">{{#str}}discussion, mod_forum{{/str}}</th>
61 <th scope="col" class="author">{{#str}}startedby, mod_forum{{/str}}</th>
62 {{#forum.state.groupmode}}
63 <th scope="col" class="group">{{#str}}group{{/str}}</th>
64 {{/forum.state.groupmode}}
65 {{#forum.capabilities.viewdiscussions}}
66 <th scope="col" class="text-center">{{#str}}replies, mod_forum{{/str}}</th>
67 {{#forum.userstate.tracked}}
68 <th scope="col" class="text-center">
69 {{#str}}unread, mod_forum{{/str}}
70 <a href="{{{forum.urls.markasread}}}">{{#pix}}t/markasread, core, {{#str}}markallread, mod_forum{{/str}}{{/pix}}</a>
71 </th>
72 {{/forum.userstate.tracked}}
73 {{/forum.capabilities.viewdiscussions}}
74 <th scope="col" class="lastpost">{{#str}}lastpost, mod_forum{{/str}}</th>
75 {{#forum.capabilities.subscribe}}
76 <th scope="col" class="discussionsubscription"></th>
77 {{/forum.capabilities.subscribe}}
78 </tr>
79 </thead>
80 {{/discussion_list_header}}
81 {{$discussion_list_body}}
82 <tbody>
83 {{#summaries}}
c5477bfc
RW
84 <!-- The discussion class is only required for behat tests to identify the row -->
85 <tr class="discussion">
54d38a73
MG
86 <td scope="col" class="pinned p-0 text-center align-middle">
87 {{#discussion.pinned}}
88 {{#pix}}i/pinned, mod_forum, {{#str}}discussionpinned, mod_forum{{/str}}{{/pix}}
89 {{/discussion.pinned}}
90 </td>
91 <td scope="col" class="topic p-0">
c5477bfc 92 <a class="p-3 p-l-0 w-100 h-100 d-block" href="{{discussion.urls.view}}">{{{discussion.name}}}</a>
54d38a73
MG
93 </td>
94 <td scope="col" class="author">
95 {{#firstpostauthor}}
96 <a href="{{urls.profile}}">
97 <div class="d-flex flex-row">
98 <div class="align-middle p-0">
99 <a href="{{urls.profile}}">
100 <img {{!
101 }} class="h-auto rounded-circle userpicture" {{!
102 }} src="{{urls.profileimage}}" {{!
103 }} alt="{{#str}}pictureof, moodle, {{fullname}}{{/str}}" {{!
104 }}>
105 </a>
106 </div>
107 <div class="align-middle p-2">
108 <a href="{{urls.profile}}">{{fullname}}</a>
109 </div>
110 </div>
111 </a>
112 {{/firstpostauthor}}
113 </td>
114 {{#forum.state.groupmode}}
115 <td scope="col" class="group">
116 {{#discussion.group}}
117 {{#urls.picture}}
118 {{#urls.userlist}}
119 <a href="{{{urls.userlist}}}">
120 <img class="border rounded h-auto rounded-circle" src="{{{urls.picture}}}">
121 </a>
122 {{/urls.userlist}}
123 {{^urls.userlist}}
124 <img class="border rounded h-auto rounded-circle" src="{{{urls.picture}}}">
125 {{/urls.userlist}}
126 {{/urls.picture}}
127 {{^urls.picture}}
128 {{#urls.userlist}}
129 <a href="{{{urls.userlist}}}">{{name}}</a>
130 {{/urls.userlist}}
131 {{^urls.userlist}}
132 {{name}}
133 {{/urls.userlist}}
134 {{/urls.picture}}
135 {{/discussion.group}}
136 </td>
137 {{/forum.state.groupmode}}
138 {{#forum.capabilities.viewdiscussions}}
139 <td scope="col" class="p-0 text-center">
140 <a href="{{discussion.urls.view}}" class="p-3 w-100 h-100 d-block">
141 {{replies}}
142 </a>
143 </td>
144 {{#forum.userstate.tracked}}
145 <td scope="col" class="p-0 text-center">
146 {{#unread}}
147 {{! TODO Rewrite as AJAX}}
148 <div class="p-3 w-100 h-100 d-block">
149 <a href="{{{discussion.urls.viewfirstunread}}}">{{unread}}</a>
150 <a href="{{{discussion.urls.markasread}}}">{{#pix}}t/markasread, core, {{#str}}markalldread, mod_forum{{/str}}{{/pix}}</a>
151 </div>
152 {{/unread}}
153 {{^unread}}
154 <span class="p-3 w-100 h-100 d-block">
155 0
156 </span>
157 {{/unread}}
158 </td>
159 {{/forum.userstate.tracked}}
160 {{/forum.capabilities.viewdiscussions}}
161 <td scope="col" class="text-left">
162 {{! TODO Check q&a, eachuser }}
163 {{#latestpostid}}
47d38303
RW
164 <div class="d-flex flex-row">
165 <div class="align-middle p-0">
54d38a73 166 <a href="{{latestpostauthor.urls.profile}}">
47d38303
RW
167 <img {{!
168 }} class="h-auto rounded-circle userpicture" {{!
54d38a73
MG
169 }} src="{{latestpostauthor.urls.profileimage}}" {{!
170 }} alt="{{#str}}pictureof, moodle, {{latestpostauthor.fullname}}{{/str}}" {{!
47d38303
RW
171 }}>
172 </a>
173 </div>
54d38a73
MG
174 <div class="p-2 p-t-0 p-b-0 d-inline-flex flex-column">
175 <div>
176 <a href="{{latestpostauthor.urls.profile}}">{{latestpostauthor.fullname}}</a>
177 </div>
178 <div>
179 <a href="{{{discussion.urls.viewlatest}}}">{{#userdate}}
180 {{discussion.times.modified}}, {{#str}}strftimerecentfull{{/str}}
181 {{/userdate}}</a>
182 </div>
47d38303
RW
183 </div>
184 </div>
54d38a73 185 {{/latestpostid}}
47d38303 186 </td>
54d38a73
MG
187 <td scope="col" class="p-0 align-middle">
188 {{#discussion}}
189 {{> mod_forum/discussion_subscription_toggle}}
190 {{/discussion}}
47d38303 191 </td>
54d38a73
MG
192 </tr>
193 {{/summaries}}
194 </tbody>
195 {{/discussion_list_body}}
196 </table>
197 {{/discussion_list_output}}
198 {{$pagination_output}}
199 {{{ pagination }}}
200 {{/pagination_output}}
47d38303
RW
201 {{#can_create_discussion}}
202 <div class="forumaddnew">
203 <a href="{{create_discussion_link}}" class="btn btn-primary">{{create_discussion_link_text}}</a>
204 </div>
205 {{/can_create_discussion}}
206 {{/state.hasdiscussions}}
207 {{^state.hasdiscussions}}
208 <div class="forumnodiscuss">
209 {{$no_discussions_text}}
210 ({{#str}}nodiscussions, forum{{/str}})
211 {{/no_discussions_text}}
212 </div>
213 {{/state.hasdiscussions}}
214
2646e9d6
RW
215</div>
216{{#js}}
217 require(['jquery', 'mod_forum/discussion_list'], function($, View) {
218 var root = $('#discussion-list-{{uniqid}}');
219 View.init(root);
220 });
221{{/js}}