diff --git a/wwwroot/js/data.js b/wwwroot/js/data.js index c80b1a7..4cfd9cc 100644 --- a/wwwroot/js/data.js +++ b/wwwroot/js/data.js @@ -1,5 +1,5 @@ import { api, adminApi } from "./api.js"; -import { handleAuthError, renderAllSuggestions, renderCounts, renderMySuggestions, renderPhasePill, renderPhaseTitles, renderResults, renderVotes, renderWelcome, setAuthUI, syncVoteScores } from "./ui.js"; +import { handleAuthError, renderAllSuggestions, renderCounts, renderMySuggestions, renderPhasePill, renderPhaseTitles, renderResults, renderVotes, renderWelcome, setAuthUI, syncVoteScores, updatePhaseNav } from "./ui.js"; import { state, clearUserState } from "./state.js"; export async function loadState() { @@ -51,6 +51,7 @@ export async function loadVoteData() { } else { syncVoteScores(); } + updatePhaseNav(); } export async function loadResults() { diff --git a/wwwroot/js/ui.js b/wwwroot/js/ui.js index cb28ec6..02967c9 100644 --- a/wwwroot/js/ui.js +++ b/wwwroot/js/ui.js @@ -164,6 +164,7 @@ export function renderVotes() { list.appendChild(li); }); updatePhaseNav(); + updateMissingBadgeFromDom(); list.querySelectorAll("input[type=range]").forEach((input) => { input.addEventListener("input", (e) => { if (state.votesFinal) return; @@ -174,6 +175,7 @@ export function renderVotes() { const warn = $("warn-" + e.target.dataset.id); if (warn) warn.classList.add("hidden"); syncLinkedSliders(e.target, val); + updateMissingBadgeFromDom(); }); input.addEventListener("change", async (e) => { if (state.votesFinal) return; @@ -675,6 +677,21 @@ function missingVotesCount() { return missing < 0 ? 0 : missing; } +function updateMissingBadgeFromDom() { + const badge = $("vote-missing"); + if (!badge) return; + if (state.votesFinal || state.phase !== "Vote") { + badge.classList.add("hidden"); + return; + } + const sliders = document.querySelectorAll("#vote-list input[type=range]"); + const missing = Array.from(sliders).some((slider) => { + const scoreLabel = $("score-" + slider.dataset.id); + return !scoreLabel || scoreLabel.textContent === "—"; + }); + badge.classList.toggle("hidden", !missing); +} + function renderAdminVoteStatus() { if (!state.me?.isAdmin) return; const list = $("admin-voter-list"); @@ -956,6 +973,7 @@ export function updatePhaseNav() { renderAdminVoteStatus(); renderAdminLinker(); + updateMissingBadgeFromDom(); // Toggle admin-only back buttons const backButtons = ["nav-vote-prev"];