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/>.
18 @template mod_forum/discussion_list
20 Template to display the list of forum discussions.
22 Classes required for JS:
25 Data attributes required for JS:
28 Context variables required for this template:
31 Example context (json):
35 <div id="discussion-list-{{uniqid}}">
39 {{> core/notification}}
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}}
49 <div class="collapse m-t-1" id="collapseAddForm">
50 {{{newdiscussionhtml}}}
53 {{/forum.capabilities.create}}
55 {{#state.hasdiscussions}}
56 {{$discussion_top_pagination}}
58 {{/discussion_top_pagination}}
59 {{$discussion_list_output}}
60 <table class="table table-hover table-striped">
61 {{$discussion_list_header}}
64 <th scope="col"> </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>
77 {{/forum.userstate.tracked}}
78 {{/forum.capabilities.viewdiscussions}}
79 <th scope="col" class="lastpost">{{#str}}lastpost, mod_forum{{/str}}</th>
80 <th scope="col"> </th>
81 {{#forum.capabilities.subscribe}}
82 <th scope="col" class="discussionsubscription"></th>
83 {{/forum.capabilities.subscribe}}
86 {{/discussion_list_header}}
87 {{$discussion_list_body}}
90 <!-- The discussion class is only required for behat tests to identify the row -->
91 <tr class="discussion {{#discussion.timed}}{{#istimed}}{{^visible}}dimmed_text{{/visible}}{{/istimed}}{{/discussion.timed}}">
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}}
97 <td scope="col" class="topic p-0 align-middle">
98 <a class="p-3 p-l-0 w-100 h-100 d-block" href="{{discussion.urls.view}}">{{{discussion.name}}}</a>
100 <td scope="col" class="author align-middle">
102 <a href="{{urls.profile}}">
103 <div class="d-flex flex-row">
104 <div class="align-middle p-0">
105 <a href="{{urls.profile}}">
107 }} class="h-auto rounded-circle userpicture" {{!
108 }} src="{{urls.profileimage}}" {{!
109 }} alt="{{#str}}pictureof, moodle, {{fullname}}{{/str}}" {{!
113 <div class="align-middle p-2">
114 <a href="{{urls.profile}}">{{fullname}}</a>
120 {{#forum.state.groupmode}}
121 <td scope="col" class="group">
122 {{#discussion.group}}
125 <a href="{{{urls.userlist}}}">
126 <img class="border rounded h-auto rounded-circle" src="{{{urls.picture}}}">
130 <img class="border rounded h-auto rounded-circle" src="{{{urls.picture}}}">
135 <a href="{{{urls.userlist}}}">{{name}}</a>
141 {{/discussion.group}}
143 {{/forum.state.groupmode}}
144 {{#forum.capabilities.viewdiscussions}}
145 <td scope="col" class="p-0 text-center align-middle">
146 <a href="{{discussion.urls.view}}" class="p-3 w-100 h-100 d-block">
150 {{#forum.userstate.tracked}}
151 <td scope="col" class="p-0 text-center align-middle">
153 {{! TODO Rewrite as AJAX}}
154 <div class="p-3 w-100 h-100 d-block">
155 <a href="{{{discussion.urls.viewfirstunread}}}">{{unread}}</a>
156 <a href="{{{discussion.urls.markasread}}}">{{#pix}}t/markasread, core, {{#str}}markalldread, mod_forum{{/str}}{{/pix}}</a>
160 <span class="p-3 w-100 h-100 d-block">
165 {{/forum.userstate.tracked}}
166 {{/forum.capabilities.viewdiscussions}}
167 <td scope="col" class="text-left">
168 {{! TODO Check q&a, eachuser }}
170 <div class="d-flex flex-row">
171 <div class="align-middle p-0">
172 <a href="{{latestpostauthor.urls.profile}}">
174 }} class="h-auto rounded-circle userpicture" {{!
175 }} src="{{latestpostauthor.urls.profileimage}}" {{!
176 }} alt="{{#str}}pictureof, moodle, {{latestpostauthor.fullname}}{{/str}}" {{!
180 <div class="p-2 p-t-0 p-b-0 d-inline-flex flex-column">
182 <a href="{{latestpostauthor.urls.profile}}">{{latestpostauthor.fullname}}</a>
185 <a href="{{{discussion.urls.viewlatest}}}">{{#userdate}}
186 {{discussion.times.modified}}, {{#str}}strftimerecentfull{{/str}}
193 <td scope="col" class="timed p-0 text-center align-middle">
194 {{#discussion.timed.istimed}}
195 <div class="timedpost">
198 {{#discussion.times.start}}
199 {{! }}{{#str}} displaystart, mod_forum {{/str}}: {{#userdate}}{{.}}, {{#str}}strftimerecentfull {{/str}}{{/userdate}}
200 {{/discussion.times.start}}
201 {{#discussion.times.end}}
202 {{! }}{{#str}} displayend, mod_forum {{/str}}: {{#userdate}}{{.}}, {{#str}} strftimerecentfull {{/str}}{{/userdate}}
203 {{/discussion.times.end}}
204 {{#discussion.timed.visible}}
205 {{! }}{{#str}} timedvisible, mod_forum {{/str}}
206 {{/discussion.timed.visible}}
207 {{^discussion.timed.visible}}
208 {{! }}{{#str}} timedhidden, mod_forum {{/str}}
209 {{/discussion.timed.visible}}
212 {{/discussion.timed.istimed}}
214 <td scope="col" class="p-0 align-middle">
216 {{> mod_forum/discussion_subscription_toggle}}
222 {{/discussion_list_body}}
224 {{/discussion_list_output}}
225 {{$discussion_bottom_pagination}}
227 {{/discussion_bottom_pagination}}
228 {{#can_create_discussion}}
229 <div class="forumaddnew">
230 <a href="{{create_discussion_link}}" class="btn btn-primary">{{create_discussion_link_text}}</a>
232 {{/can_create_discussion}}
233 {{/state.hasdiscussions}}
234 {{^state.hasdiscussions}}
235 <div class="forumnodiscuss">
236 {{$no_discussions_text}}
237 ({{#str}}nodiscussions, forum{{/str}})
238 {{/no_discussions_text}}
240 {{/state.hasdiscussions}}
244 require(['jquery', 'mod_forum/discussion_list'], function($, View) {
245 var root = $('#discussion-list-{{uniqid}}');