MDL-75148 mod_data: Improve presets list page
[moodle.git] / mod / data / templates / presets.mustache
blob06754453dfea30e176ac51e389413d16a287fa06
1 {{!
2     This file is part of Moodle - http://moodle.org/
3     Moodle is free software: you can redistribute it and/or modify
4     it under the terms of the GNU General Public License as published by
5     the Free Software Foundation, either version 3 of the License, or
6     (at your option) any later version.
7     Moodle is distributed in the hope that it will be useful,
8     but WITHOUT ANY WARRANTY; without even the implied warranty of
9     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
10     GNU General Public License for more details.
11     You should have received a copy of the GNU General Public License
12     along with Moodle.  If not, see <http://www.gnu.org/licenses/>.
14 {{!
15     @template mod_data/presets
17     Form containing all database presets displayed within a table.
19     Context variables required for this template:
20     * formactionul - The form action url.
21     * d - The database id.
22     * presets - List of presets containing id, name, fullname, shortname and actions.
24     Example context (json):
25     {
26         "formactionul": "http://www.example.com",
27         "d": 1,
28         "presets": [
29             {
30                 "id": 1,
31                 "name": "Image gallery",
32                 "shortname": "imagegallery",
33                 "fullname": "Image gallery",
34                 "userid": 0,
35                 "actions": []
36             },
37             {
38                 "id": 2,
39                 "name": "Preset saved manually",
40                 "shortname": "Preset saved manually",
41                 "fullname": "Preset saved manually (admin)",
42                 "userid": 2,
43                 "actions": []
44             }
45         ]
46     }
48 {{#str}}presetshelp, mod_data{{/str}}
50 <form method="post" action="{{formactionul}}" class="mt-4">
51     <input type="hidden" name="d" value="{{d}}">
52     <input type="hidden" name="mode" value="usepreset">
53     <input type="hidden" name="action" value="select">
55     <table id="presets-list" class="generaltable fullwidth">
56         <thead>
57             <tr>
58                 <th class="pl-4 border-top-0" scope="col" style="width: 3%"></th>
59                 <th class="pl-4 border-top-0" scope="col">{{#str}} name {{/str}}</th>
60                 <th class="pl-4 border-top-0" scope="col" style="width: 3%">{{#showmanage}}{{#str}} action {{/str}}{{/showmanage}}</th>
61             </tr>
62         </thead>
63         <tbody>
64             {{#presets}}
65             <tr>
66                 <td class="p-4 border-right">
67                     <input type="radio" name="fullname" value="{{userid}}/{{shortname}}" />
68                 </td>
69                 <td class="p-4">{{fullname}}</td>
70                 <td class="p-4 preset_action_menu">
71                     {{#actions}}
72                         <div class="float-right">
73                             {{>core/action_menu}}
74                         </div>
75                     {{/actions}}
76                 </td>
77             </tr>
78             {{/presets}}
79         </tbody>
80     </table>
82     <input type="submit" name="selectpreset" value="{{#str}}usepreset, mod_data{{/str}}" class="btn btn-secondary mt-2 float-right" disabled>
83 </form>
85 {{#js}}
86     require(['mod_data/selectpreset'], function(selectPreset) {
87         selectPreset.init();
88     });
89 {{/js}}