<!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">
<body>
	<th:block layout:fragment="content">
		<div class="tablebox" sec:authorize="hasRole('admin')">
			<table id="docs" class="table table-striped" style="width: 100% !important">
				<thead>
					<tr>
						<td>Name</td>
						<td>Dokumententyp</td>
						<td>Zielgruppe</td>
						<th>Inhalt</th>
					</tr>
				</thead>
				<tbody>
					<tr th:each="d : ${documents}">
						<td><a th:href="@{/admin/document/edit/{id}(id=${d.pk})}"><i class="fas fa-pen beforetext"></i><span th:text="${d.name}"></span></a></td>
						<td><span th:if="${d.doctype.literal == 'location'}">Wegbeschreibung</span> <span th:if="${d.doctype.literal == 'camp'}">Bestätigung</span><span
							th:if="${d.doctype.literal == 'camppass'}">Freizeitpass</span></td>
						<td><th:block th:each="r : ${d.roles}">
								<span th:if="${r.literal == 'student'}" class="roleflag">Teilnehmer</span>
								<span th:if="${r.literal == 'teacher'}" class="roleflag">Mitarbeiter</span>
								<span th:if="${r.literal == 'director'}" class="roleflag">Leiter</span>
								<span th:if="${r.literal == 'feeder'}" class="roleflag">Küche</span>
								<span th:if="${r.literal == 'observer'}" class="roleflag">Mitarbeiterkind</span>
							</th:block></td>
						<td><a th:href="@{/document/{id}(id=${d.pk})}"><i class="fas fa-download beforetext"></i><span th:text="${d.filetype.literal}" th:if="${d.filetype}"></span>&nbsp;anzeigen</a></td>
					</tr>
				</tbody>
				<tfoot>
					<tr>
						<td colspan="4" style="text-align: center"><a th:href="@{/admin/document/add}" class="btn btn-outline-primary">neues Dokument anlegen</a></td>
					</tr>
				</tfoot>
			</table>
			<script>
				$(document).ready(function() {
					$("#docs").DataTable({
						language : locale_de
					});
				});
			</script>
		</div>
	</th:block>
</body>
</html>