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