Make vote missing badge update immediately
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
import { api, adminApi } from "./api.js";
|
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";
|
import { state, clearUserState } from "./state.js";
|
||||||
|
|
||||||
export async function loadState() {
|
export async function loadState() {
|
||||||
@@ -51,6 +51,7 @@ export async function loadVoteData() {
|
|||||||
} else {
|
} else {
|
||||||
syncVoteScores();
|
syncVoteScores();
|
||||||
}
|
}
|
||||||
|
updatePhaseNav();
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function loadResults() {
|
export async function loadResults() {
|
||||||
|
|||||||
@@ -164,6 +164,7 @@ export function renderVotes() {
|
|||||||
list.appendChild(li);
|
list.appendChild(li);
|
||||||
});
|
});
|
||||||
updatePhaseNav();
|
updatePhaseNav();
|
||||||
|
updateMissingBadgeFromDom();
|
||||||
list.querySelectorAll("input[type=range]").forEach((input) => {
|
list.querySelectorAll("input[type=range]").forEach((input) => {
|
||||||
input.addEventListener("input", (e) => {
|
input.addEventListener("input", (e) => {
|
||||||
if (state.votesFinal) return;
|
if (state.votesFinal) return;
|
||||||
@@ -174,6 +175,7 @@ export function renderVotes() {
|
|||||||
const warn = $("warn-" + e.target.dataset.id);
|
const warn = $("warn-" + e.target.dataset.id);
|
||||||
if (warn) warn.classList.add("hidden");
|
if (warn) warn.classList.add("hidden");
|
||||||
syncLinkedSliders(e.target, val);
|
syncLinkedSliders(e.target, val);
|
||||||
|
updateMissingBadgeFromDom();
|
||||||
});
|
});
|
||||||
input.addEventListener("change", async (e) => {
|
input.addEventListener("change", async (e) => {
|
||||||
if (state.votesFinal) return;
|
if (state.votesFinal) return;
|
||||||
@@ -675,6 +677,21 @@ function missingVotesCount() {
|
|||||||
return missing < 0 ? 0 : missing;
|
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() {
|
function renderAdminVoteStatus() {
|
||||||
if (!state.me?.isAdmin) return;
|
if (!state.me?.isAdmin) return;
|
||||||
const list = $("admin-voter-list");
|
const list = $("admin-voter-list");
|
||||||
@@ -956,6 +973,7 @@ export function updatePhaseNav() {
|
|||||||
|
|
||||||
renderAdminVoteStatus();
|
renderAdminVoteStatus();
|
||||||
renderAdminLinker();
|
renderAdminLinker();
|
||||||
|
updateMissingBadgeFromDom();
|
||||||
|
|
||||||
// Toggle admin-only back buttons
|
// Toggle admin-only back buttons
|
||||||
const backButtons = ["nav-vote-prev"];
|
const backButtons = ["nav-vote-prev"];
|
||||||
|
|||||||
Reference in New Issue
Block a user