<!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 sec:authorize="hasRole('admin')">
			<form th:action="@{/admin/document/update}" th:object="${bean}" method="post" enctype="multipart/form-data">
				<div class="tablebox">
					<div class="container">
						<input type="hidden" th:field="*{pk}" />
						<div class="row mb-2">
							<label for="inputName" class="col-sm-2 col-form-label">Name</label>
							<div class="col-sm-10">
								<span class="error" th:each="error : ${#fields.errors('name')}">[[${error}]]<br /></span> <input id="inputName" type="text" th:field="*{name}"
									th:class="${'form-control ' + (#fields.hasErrors('name') ? 'inputerror' : '')}">
							</div>
						</div>
						<div class="row mb-2">
							<label for="inputDoctype" class="col-sm-2 col-form-label">Dokumententyp</label>
							<div class="col-sm-10">
								<span class="error" th:each="error : ${#fields.errors('doctype')}">[[${error}]]<br /></span> <select id="inputDoctype" th:field="*{doctype}"
									th:class="${'form-select ' + (#fields.hasErrors('doctype') ? 'inputerror' : '')}">
									<option value="">--- bitte wählen ---</option>
									<option value="location">Wegbeschreibung</option>
									<option value="camp">Bestätigung</option>
									<option value="camppass">Freizeitpass</option>
								</select>
							</div>
						</div>
						<div class="row mb-2">
							<label for="inputRole" class="col-sm-2 col-form-label">Zielgruppe</label>
							<div class="col-sm-10">
								<span class="error" th:each="error : ${#fields.errors('roles')}">[[${error}]]<br /></span> <select id="inputRole" th:field="*{roles}"
									th:class="${'form-control ' + (#fields.hasErrors('roles') ? 'inputerror' : '')}" multiple>
									<option value="student">Teilnehmer</option>
									<option value="teacher">Mitarbeiter</option>
									<option value="director">Leiter</option>
									<option value="feeder">Küchenteam</option>
									<option value="observer">Mitarbeiterkind</option>
								</select>
							</div>
						</div>
						<div class="row mb-2">
							<label for="inputFile" class="col-sm-2 col-form-label">Dokument</label>
							<div class="col-sm-10">
								<span class="error" th:each="error : ${#fields.errors('uploadfile')}">[[${error}]]<br /></span>
								<input type="file" id="inputFile" th:field="*{uploadfile}" th:class="${'form-control ' + (#fields.hasErrors('uploadfile') ? 'inputerror' : '')}" />
							</div>
						</div>
						<div class="row mb-2">
							<label for="inputFiletype" class="col-sm-2 col-form-label">Dateityp</label>
							<div class="col-sm-10">
								<span class="error" th:each="error : ${#fields.errors('filetype')}">[[${error}]]<br /></span> <select id="inputFiletype" th:field="*{filetype}"
									th:class="${'form-select ' + (#fields.hasErrors('filetype') ? 'inputerror' : '')}">
									<option value="">--- bitte wählen ---</option>
									<option value="pdf">PDF</option>
									<option value="png">PNG</option>
									<option value="jpg">JPG</option>
								</select>
							</div>
						</div>
						<div class="row mb-2">
							<div class="col-sm-2"></div>
							<div class="col-sm-10">
								<input type="submit" class="btn btn-success" value="Ok" />
								<a th:href="@{/admin/document}" class="btn btn-outline-secondary">Abbrechen</a>
								<div class="dropdown" style="display: inline">
									<button class="btn btn-outline-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/document/delete/{id}(id=${bean.pk})}">Dokument endgültig löschen</a>
									</ul>
								</div>
							</div>
						</div>
					</div>
				</div>
			</form>
		</div>
	</th:block>
</body>
</html>