Add votes-final flag, warn on missing votes, and sync phases with results toggle

This commit is contained in:
2026-02-04 22:54:36 +01:00
parent 91692856f9
commit 13c8bb6194
13 changed files with 318 additions and 6 deletions

View File

@@ -44,6 +44,7 @@ export const api = {
myVotes: () => request("/api/votes/mine"),
vote: (suggestionId, score) => request("/api/votes", { method: "POST", body: { suggestionId, score } }),
finalizeVotes: (final) => request("/api/votes/finalize", { method: "POST", body: { final } }),
results: () => request("/api/results"),
nextPhase: () => request("/api/me/phase/next", { method: "POST" }),

View File

@@ -76,6 +76,8 @@ const translations = {
"card.openScreenshot": "Open screenshot",
"vote.saved": "Saved vote",
"vote.missing": "Missing",
"vote.missingWarn": "You havent voted yet. Slide to set a score.",
"results.rank": "Rank",
"results.game": "Game",
@@ -193,6 +195,8 @@ const translations = {
"card.openScreenshot": "Screenshot öffnen",
"vote.saved": "Stimme gespeichert",
"vote.missing": "Fehlt",
"vote.missingWarn": "Du hast hier noch nicht abgestimmt. Schiebe den Regler.",
"results.rank": "Rang",
"results.game": "Spiel",

View File

@@ -145,11 +145,12 @@ export function renderVotes() {
});
const hasVote = Object.prototype.hasOwnProperty.call(votesMap, s.id);
const current = hasVote ? votesMap[s.id] : 5; // start neutral when no prior vote
const displayScore = hasVote ? current : "—";
const displayEmoji = hasVote ? scoreToEmoji(current) : neutralEmoji();
const displayScore = hasVote ? current : t("vote.missing");
const displayEmoji = hasVote ? scoreToEmoji(current) : "⚠️";
const footer = document.createElement("div");
footer.className = "vote-controls";
footer.innerHTML = `
<div class="warning-text ${hasVote ? "hidden" : ""}" id="warn-${s.id}">${t("vote.missingWarn")}</div>
<input class="full-slider" type="range" min="0" max="10" value="${current}" data-id="${s.id}">
<span class="score" id="score-${s.id}">${displayScore}</span>
<span class="score-emoji" id="emoji-${s.id}">${displayEmoji}</span>`;
@@ -162,6 +163,8 @@ export function renderVotes() {
$("score-" + e.target.dataset.id).textContent = val;
const emojiEl = $("emoji-" + e.target.dataset.id);
if (emojiEl) emojiEl.textContent = scoreToEmoji(val);
const warn = $("warn-" + e.target.dataset.id);
if (warn) warn.classList.add("hidden");
});
input.addEventListener("change", async (e) => {
const suggestionId = Number(e.target.dataset.id);
@@ -627,7 +630,7 @@ export function neutralEmoji() {
}
function formatVotes(votes) {
if (!Array.isArray(votes) || votes.length === 0) return "";
if (!Array.isArray(votes) || votes.length === 0) return "⚠️";
const sorted = [...votes].sort((a, b) => a - b);
return sorted.map((v) => scoreToEmoji(v)).join("");
}