MDL-66372 forumreport_summary: Tidy up per page and bulk ops handling
[moodle.git] / mod / forum / report / summary / templates / bulk_action_menu.mustache
CommitLineData
d4d9b8c6
MH
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 forumreport_summary/bulk_action_menu
19
20 Summary report filters.
21
22 Example context (json):
23 {
20b064be 24 "showbulkactions": true,
d4d9b8c6
MH
25 "id": "formactionid",
26 "attributes": [
27 {
28 "name": "data-action",
29 "value": "toggle"
30 },
31 {
32 "name": "data-togglegroup",
33 "value": "summaryreport-table"
34 },
35 {
36 "name": "data-toggle",
37 "value": "action"
38 }
39 ],
40 "actions": [
41 {
42 "name": "Choose...",
43 "value": ""
44 },
45 {
46 "name": "Send a message",
47 "value": "#messageselect"
48 }
20b064be
MH
49 ],
50 "perpage" : "<div class='singleselect'></div>"
d4d9b8c6
MH
51 }
52}}
53
20b064be
MH
54<br />
55<div class="d-inline-block w-100">
56 {{#showbulkactions}}
57 <div class="buttons float-left">
58 <div class="form-inline pl-1">
59 <label for="{{id}}">{{#str}}withselectedusers{{/str}}</label>
60 <select id="{{id}}" class="select custom-select ml-4" {{#attributes}}{{name}}="{{value}}" {{/attributes}}>
61 <option value="">{{#str}}choosedots{{/str}}</option>
62 {{#actions}}
63 <option value="{{value}}">{{name}}</option>
64 {{/actions}}
65 </select>
66 </div>
67 </div>
68 {{/showbulkactions}}
69 <div class="float-right">
cf8393be
MH
70 {{#perpage}}
71 {{> core/single_select}}
72 {{/perpage}}
20b064be
MH
73 </div>
74</div>
75
0942e58c
SR
76{{#js}}
77require(['jquery', 'core_message/message_send_bulk'], function($, BulkSender) {
78 $('#{{id}}').on('change', function(e) {
79 var action = $(e.target).val();
80 if (action.indexOf('#') !== -1) {
81 e.preventDefault();
82
83 var ids = $('#summaryreport input.usercheckbox:checked').map(function(index, element) {
84 return element.name.replace('user', '');
85 }).get();
86
87 if (action == '#messageselect') {
88 BulkSender.showModal(ids, function() {
89 $('#{{id}}').focus();
90 });
91 }
92
93 $('#{{id}} option[value=""]').prop('selected', 'selected');
94 }
95 });
96});
97{{/js}}