Make vote missing badge update immediately

This commit is contained in:
2026-02-05 11:30:23 +01:00
parent 4a0a1c28e6
commit a5c39d1263
2 changed files with 20 additions and 1 deletions

View File

@@ -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"];