MDL-65033 mod_forum: Favouriting in forum
[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}}
71 <th scope="col" class="text-center">{{#str}}replies, mod_forum{{/str}}</th>
72 {{#forum.userstate.tracked}}
73 <th scope="col" class="text-center">
74 {{#str}}unread, mod_forum{{/str}}
75 <a href="{{{forum.urls.markasread}}}">{{#pix}}t/markasread, core, {{#str}}markallread, mod_forum{{/str}}{{/pix}}</a>
76 </th>
77 {{/forum.userstate.tracked}}
78 {{/forum.capabilities.viewdiscussions}}
79 <th scope="col" class="lastpost">{{#str}}lastpost, mod_forum{{/str}}</th>
9b4f09ba 80 <th scope="col">&nbsp;</th>
54d38a73
MG
81 {{#forum.capabilities.subscribe}}
82 <th scope="col" class="discussionsubscription"></th>
83 {{/forum.capabilities.subscribe}}
84 </tr>
85 </thead>
86 {{/discussion_list_header}}
87 {{$discussion_list_body}}
88 <tbody>
89 {{#summaries}}
c5477bfc 90 <!-- The discussion class is only required for behat tests to identify the row -->
7661ccdd 91 <tr class="discussion {{#discussion.timed}}{{#istimed}}{{^visible}}dimmed_text{{/visible}}{{/istimed}}{{/discussion.timed}}">
54d38a73
MG
92 <td scope="col" class="pinned p-0 text-center align-middle">
93 {{#discussion.pinned}}
94 {{#pix}}i/pinned, mod_forum, {{#str}}discussionpinned, mod_forum{{/str}}{{/pix}}
95 {{/discussion.pinned}}
99bda8a7
P
96 {{^discussion.pinned}}
97 {{#discussion.userstate.favourited}}
98 {{#pix}}i/pinned, mod_forum, {{#str}}discussionpinned, mod_forum{{/str}}{{/pix}}
99 {{/discussion.userstate.favourited}}
100 {{/discussion.pinned}}
54d38a73 101 </td>
7661ccdd 102 <td scope="col" class="topic p-0 align-middle">
c5477bfc 103 <a class="p-3 p-l-0 w-100 h-100 d-block" href="{{discussion.urls.view}}">{{{discussion.name}}}</a>
54d38a73 104 </td>
7661ccdd 105 <td scope="col" class="author align-middle">
54d38a73
MG
106 {{#firstpostauthor}}
107 <a href="{{urls.profile}}">
108 <div class="d-flex flex-row">
109 <div class="align-middle p-0">
110 <a href="{{urls.profile}}">
111 <img {{!
112 }} class="h-auto rounded-circle userpicture" {{!
113 }} src="{{urls.profileimage}}" {{!
114 }} alt="{{#str}}pictureof, moodle, {{fullname}}{{/str}}" {{!
115 }}>
116 </a>
117 </div>
118 <div class="align-middle p-2">
119 <a href="{{urls.profile}}">{{fullname}}</a>
120 </div>
121 </div>
122 </a>
123 {{/firstpostauthor}}
124 </td>
125 {{#forum.state.groupmode}}
126 <td scope="col" class="group">
127 {{#discussion.group}}
128 {{#urls.picture}}
129 {{#urls.userlist}}
130 <a href="{{{urls.userlist}}}">
131 <img class="border rounded h-auto rounded-circle" src="{{{urls.picture}}}">
132 </a>
133 {{/urls.userlist}}
134 {{^urls.userlist}}
135 <img class="border rounded h-auto rounded-circle" src="{{{urls.picture}}}">
136 {{/urls.userlist}}
137 {{/urls.picture}}
138 {{^urls.picture}}
139 {{#urls.userlist}}
140 <a href="{{{urls.userlist}}}">{{name}}</a>
141 {{/urls.userlist}}
142 {{^urls.userlist}}
143 {{name}}
144 {{/urls.userlist}}
145 {{/urls.picture}}
146 {{/discussion.group}}
147 </td>
148 {{/forum.state.groupmode}}
149 {{#forum.capabilities.viewdiscussions}}
7661ccdd 150 <td scope="col" class="p-0 text-center align-middle">
54d38a73
MG
151 <a href="{{discussion.urls.view}}" class="p-3 w-100 h-100 d-block">
152 {{replies}}
153 </a>
154 </td>
155 {{#forum.userstate.tracked}}
7661ccdd 156 <td scope="col" class="p-0 text-center align-middle">
54d38a73
MG
157 {{#unread}}
158 {{! TODO Rewrite as AJAX}}
159 <div class="p-3 w-100 h-100 d-block">
160 <a href="{{{discussion.urls.viewfirstunread}}}">{{unread}}</a>
161 <a href="{{{discussion.urls.markasread}}}">{{#pix}}t/markasread, core, {{#str}}markalldread, mod_forum{{/str}}{{/pix}}</a>
162 </div>
163 {{/unread}}
164 {{^unread}}
165 <span class="p-3 w-100 h-100 d-block">
166 0
167 </span>
168 {{/unread}}
169 </td>
170 {{/forum.userstate.tracked}}
171 {{/forum.capabilities.viewdiscussions}}
172 <td scope="col" class="text-left">
173 {{! TODO Check q&a, eachuser }}
174 {{#latestpostid}}
47d38303
RW
175 <div class="d-flex flex-row">
176 <div class="align-middle p-0">
54d38a73 177 <a href="{{latestpostauthor.urls.profile}}">
47d38303
RW
178 <img {{!
179 }} class="h-auto rounded-circle userpicture" {{!
54d38a73
MG
180 }} src="{{latestpostauthor.urls.profileimage}}" {{!
181 }} alt="{{#str}}pictureof, moodle, {{latestpostauthor.fullname}}{{/str}}" {{!
47d38303
RW
182 }}>
183 </a>
184 </div>
54d38a73
MG
185 <div class="p-2 p-t-0 p-b-0 d-inline-flex flex-column">
186 <div>
187 <a href="{{latestpostauthor.urls.profile}}">{{latestpostauthor.fullname}}</a>
188 </div>
189 <div>
190 <a href="{{{discussion.urls.viewlatest}}}">{{#userdate}}
191 {{discussion.times.modified}}, {{#str}}strftimerecentfull{{/str}}
192 {{/userdate}}</a>
193 </div>
47d38303
RW
194 </div>
195 </div>
54d38a73 196 {{/latestpostid}}
47d38303 197 </td>
9b4f09ba
P
198 <td scope="col" class="timed p-0 text-center align-middle">
199 {{#discussion.timed.istimed}}
200 <div class="timedpost">
201 {{#pix}}
202 i/calendar, moodle,
203 {{#discussion.times.start}}
204 {{! }}{{#str}} displaystart, mod_forum {{/str}}: {{#userdate}}{{.}}, {{#str}}strftimerecentfull {{/str}}{{/userdate}}
205 {{/discussion.times.start}}
206 {{#discussion.times.end}}
207 {{! }}{{#str}} displayend, mod_forum {{/str}}: {{#userdate}}{{.}}, {{#str}} strftimerecentfull {{/str}}{{/userdate}}
208 {{/discussion.times.end}}
209 {{#discussion.timed.visible}}
210 {{! }}{{#str}} timedvisible, mod_forum {{/str}}
211 {{/discussion.timed.visible}}
212 {{^discussion.timed.visible}}
213 {{! }}{{#str}} timedhidden, mod_forum {{/str}}
214 {{/discussion.timed.visible}}
215 {{/pix}}
216 </div>
217 {{/discussion.timed.istimed}}
218 </td>
54d38a73
MG
219 <td scope="col" class="p-0 align-middle">
220 {{#discussion}}
221 {{> mod_forum/discussion_subscription_toggle}}
222 {{/discussion}}
47d38303 223 </td>
54d38a73
MG
224 </tr>
225 {{/summaries}}
226 </tbody>
227 {{/discussion_list_body}}
228 </table>
229 {{/discussion_list_output}}
23f5e65e 230 {{$discussion_bottom_pagination}}
54d38a73 231 {{{ pagination }}}
23f5e65e 232 {{/discussion_bottom_pagination}}
47d38303
RW
233 {{#can_create_discussion}}
234 <div class="forumaddnew">
235 <a href="{{create_discussion_link}}" class="btn btn-primary">{{create_discussion_link_text}}</a>
236 </div>
237 {{/can_create_discussion}}
238 {{/state.hasdiscussions}}
239 {{^state.hasdiscussions}}
240 <div class="forumnodiscuss">
241 {{$no_discussions_text}}
242 ({{#str}}nodiscussions, forum{{/str}})
243 {{/no_discussions_text}}
244 </div>
245 {{/state.hasdiscussions}}
246
2646e9d6
RW
247</div>
248{{#js}}
249 require(['jquery', 'mod_forum/discussion_list'], function($, View) {
250 var root = $('#discussion-list-{{uniqid}}');
251 View.init(root);
252 });
253{{/js}}