1 |
efrain |
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 core_customfield/list
|
|
|
19 |
|
|
|
20 |
Moodle list template.
|
|
|
21 |
|
|
|
22 |
The purpose of this template is to render a list.
|
|
|
23 |
|
|
|
24 |
Classes required for JS:
|
|
|
25 |
* none
|
|
|
26 |
|
|
|
27 |
Data attributes required for JS:
|
|
|
28 |
* data-component
|
|
|
29 |
* data-area
|
|
|
30 |
* data-itemid
|
|
|
31 |
|
|
|
32 |
Context variables required for this template:
|
|
|
33 |
* attributes Array of name / value pairs.
|
|
|
34 |
|
|
|
35 |
Example context (json):
|
|
|
36 |
{
|
|
|
37 |
"component": "core_nonexisting",
|
|
|
38 |
"area": "course",
|
|
|
39 |
"itemid": 0,
|
|
|
40 |
"usescategories": 1,
|
|
|
41 |
"categories": [
|
|
|
42 |
{ "id": "0",
|
|
|
43 |
"nameeditable": "Other fields",
|
|
|
44 |
"addfieldmenu": "Add field",
|
|
|
45 |
"fields": [
|
|
|
46 |
{ "id": 0, "name": "Field name", "shortname": "shortname", "type": "Text" },
|
|
|
47 |
{ "id": 0, "name": "Another field", "shortname": "checkme", "type": "Checkbox" }
|
|
|
48 |
]
|
|
|
49 |
},
|
|
|
50 |
{ "id": "00",
|
|
|
51 |
"nameeditable": "Empty category",
|
|
|
52 |
"addfieldmenu": "Add field",
|
|
|
53 |
"fields": [] }
|
|
|
54 |
],
|
|
|
55 |
"singleselect" : "select"
|
|
|
56 |
}
|
|
|
57 |
}}
|
|
|
58 |
|
|
|
59 |
{{{alert}}}
|
|
|
60 |
|
|
|
61 |
<div data-region="list-page" id="customfield_catlist" data-component="{{component}}" data-area="{{area}}" data-itemid="{{itemid}}">
|
|
|
62 |
<div class="row">
|
|
|
63 |
<div class="col align-self-end">
|
|
|
64 |
{{#usescategories}}
|
|
|
65 |
<a tabindex="0" role="button" class="btn btn-secondary float-right" data-role="addnewcategory">{{#str}}addnewcategory, core_customfield{{/str}}</a>
|
|
|
66 |
{{/usescategories}}
|
|
|
67 |
</div>
|
|
|
68 |
</div>
|
|
|
69 |
|
|
|
70 |
{{^categories}}
|
|
|
71 |
{{{nocategories}}}
|
|
|
72 |
{{/categories}}
|
|
|
73 |
|
|
|
74 |
<div class="categorieslist">
|
|
|
75 |
{{#categories}}
|
|
|
76 |
<div data-category-id="{{id}}" id="category-{{id}}" class="mt-2">
|
|
|
77 |
<div class="row justify-content-between align-items-center">
|
|
|
78 |
<div class="col-6 categoryinstance">
|
|
|
79 |
{{#usescategories}}
|
|
|
80 |
<h3 class="d-inline-flex align-items-center">
|
|
|
81 |
<span class="movecategory mr-2">
|
|
|
82 |
{{> core/drag_handle}}</span>{{{nameeditable}}}
|
|
|
83 |
<a href="#" data-role="deletecategory" class="ml-3" data-id="{{id}}">{{#pix}}
|
|
|
84 |
t/delete, core, {{#str}} delete, moodle {{/str}} {{/pix}}</a>
|
|
|
85 |
</h3>
|
|
|
86 |
{{/usescategories}}
|
|
|
87 |
</div>
|
|
|
88 |
<div class="col-auto text-right">
|
|
|
89 |
{{{addfieldmenu}}}
|
|
|
90 |
</div>
|
|
|
91 |
</div>
|
|
|
92 |
<div>
|
|
|
93 |
<table class="generaltable fullwidth fieldslist">
|
|
|
94 |
<thead>
|
|
|
95 |
<tr>
|
|
|
96 |
<th scope="col">{{#str}} customfield, core_customfield {{/str}}</th>
|
|
|
97 |
<th scope="col">{{#str}} shortname, core_customfield {{/str}}</th>
|
|
|
98 |
<th scope="col">{{#str}} type, core_customfield {{/str}}</th>
|
|
|
99 |
<th scope="col" class="text-right">{{#str}} action, core_customfield {{/str}}</th>
|
|
|
100 |
</tr>
|
|
|
101 |
</thead>
|
|
|
102 |
<tbody>
|
|
|
103 |
{{#fields}}
|
|
|
104 |
<tr data-field-name="{{name}}" data-field-id="{{id}}" class="field">
|
|
|
105 |
<td><span class="movefield mr-2">{{> core/drag_handle}}</span>{{{name}}}</td>
|
|
|
106 |
<td><span class="small">{{{shortname}}}</span></td>
|
|
|
107 |
<td><span class="badge bage-light">{{{type}}}</div></td>
|
|
|
108 |
<td class="table-buttons text-right">
|
|
|
109 |
<a href="#" data-role="editfield" data-name="{{name}}" data-id="{{id}}">{{#pix}}
|
|
|
110 |
t/edit, core, {{#str}} edit, moodle {{/str}} {{/pix}}</a>
|
|
|
111 |
<a href="#" data-id="{{id}}" data-role="deletefield">{{#pix}}
|
|
|
112 |
t/delete, core, {{#str}} delete, moodle {{/str}} {{/pix}}</a>
|
|
|
113 |
</td>
|
|
|
114 |
</tr>
|
|
|
115 |
{{/fields}}
|
|
|
116 |
{{^fields}}
|
|
|
117 |
<tr class="nofields"><td colspan="4">{{# str }} therearenofields, core_customfield {{/ str }}</td></tr>
|
|
|
118 |
{{/fields}}
|
|
|
119 |
</tbody>
|
|
|
120 |
</table>
|
|
|
121 |
</div>
|
|
|
122 |
</div>
|
|
|
123 |
{{/categories}}
|
|
|
124 |
</div>
|
|
|
125 |
</div>
|
|
|
126 |
|
|
|
127 |
{{#js}}
|
|
|
128 |
require(['core_customfield/form'], function(s) {
|
|
|
129 |
s.init();
|
|
|
130 |
});
|
|
|
131 |
{{/js}}
|