MDL-65069 mod_forum: Stripped out inpage form and advanced redirect
[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 class="btn btn-primary" data-toggle="collapse" href="#collapseAddForm">
45                 {{$discussion_create_text}}
46                     {{#str}}addanewdiscussion, forum{{/str}}
47                 {{/discussion_create_text}}
48             </a>
49             <div class="collapse m-t-1" id="collapseAddForm">
50                 {{{newdiscussionhtml}}}
51             </div>
52         </div>
53     {{/forum.capabilities.create}}
55     {{#state.hasdiscussions}}
56         {{$discussion_top_pagination}}
57             {{{ pagination }}}
58         {{/discussion_top_pagination}}
59         {{$discussion_list_output}}
60             <table class="table table-hover table-striped">
61                 {{$discussion_list_header}}
62                 <thead>
63                     <tr>
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>
80                         <th scope="col">&nbsp;</th>
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}}
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}}
96                             </td>
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>
99                             </td>
100                             <td scope="col" class="author align-middle">
101                                 {{#firstpostauthor}}
102                                     <a href="{{urls.profile}}">
103                                         <div class="d-flex flex-row">
104                                             <div class="align-middle p-0">
105                                                 <a href="{{urls.profile}}">
106                                                     <img {{!
107                                                         }} class="h-auto rounded-circle userpicture" {{!
108                                                         }} src="{{urls.profileimage}}" {{!
109                                                         }} alt="{{#str}}pictureof, moodle, {{fullname}}{{/str}}" {{!
110                                                         }}>
111                                                 </a>
112                                             </div>
113                                             <div class="align-middle p-2">
114                                                 <a href="{{urls.profile}}">{{fullname}}</a>
115                                             </div>
116                                         </div>
117                                     </a>
118                                 {{/firstpostauthor}}
119                             </td>
120                             {{#forum.state.groupmode}}
121                                 <td scope="col" class="group">
122                                     {{#discussion.group}}
123                                         {{#urls.picture}}
124                                             {{#urls.userlist}}
125                                                 <a href="{{{urls.userlist}}}">
126                                                     <img class="border rounded h-auto rounded-circle" src="{{{urls.picture}}}">
127                                                 </a>
128                                             {{/urls.userlist}}
129                                             {{^urls.userlist}}
130                                                 <img class="border rounded h-auto rounded-circle" src="{{{urls.picture}}}">
131                                             {{/urls.userlist}}
132                                         {{/urls.picture}}
133                                         {{^urls.picture}}
134                                             {{#urls.userlist}}
135                                                 <a href="{{{urls.userlist}}}">{{name}}</a>
136                                             {{/urls.userlist}}
137                                             {{^urls.userlist}}
138                                                 {{name}}
139                                             {{/urls.userlist}}
140                                         {{/urls.picture}}
141                                     {{/discussion.group}}
142                                 </td>
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">
147                                         {{replies}}
148                                     </a>
149                                 </td>
150                                 {{#forum.userstate.tracked}}
151                                     <td scope="col" class="p-0 text-center align-middle">
152                                         {{#unread}}
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>
157                                             </div>
158                                         {{/unread}}
159                                         {{^unread}}
160                                             <span class="p-3 w-100 h-100 d-block">
161                                                 0
162                                             </span>
163                                         {{/unread}}
164                                     </td>
165                                 {{/forum.userstate.tracked}}
166                             {{/forum.capabilities.viewdiscussions}}
167                             <td scope="col" class="text-left">
168                                 {{! TODO Check q&a, eachuser }}
169                                 {{#latestpostid}}
170                                     <div class="d-flex flex-row">
171                                         <div class="align-middle p-0">
172                                             <a href="{{latestpostauthor.urls.profile}}">
173                                                 <img {{!
174                                                     }} class="h-auto rounded-circle userpicture" {{!
175                                                     }} src="{{latestpostauthor.urls.profileimage}}" {{!
176                                                     }} alt="{{#str}}pictureof, moodle, {{latestpostauthor.fullname}}{{/str}}" {{!
177                                                     }}>
178                                             </a>
179                                         </div>
180                                         <div class="p-2 p-t-0 p-b-0 d-inline-flex flex-column">
181                                             <div>
182                                                 <a href="{{latestpostauthor.urls.profile}}">{{latestpostauthor.fullname}}</a>
183                                             </div>
184                                             <div>
185                                                 <a href="{{{discussion.urls.viewlatest}}}">{{#userdate}}
186                                                     {{discussion.times.modified}}, {{#str}}strftimerecentfull{{/str}}
187                                                 {{/userdate}}</a>
188                                             </div>
189                                         </div>
190                                     </div>
191                                 {{/latestpostid}}
192                             </td>
193                             <td scope="col" class="timed p-0 text-center align-middle">
194                                 {{#discussion.timed.istimed}}
195                                 <div class="timedpost">
196                                     {{#pix}}
197                                     i/calendar, moodle,
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}}
210                                     {{/pix}}
211                                 </div>
212                                 {{/discussion.timed.istimed}}
213                             </td>
214                             <td scope="col" class="p-0 align-middle">
215                                 {{#discussion}}
216                                     {{> mod_forum/discussion_subscription_toggle}}
217                                 {{/discussion}}
218                             </td>
219                         </tr>
220                     {{/summaries}}
221                 </tbody>
222                 {{/discussion_list_body}}
223             </table>
224         {{/discussion_list_output}}
225         {{$discussion_bottom_pagination}}
226             {{{ 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>
231             </div>
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}}
239         </div>
240     {{/state.hasdiscussions}}
242 </div>
243 {{#js}}
244     require(['jquery', 'mod_forum/discussion_list'], function($, View) {
245         var root = $('#discussion-list-{{uniqid}}');
246         View.init(root);
247     });
248 {{/js}}