<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org" layout:decorate="~{template}" xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout" xmlns:sec="http://www.thymeleaf.org/extras/spring-security">
<head>
<title>Camp Organizer Privileges</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
</head>
<body>
	<th:block layout:fragment="content">
		<div sec:authorize="hasRole('admin')">
			<div class="tablebox">
				<div class="btn-group" role="group">
					<a th:class="${e == selected ? 'btn btn-primary' : 'btn btn-outline-secondary'}" th:each="e : ${list}" th:href="@{/admin/privileges/rolebased/{r}(r=${e})}"> <span th:text="${e}"></span>
					</a>
				</div>
				<div class="card" th:if="${selected}">
					<div class="card-header">
						<h1 th:text="${selected}"></h1>
					</div>
					<div class="card-body">
						<table id="table" class="table table-striped">
							<thead>
								<tr>
									<th>Name</th>
									<th>Freizeit</th>
								</tr>
							</thead>
							<tbody>
								<tr th:each="m : ${container.map}">
									<td th:text="${m.key}"></td>
									<td>
										<div class="btn-toolbar" role="toolbar">
											<div class="btn-group beforetext" role="group" th:each="v : ${m.value}" th:if="${m.value}">
												<div class="dropdown">
													<button class="btn btn-danger dropdown-toggle" type="button" data-bs-toggle="dropdown" aria-expanded="false">
														<i class="fas fa-trash-alt"></i>
													</button>
													<ul class="dropdown-menu">
														<li><a class="dropdown-item" th:href="@{/admin/privileges/delete/{id}/{d}(id=${v.key}, d=${pagedest})}">endgültig löschen</a></li>
													</ul>
												</div>
												<button type="button" class="btn btn-outline-secondary" th:text="${v.value}" disabled></button>
											</div>
										</div>
									</td>
								</tr>
							</tbody>
							<tfoot>
								<tr>
									<td colspan="2" style="text-align: center"><a th:href="@{/admin/privileges/add/{d}?module={m}(d=${pagedest},m=${module})}" class="btn btn-outline-primary">neue Berechtigung vergeben</a></td>
								</tr>
							</tfoot>
						</table>
						<script>
							$(document).ready(function() {
								$("#table").DataTable({
									language : locale_de
								});
							});
						</script>
					</div>
				</div>
			</div>
		</div>
	</th:block>
</body>
</html>