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