5f8871155f3a5bff93d0a7e218b1c69ed6007d42
[moodle.git] / mod / forum / report / summary / templates / bulk_action_menu.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 forumreport_summary/bulk_action_menu
20     Summary report filters.
22     Example context (json):
23     {
24         "showbulkactions": true,
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             }
49         ],
50         "perpage" : "<div class='singleselect'></div>"
51     }
52 }}
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">
70         {{{perpage}}}
71     </div>
72 </div>
74 {{#js}}
75 require(['jquery', 'core_message/message_send_bulk'], function($, BulkSender) {
76     $('#{{id}}').on('change', function(e) {
77         var action = $(e.target).val();
78         if (action.indexOf('#') !== -1) {
79             e.preventDefault();
81             var ids = $('#summaryreport input.usercheckbox:checked').map(function(index, element) {
82                 return element.name.replace('user', '');
83             }).get();
85             if (action == '#messageselect') {
86                 BulkSender.showModal(ids, function() {
87                     $('#{{id}}').focus();
88                 });
89             }
91             $('#{{id}} option[value=""]').prop('selected', 'selected');
92         }
93     });
94 });
95 {{/js}}