Add joker support during voting
This commit is contained in:
@@ -565,11 +565,16 @@ export function openNewSuggestionModal() {
|
||||
submitLabel: t("form.submit"),
|
||||
initial: {},
|
||||
onSubmit: async (data, close, submitBtn) => {
|
||||
const wasVotePhase = state.phase === "Vote";
|
||||
await api.createSuggestion(data);
|
||||
toast(t("toast.suggestionAdded"));
|
||||
if (submitBtn) triggerCelebration(submitBtn);
|
||||
close();
|
||||
await window.loadSuggestData();
|
||||
if (wasVotePhase) {
|
||||
await window.refreshPhaseData();
|
||||
} else {
|
||||
await window.loadSuggestData();
|
||||
}
|
||||
},
|
||||
});
|
||||
}
|
||||
@@ -712,13 +717,16 @@ function renderAdminVoteStatus() {
|
||||
if (!state.me?.isAdmin) return;
|
||||
const list = $("admin-voter-list");
|
||||
const status = $("admin-ready-status");
|
||||
const jokerWrap = $("admin-joker");
|
||||
const jokerSelect = $("joker-player");
|
||||
if (!state.adminVoteStatus || !list || !status) return;
|
||||
|
||||
list.innerHTML = "";
|
||||
state.adminVoteStatus.voters.forEach((v) => {
|
||||
const li = document.createElement("li");
|
||||
const name = v.name?.length > 24 ? `${v.name.slice(0, 21)}…` : v.name;
|
||||
li.textContent = `${name} — ${v.finalized ? "✅" : "⏳"}`;
|
||||
const jokerMark = v.hasJoker ? " 🎟" : "";
|
||||
li.textContent = `${name}${jokerMark} — ${v.finalized ? "✅" : "⏳"}`;
|
||||
li.title = v.name;
|
||||
list.appendChild(li);
|
||||
});
|
||||
@@ -732,6 +740,29 @@ function renderAdminVoteStatus() {
|
||||
? t("admin.readyForResults")
|
||||
: t("admin.waitingForPlayers", { names: waitingDisplay.join(", ") });
|
||||
status.className = ready ? "badge" : "badge warning";
|
||||
|
||||
if (jokerWrap) jokerWrap.classList.toggle("hidden", state.phase !== "Vote");
|
||||
if (jokerSelect && state.phase === "Vote") {
|
||||
const previous = jokerSelect.value;
|
||||
jokerSelect.innerHTML = "";
|
||||
const placeholder = document.createElement("option");
|
||||
placeholder.value = "";
|
||||
placeholder.disabled = true;
|
||||
placeholder.selected = true;
|
||||
placeholder.textContent = t("admin.jokerPlaceholder");
|
||||
jokerSelect.appendChild(placeholder);
|
||||
|
||||
state.adminVoteStatus.voters.forEach((v) => {
|
||||
const opt = document.createElement("option");
|
||||
opt.value = v.playerId;
|
||||
opt.textContent = v.hasJoker ? `${v.name} — 🎟` : v.name;
|
||||
jokerSelect.appendChild(opt);
|
||||
});
|
||||
|
||||
if (previous && Array.from(jokerSelect.options).some((o) => o.value === previous)) {
|
||||
jokerSelect.value = previous;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function renderAdminLinker() {
|
||||
@@ -961,6 +992,12 @@ export function updatePhaseNav() {
|
||||
|
||||
showNav("nav-suggest", phase === "Suggest");
|
||||
showNav("nav-vote", phase === "Vote");
|
||||
const jokerBtn = $("open-joker-modal");
|
||||
if (jokerBtn) {
|
||||
const showJoker = phase === "Vote" && state.hasJoker;
|
||||
jokerBtn.classList.toggle("hidden", !showJoker);
|
||||
jokerBtn.disabled = !showJoker;
|
||||
}
|
||||
|
||||
const finalizeBtn = $("finalize-votes");
|
||||
if (finalizeBtn) {
|
||||
|
||||
Reference in New Issue
Block a user