Block voting when finalized; disable sliders client-side

This commit is contained in:
2026-02-04 23:17:47 +01:00
parent 56ca3b1f68
commit 4edbfb16ee
2 changed files with 5 additions and 1 deletions

View File

@@ -32,6 +32,8 @@ public static class VoteEndpoints
var player = await EndpointHelpers.GetAuthenticatedPlayer(ctx, db);
if (player is null) return Results.Unauthorized();
if (player.VotesFinal)
return Results.BadRequest(new { error = "Votes are finalized. Unfinalize before changing scores." });
var phase = await EndpointHelpers.GetPhase(db, player.Id);
if (phase != Phase.Vote)
return EndpointHelpers.PhaseMismatch(Phase.Vote, phase);

View File

@@ -152,7 +152,7 @@ export function renderVotes() {
footer.innerHTML = `
<div class="warning-text ${hasVote ? "hidden" : ""}" id="warn-${s.id}">${t("vote.missingWarn")}</div>
<div class="vote-row">
<input class="full-slider" type="range" min="0" max="10" value="${current}" data-id="${s.id}">
<input class="full-slider" type="range" min="0" max="10" value="${current}" data-id="${s.id}" ${state.votesFinal ? "disabled" : ""}>
<span class="score" id="score-${s.id}">${displayScore}</span>
<span class="score-emoji" id="emoji-${s.id}">${displayEmoji}</span>
</div>`;
@@ -161,6 +161,7 @@ export function renderVotes() {
});
list.querySelectorAll("input[type=range]").forEach((input) => {
input.addEventListener("input", (e) => {
if (state.votesFinal) return;
const val = Number(e.target.value);
$("score-" + e.target.dataset.id).textContent = val;
const emojiEl = $("emoji-" + e.target.dataset.id);
@@ -169,6 +170,7 @@ export function renderVotes() {
if (warn) warn.classList.add("hidden");
});
input.addEventListener("change", async (e) => {
if (state.votesFinal) return;
const suggestionId = Number(e.target.dataset.id);
const score = Number(e.target.value);
try {