b48abd3e305aeb90dd521f757e8e3340a613ef59
[moodle.git] / admin / tool / lp / templates / manage_templates_page.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     Manage learning plan templates template.
20     Classes required for JS:
21     * drag-parentnode
22     * drag-samenode
23     * templateactions
25     Data attibutes required for JS:
26     * data-region = managetemplates
27     * data-templateid = id
28     * data-action = deletetemplate
30     Context variables required for this template:
31     * templates - array of objects containing id, shortname, visible, canmanage, contextname
32     * navigation - array of strings containing buttons for navigation
33 }}
34 <div data-region="managetemplates">
35 <div class="btn-group pull-right">
36     {{#navigation}}
37     {{{.}}}
38     {{/navigation}}
39 </div>
40 <table class="generaltable fullwidth managetemplates">
41     <caption>{{#str}}listtemplatescaption, tool_lp{{/str}}</caption>
42     <thead>
43         <tr>
44             <th scope="col">{{#str}}templatename, tool_lp{{/str}}</th>
45             <th scope="col">{{#str}}context, core_role{{/str}}</th>
46             <th scope="col">{{#str}}cohorts, core_cohort{{/str}}</th>
47             <th scope="col">{{#str}}userplans, tool_lp{{/str}}</th>
48             {{#canmanage}}
49             <th scope="col">{{#str}}actions, tool_lp{{/str}}</th>
50             {{/canmanage}}
51         </tr>
52     </thead>
53     <tbody class="drag-parentnode">
54         {{#templates}}
55         <tr class="drag-samenode" data-templateid="{{id}}">
56             <td><a href="{{pluginbaseurl}}/templatecompetencies.php?templateid={{id}}&amp;pagecontextid={{pagecontextid}}">{{shortname}}</a></span> {{^visible}}{{#str}}hiddenhint, tool_lp{{/str}}{{/visible}}</td>
57             <td>{{contextname}}</td>
58             <td><a class="template-cohorts" href="{{pluginbaseurl}}/template_cohorts.php?id={{id}}&amp;pagecontextid={{pagecontextid}}">{{cohortscount}}</a></td>
59             <td><a class="template-userplans" href="{{pluginbaseurl}}/template_plans.php?id={{id}}&amp;pagecontextid={{pagecontextid}}">{{planscount}}</a></td>
60             <td>
61             {{#canmanage}}
62             <ul class="templateactions">
63                 <li>
64                     <a href="#">{{#str}}edit{{/str}}</a><b class="caret"></b>
65                     <ul class="dropdown-menu">
66                         <li>
67                             <a href="{{pluginbaseurl}}/edittemplate.php?id={{id}}&amp;pagecontextid={{pagecontextid}}&amp;return=templates">
68                                 {{#pix}}t/edit{{/pix}} {{#str}}edit{{/str}}
69                             </a>
70                         </li>
71                         <li>
72                             <a data-action="duplicatetemplate" data-templateid="{{id}}" href="#">
73                                 {{#pix}}t/copy{{/pix}} {{#str}}duplicate{{/str}}
74                             </a>
75                         </li>
76                         <li>
77                             <a data-action="deletetemplate" data-templateid="{{id}}" href="#">
78                                 {{#pix}}t/delete{{/pix}} {{#str}}delete{{/str}}
79                             </a>
80                         </li>
81                     </ul>
82                 </li>
83             </ul>
84             {{/canmanage}}
85             </td>
86         </tr>
87         {{/templates}}
88     </tbody>
89 </table>
90 {{^templates}}
91 <p class="alert-info">
92     {{#str}}notemplates, tool_lp{{/str}}
93 </p>
94 {{/templates}}
96 {{#js}}
97 // Initialise the JS.
98 require(['tool_lp/templateactions',
99          'tool_lp/menubar'],
100         function(actionsMod, menubar) {
102     actionsMod.init({{pagecontextid}});
104     menubar.enhance('.templateactions', {
105         '[data-action="deletetemplate"]': actionsMod.deleteHandler,
106         '[data-action="duplicatetemplate"]': actionsMod.duplicateHandler
107     });
108 });
110 {{/js}}
112 </div>