Add votes-final flag, warn on missing votes, and sync phases with results toggle
This commit is contained in:
@@ -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" }),
|
||||
|
||||
@@ -76,6 +76,8 @@ const translations = {
|
||||
"card.openScreenshot": "Open screenshot",
|
||||
|
||||
"vote.saved": "Saved vote",
|
||||
"vote.missing": "Missing",
|
||||
"vote.missingWarn": "You haven’t 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",
|
||||
|
||||
@@ -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("");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user