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