Merge branch 'MDL-66273-MOODLE-311-v2' of https://github.com/golenkovm/moodle into...
[moodle.git] / user / templates / edit_profile_fields.mustache
blob97faa9e4b8b421f4c3e4409bf7ab5f03d3afd53a
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/>.
17 {{!
18     @template core_user/edit_profile_fields
20     UI for editing profile fields
22     Example context (json):
23     {
24         "baseurl": "index.php",
25         "sesskey": "12345",
26         "categories": [
27             {
28                 "id": 1,
29                 "name": "Cat1",
30                 "fields": [
31                     {"id": 1, "name": "Field1", "isfirst": true, "islast": false},
32                     {"id": 2, "name": "Field2", "isfirst": false, "islast": false},
33                     {"id": 3, "name": "Field3", "isfirst": false, "islast": true}
34                 ],
35                 "hasfields": true,
36                 "isfirst": true,
37                 "candelete": true
38             },
39             {
40                 "id": 2,
41                 "name": "Cat2",
42                 "candelete": true
43             },
44             {
45                 "id": 3,
46                 "name": "Cat3",
47                 "islast": true,
48                 "candelete": true
49             }
50         ]
51     }
54 <div class="row profileeditor">
55     <div class="col align-self-end">
56         <a tabindex="0" role="button" class="btn btn-secondary float-right" data-action="editcategory">{{#str}}profilecreatecategory, admin{{/str}}</a>
57     </div>
58 </div>
60 <div class="categorieslist">
61 {{#categories}}
62 <div data-category-id="{{id}}" id="category-{{id}}" class="mt-2">
63     <div class="row justify-content-between align-items-end">
64         <div class="col-6 categoryinstance">
65             <h3>
66                 {{{name}}}
67                 <a href="#" data-action="editcategory" data-id="{{id}}" data-name="{{name}}">
68                     {{#pix}}t/edit, core, {{#str}}edit{{/str}}{{/pix}}</a>
69                 {{#candelete}}
70                     <a href="{{baseurl}}?action=deletecategory&id={{id}}&sesskey={{sesskey}}">
71                     {{#pix}}t/delete, core, {{#str}}delete{{/str}}{{/pix}}</a>
72                 {{/candelete}}
73                 {{^isfirst}}
74                     <a href="{{baseurl}}?id={{id}}&action=movecategory&dir=up&amp;sesskey={{sesskey}}">
75                     {{#pix}}t/up, core, {{#str}}moveup{{/str}}{{/pix}}</a>
76                 {{/isfirst}}
77                 {{#isfirst}}{{#pix}}spacer, moodle{{/pix}}{{/isfirst}}
78                 {{^islast}}
79                     <a href="{{baseurl}}?id={{id}}&action=movecategory&dir=down&amp;sesskey={{sesskey}}">
80                     {{#pix}}t/down, core, {{#str}}movedown{{/str}}{{/pix}}</a>
81                 {{/islast}}
82             </h3>
83         </div>
84         <div class="col-auto text-right">
85             {{#addfieldmenu}}{{> core/action_menu}}{{/addfieldmenu}}
86         </div>
87     </div>
89     <table class="generaltable fullwidth profilefield">
90         {{#hasfields}}
91             <thead>
92                 <tr>
93                     <th scope="col" class="col-8">{{#str}}profilefield, admin{{/str}}</th>
94                     <th scope="col" class="col-3 text-right">{{#str}}edit{{/str}}</th>
95                 </tr>
96             </thead>
97             <tbody>
98                 {{#fields}}
99                     <tr>
100                         <td class="col-8">
101                             {{{name}}}
102                         </td>
103                         <td class="col-3 text-right">
104                             <a href="#" data-action="editfield" data-id="{{id}}" data-name="{{name}}">
105                                 {{#pix}}t/edit, core, {{#str}}edit{{/str}}{{/pix}}</a>
106                             <a href="{{baseurl}}?action=deletefield&id={{id}}&sesskey={{sesskey}}">
107                                 {{#pix}}t/delete, core, {{#str}}delete{{/str}}{{/pix}}</a>
108                             {{^isfirst}}
109                                 <a href="{{baseurl}}?id={{id}}&action=movefield&dir=up&amp;sesskey={{sesskey}}">
110                                 {{#pix}}t/up, core, {{#str}}moveup{{/str}}{{/pix}}</a>
111                             {{/isfirst}}
112                             {{#isfirst}}{{#pix}}spacer, moodle{{/pix}}{{/isfirst}}
113                             {{^islast}}
114                                 <a href="{{baseurl}}?id={{id}}&action=movefield&dir=down&amp;sesskey={{sesskey}}">
115                                 {{#pix}}t/down, core, {{#str}}movedown{{/str}}{{/pix}}</a>
116                             {{/islast}}
117                             {{#islast}}{{#pix}}spacer, moodle{{/pix}}{{/islast}}
118                         </td>
119                     </tr>
120                 {{/fields}}
121             </tbody>
122         {{/hasfields}}
123         {{^hasfields}}
124             <thead>
125                 <tr class="nofields alert alert-danger alert-block fade in">
126                     <td>
127                         {{#str}}profilenofieldsdefined, admin{{/str}}
128                     </td>
129                 </tr>
130             </thead>
131         {{/hasfields}}
132     </table>
133 </div>
134 {{/categories}}
135 </div>
137 {{#js}}
138     require(['core_user/edit_profile_fields'], function(s) {
139         s.init();
140     });
141 {{/js}}