summaryrefslogtreecommitdiffstats
path: root/modules-available/permissionmanager/templates/userstable.html
blob: 9f684e995378b835895d1a6c3a36a7a25782a0fe (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
<form method="post" action="?do=permissionmanager&show=users">
	<input type="hidden" name="token" value="{{token}}">

	<div class="row">
		<div class="col-md-4">
		</div>
		<div class="col-md-4">
			<select multiple name="roles[]" id="select-role">
				<option value>{{lang_selectizePlaceholder}}</option>
				{{#roles}}
				<option value="{{roleid}}">{{rolename}}</option>
				{{/roles}}
			</select>
		</div>
		<div class="col-md-4 text-right">
			<button class="btn btn-success" type="button" data-toggle="modal" data-target="#addRoleToUserModal"><span class="glyphicon glyphicon-share-alt"></span> {{lang_addRole}}</button>
			<button class="btn btn-danger" type="button" data-toggle="modal" data-target="#removeRoleFromUserModal"><span class="glyphicon glyphicon-trash"></span> {{lang_removeRole}}</button>
		</div>
	</div>

	<div class="row">
		<div class="col-md-12">
			<table id="usersTable" class="table table-condensed table-hover stupidtable dataTable">
				<thead>
					<tr>
						<th data-sort="string">{{lang_Users}}</th>
						<th>{{lang_Roles}}</th>
						<th data-sort="int" data-sort-default="desc">{{lang_Selected}}</th>
					</tr>
				</thead>

				<tbody>
				{{#user}}
					<tr data-selectizeCount='0'>
						<td>{{username}}</td>
						<td>
							{{#roles}}
							<span class="label label-default customSpanMargin roleid-{{roleid}}">{{rolename}}</span>
							{{/roles}}
						</td>
						<td data-sort-value="0">
							<div class="checkbox">
								<input id="{{userid}}" type="checkbox" name="users[]" value='{{userid}}'>
								<label for="{{userid}}"></label>
							</div>
						</td>
					</tr>
				{{/user}}
				</tbody>
			</table>
		</div>
	</div>

	<!-- Modals -->
	<div class ="modal fade" id="addRoleToUserModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
		<div class="modal-dialog" role="document">
			<div class="modal-content">
				<div class="modal-header">
					<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
					<h4 class="modal-title" id="myModalLabel">{{lang_addRole}}</h4>
				</div>
				<div class="modal-body">
					<div class="row">
						<div class="col-md-12 scrollingTable">
							<table id="addRoleToUserTable" class="table table-condensed table-hover stupidtable">
								<thead>
									<tr>
										<th data-sort="string">{{lang_Roles}}</th>
										<th data-sort="int" data-sort-default="desc">{{lang_Selected}}</th>
									</tr>
								</thead>

								<tbody>
								{{#roles}}
									<tr>
										<td>{{rolename}}</td>
										<td data-sort-value="0">
											<div class="checkbox">
												<input id="add{{roleid}}" type="checkbox" name="roles[]" value='{{roleid}}'>
												<label for="add{{roleid}}"></label>
											</div>
										</td>
									</tr>
								{{/roles}}
								</tbody>
							</table>
						</div>
					</div>
				</div>
				<div class="modal-footer">
					<button type="button" class="btn btn-default" data-dismiss="modal">{{lang_cancel}}</button>
					<button type="submit" name="action" value="addRoleToUser" class="btn btn-success"  onclick="clearRemoveRoleModal()"><span class="glyphicon glyphicon-share-alt"></span> {{lang_addRole}}</button>
				</div>
			</div>
		</div>
	</div>

	<div class ="modal fade" id="removeRoleFromUserModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
		<div class="modal-dialog" role="document">
			<div class="modal-content">
				<div class="modal-header">
					<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
					<h4 class="modal-title" id="myModalLabel2">{{lang_Remove}}</h4>
				</div>
				<div class="modal-body">
					<div class="row">
						<div class="col-md-12 scrollingTable">
							<table id="removeRoleFromUserTable" class="table table-condensed table-hover stupidtable">
								<thead>
									<tr>
										<th data-sort="string">{{lang_Roles}}</th>
										<th data-sort="int" data-sort-default="desc">{{lang_Selected}}</th>
									</tr>
								</thead>

								<tbody>
								{{#roles}}
									<tr>
										<td>{{rolename}}</td>
										<td data-sort-value="0">
											<div class="checkbox">
												<input id="remove{{roleid}}" type="checkbox" name="roles[]" value='{{roleid}}'>
												<label for="remove{{roleid}}"></label>
											</div>
										</td>
									</tr>
								{{/roles}}
								</tbody>
							</table>
						</div>
					</div>
				</div>
				<div class="modal-footer">
					<button type="button" class="btn btn-default" data-dismiss="modal">{{lang_cancel}}</button>
					<button type="submit" name="action" value="removeRoleFromUser" class="btn btn-danger" onclick="clearAddRoleModal()"><span class="glyphicon glyphicon-trash"></span> {{lang_Remove}}</button>
				</div>
			</div>
		</div>
	</div>
</form>

<script>
	document.addEventListener("DOMContentLoaded", function() {
		// if checked,: mark green, else: unmark
		$('input:checkbox').change(function() {
			if ($(this).is(':checked')) {
				$(this).closest("td").data("sort-value", 1);
				$(this).closest("tr").css("background-color", "#f2ffe6");
			} else {
				$(this).closest("td").data("sort-value", 0);
				$(this).closest("tr").css("background-color", "");
			}

		});
	});


	// if remove-Role button is clicked, uncheck all checkboxes in add-role modal so they aren't submitted too
	function clearAddRoleModal () {
		$('#addRoleToUserModal')
			.find("input[type=checkbox]")
			.prop("checked", "")
			.end();
	}

	// if add-Role button is clicked, uncheck all checkboxes in remove-role modal so they aren't submitted too
	function clearRemoveRoleModal() {
		$('#removeRoleFromUserModal')
			.find("input[type=checkbox]")
			.prop("checked", "")
			.end();
	}
</script>