summaryrefslogtreecommitdiffstats
path: root/modules-available/permissionmanager/templates/rolestable.html
blob: 99401624f0360e855b46fb967eaf15ba20cab83f (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
<form method="post" action="?do=permissionmanager">
	<input type="hidden" name="token" value="{{token}}">

	<div class="row">
		<div class="col-md-4">
			<button class="btn btn-success" type="button" onclick="openRoleEditor()"><span class="glyphicon glyphicon-plus"></span> {{lang_newRole}}</button>
		</div>
		<div class="col-md-4">
			<input type="text" class="form-control" id="roleNameSearchField" onkeyup="searchFieldFunction()" placeholder="{{lang_searchPlaceholder}}">
		</div>
	</div>

	<div class="row">
		<div class="col-md-12">
			<table id="rolesTable" class="table table-condensed table-hover stupidtable">
				<thead>
					<tr>
						<th data-sort="string">{{lang_Roles}}</th>
						<th class="text-center">{{lang_Edit}}</th>
						<th class="text-center">{{lang_Delete}}</th>
					</tr>
				</thead>

				<tbody>
				{{#roles}}
					<tr class="rolesRow">
						<td class="rolesData">{{rolename}}</td>
						<td class="text-center">
							<a class="btn btn-xs btn-info" href="?do=permissionmanager&show=roleEditor&roleid={{roleid}}"><span class="glyphicon glyphicon-edit"></span></a>
						</td>
						<td class="text-center">
							<a class="btn btn-xs btn-danger" href="#deleteModal" data-toggle="modal" data-target="#deleteModal" onclick="deleteRole('{{roleid}}')"><span class="glyphicon glyphicon-trash"></span></a>
						</td>
					</tr>
				{{/roles}}
				</tbody>
			</table>
		</div>
	</div>


	<!-- Modals -->
	<div class ="modal fade" id="deleteModal" 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_Delete}}</h4>
				</div>
				<div class="modal-body">
					{{lang_deleteCheck}}
				</div>
				<div class="modal-footer">
					<input type="hidden" id="deleteId" name="deleteId" value=""/>
					<button type="button" class="btn btn-default" data-dismiss="modal">{{lang_cancel}}</button>
					<button type="submit" name="action" value="deleteRole" class="btn btn-danger"><span class="glyphicon glyphicon-trash"></span> {{lang_Delete}}</button>
				</div>
			</div>
		</div>
	</div>

</form>

<script>
	function openRoleEditor() {
		window.location.href = "?do=permissionmanager&show=roleEditor"
	}

	function deleteRole($roleid) {
		$(".modal-footer #deleteId").val($roleid);
	}

	function searchFieldFunction() {
		// Declare variables
		var input, filter, table, trs, a, i;
		input = document.getElementById('roleNameSearchField');
		filter = input.value.toUpperCase();
		table = document.getElementById("rolesTable");
		trs = table.getElementsByClassName('rolesRow');

		// Loop through all list items, and hide those who don't match the search query
		for (i = 0; i < trs.length; i++) {
			a = trs[i].getElementsByClassName("rolesData")[0];
			if (a.innerHTML.toUpperCase().indexOf(filter) > -1) {
				trs[i].style.display = "";
			} else {
				trs[i].style.display = "none";
			}
		}
	}
</script>