Files
AbizeitungVotingSystem/src/main/resources/templates/addingCandidates.html
Simon 1ee5174207 Made the transition of data between possibleCandidates and Candidates easier
CHANGED VotingController:
    - changed: candidateRepositorys get now only created if empty and 'candidatesAdded == true'

CHANGED PossibleCandidate:
    - added: new getter getCategoryID

CHANGED PossibleCandidateRepository
    - removed: unnecessary public declaration of methods

CHANGED TableAction:
    - changed: 'setupCandiates' adds the top 5 (votes) of every category in possibleCandidates (Manual preselection necessary)
    - added: helper method 'getLimit
    - removed: 'addCandidate' and 'addPossibleCandidate' due to no usage

CHANGED voting.css:
    - added: font-size to 'h1', 'h2.categoryHeader' and 'button' to enhance readability

CHANGED addingCandidates.html:
    - changed: language used in html tag from 'en' to 'de'

ADDED alreadysubmittedcandidates.html:
    - added: error page if voter already submitted possibleCandidates
2020-12-07 23:42:35 +01:00

55 lines
1.9 KiB
HTML

<!DOCTYPE html>
<html lang="de" xmlns:th="https://www.thymeleaf.org/">
<head>
<meta charset="UTF-8">
<title>Title</title>
<link th:href="@{/styles/addingCandidates.css}" rel="stylesheet" />
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
</head>
<body class="center-screen">
<script>
var q = 1,
qMax = 0;
$(function() {
qMax = $('#inputForm div.group').length;
$('#inputForm div.group').hide();
$('#inputForm div.group:nth-child(1)').show();
$('#btnNext').on('click', function(event) {
event.preventDefault();
handleClick();
});
});
function handleClick() {
if (q < qMax) {
$('#inputForm div.group:nth-child(' + q + ')').hide();
$('#inputForm div.group:nth-child(' + (q + 1) + ')').show();
if (q == (qMax - 1)) {
$('#btnNext').html('Submit Answers');
}
q++;
} else {
document.getElementById("inputForm").submit();
}
}
</script>
<div class="centered">
<h1>Schlage für jede Kategorie eine/n Kandiadt/en vor:</h1>
<form id="inputForm" action="#" th:action="@{/saveCandidates}" th:object="${form}" method="post">
<div id="candidateAdding">
<div class="group" th:each="category, itemStat : ${categories}">
<h2 class="categoryHeader" th:text="${category.name}"></h2>
<input th:field="*{possibleCandidates[__${itemStat.index}__].name}"/>
</div>
</div>
<button class="submitButton" id="btnNext" type="submit">Nächste Frage</button>
<input id="voterName" type="hidden" name="name" th:value="${name}" />
</form>
</div>
</body>
</html>