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 |
|
|
|
19 |
@template tool_supporter/user_table
|
|
|
20 |
Template which outputs a table of users.
|
|
|
21 |
|
|
|
22 |
Classes required for JS:
|
|
|
23 |
* dataTables
|
|
|
24 |
|
|
|
25 |
Context variables required for this template:
|
|
|
26 |
* users - array of arrays: user details to be displayed in a table.
|
|
|
27 |
|
|
|
28 |
Example context (json):
|
|
|
29 |
{
|
|
|
30 |
"users": [
|
|
|
31 |
{
|
|
|
32 |
"id": 1,
|
|
|
33 |
"idnumber": "",
|
|
|
34 |
"username": "guest",
|
|
|
35 |
"firstname": "Gast",
|
|
|
36 |
"lastname": " ",
|
|
|
37 |
"email": "root@localhost"
|
|
|
38 |
},
|
|
|
39 |
{
|
|
|
40 |
"id": 2,
|
|
|
41 |
"idnumber": "",
|
|
|
42 |
"username": "admin",
|
|
|
43 |
"firstname": "Admin",
|
|
|
44 |
"lastname": "Nutzer",
|
|
|
45 |
"email": "hasbvdjh@sabdhadbvsdaj.de"
|
|
|
46 |
},
|
|
|
47 |
{
|
|
|
48 |
"id": 3,
|
|
|
49 |
"idnumber": "",
|
|
|
50 |
"username": "testnutzer",
|
|
|
51 |
"firstname": "testnutzer",
|
|
|
52 |
"lastname": "testnutzer",
|
|
|
53 |
"email": "testnutzer@bsdahuvugdvsaudvusdaau.de"
|
|
|
54 |
},
|
|
|
55 |
{
|
|
|
56 |
"id": 4,
|
|
|
57 |
"idnumber": "Matrikel",
|
|
|
58 |
"username": "deaktiviert_suspended",
|
|
|
59 |
"firstname": "deaktiviert_suspended",
|
|
|
60 |
"lastname": "deaktiviert_suspended",
|
|
|
61 |
"email": "deaktiviert_suspended@sadhbsaudbsaudbvasubd.net"
|
|
|
62 |
}
|
|
|
63 |
],
|
|
|
64 |
"searchname": "Suchen",
|
|
|
65 |
"refreshname": "Aktualisieren"
|
|
|
66 |
}
|
|
|
67 |
|
|
|
68 |
}}
|
|
|
69 |
<div data-region="user_table" class="card rui-user-table">
|
|
|
70 |
<div class = "card-header">
|
|
|
71 |
<div class="row">
|
|
|
72 |
<div class="col">
|
|
|
73 |
<h4 class="card-title">{{#str}}users{{/str}}
|
|
|
74 |
<button class="ml-4 btn btn-xs p-1 btn-secondary" id="btn_refresh_users">{{#pix}} a/refresh, core, {{refreshname}} {{/pix}}</button>
|
|
|
75 |
</h4>
|
|
|
76 |
</div>
|
|
|
77 |
</div>
|
|
|
78 |
</div>
|
|
|
79 |
|
|
|
80 |
<div id="users_dynamic_search" class="btn-toolbar ml-3 mt-1" role="toolbar" style="visibility: hidden;">
|
|
|
81 |
<div class="btn-group pull-right" role="group">
|
|
|
82 |
<select id="user_table_column_chooser" class="form-control custom-select mr-1">
|
|
|
83 |
<!-- Additional Options are later added with javascript -->
|
|
|
84 |
<option selected value="-1">{{#str}}all{{/str}}</option>
|
|
|
85 |
</select>
|
|
|
86 |
</div>
|
|
|
87 |
<div class="btn-group" role="group" style="width: 60%">
|
|
|
88 |
<input type="text" id="user_table_search_input" class="form-control form-control-sm" placeholder={{searchname}}>
|
|
|
89 |
</div>
|
|
|
90 |
</div>
|
|
|
91 |
|
|
|
92 |
<div class = "table table-responsive">
|
|
|
93 |
<table class = "stripe hover row-border" id = "userTable">
|
|
|
94 |
<thead>
|
|
|
95 |
<tr>
|
|
|
96 |
<th>ID</th>
|
|
|
97 |
<th>{{#str}}idnumbermod{{/str}}</th>
|
|
|
98 |
<th>{{#str}}username{{/str}}</th>
|
|
|
99 |
<th>{{#str}}firstname{{/str}}</th>
|
|
|
100 |
<th>{{#str}}lastname{{/str}}</th>
|
|
|
101 |
<th>{{#str}}email{{/str}}</th>
|
|
|
102 |
</tr>
|
|
|
103 |
</thead>
|
|
|
104 |
<tbody>
|
|
|
105 |
</tbody>
|
|
|
106 |
</table>
|
|
|
107 |
</div>
|
|
|
108 |
<span class="loading-icon text-center" id="userTable-loadingIcon">{{#pix}} i/loading, core, {{#str}} loading {{/str}} {{/pix}}</span>
|
|
|
109 |
</div>
|
|
|
110 |
|
|
|
111 |
{{#js}}
|
|
|
112 |
require(['tool_supporter/load_information', 'jquery', 'core/ajax', 'core/notification', 'core/templates',
|
|
|
113 |
'tool_supporter/datatables', 'tool_supporter/table_filter'],
|
|
|
114 |
function(loadInformation, $, ajax, notification, templates, datatables, tableFilter) {
|
|
|
115 |
|
|
|
116 |
var columns = [
|
|
|
117 |
{data: 'id', name: 'ID'},
|
|
|
118 |
{data: 'idnumber', name: '{{#str}}idnumbermod{{/str}}'},
|
|
|
119 |
{data: 'username', name: '{{#str}}username{{/str}}'},
|
|
|
120 |
{data: 'firstname', name: '{{#str}}firstname{{/str}}'},
|
|
|
121 |
{data: 'lastname', name: '{{#str}}lastname{{/str}}'},
|
|
|
122 |
{data: 'email', name: '{{#str}}email{{/str}}'}
|
|
|
123 |
];
|
|
|
124 |
datatables.dataTableAjax('#userTable', 'tool_supporter_get_users', {}, 'users', columns);
|
|
|
125 |
|
|
|
126 |
// Refresh this table.
|
|
|
127 |
loadInformation.clickOnRefresh('#userTable', 'tool_supporter_get_users', {}, 'users', columns);
|
|
|
128 |
|
|
|
129 |
// Load detailed information about the clicked user.
|
|
|
130 |
loadInformation.clickOnUser('#userTable');
|
|
|
131 |
|
|
|
132 |
// Search the table.
|
|
|
133 |
tableFilter.searchTable('#userTable', '#user_table_column_chooser', '#user_table_search_input', columns);
|
|
|
134 |
});
|
|
|
135 |
{{/js}}
|