Add confirmation for missing vote finalize

This commit is contained in:
2026-02-06 22:26:23 +01:00
parent 7ae51e1939
commit 4889274e8e
2 changed files with 35 additions and 5 deletions

View File

@@ -367,14 +367,38 @@ function bindNavButtons() {
const finalizeBtn = $("finalize-votes");
if (finalizeBtn) {
const finalizeVotes = async (desired) => {
await api.finalizeVotes(desired);
state.votesFinal = desired;
renderPhasePill();
renderVotes();
toast(desired ? t("vote.finalize") : t("vote.unfinalize"));
};
const missingVotes = () => {
const votedIds = new Set((state.myVotes ?? []).map((v) => v.suggestionId));
return (state.allSuggestions ?? []).filter((s) => !votedIds.has(s.id));
};
finalizeBtn.addEventListener("click", async () => {
try {
const desired = !state.votesFinal;
await api.finalizeVotes(desired);
state.votesFinal = desired;
renderPhasePill();
renderVotes();
toast(desired ? t("vote.finalize") : t("vote.unfinalize"));
if (desired) {
const missing = missingVotes();
if (missing.length > 0) {
openConfirmModal({
title: t("vote.finalizeMissingTitle"),
body: t("vote.finalizeMissingBody", { count: missing.length }),
confirmLabel: t("vote.finalizeMissingConfirm"),
onConfirm: async (close) => {
await finalizeVotes(desired);
close();
},
});
return;
}
}
await finalizeVotes(desired);
} catch (err) {
toast(err.message, true);
}

View File

@@ -88,6 +88,9 @@ const translations = {
"vote.unfinalize": "Edit votes",
"vote.finalHint": "Finalize when youre done. You can unfinalize to change scores.",
"vote.waitAdmin": "Waiting for admin to unlock results.",
"vote.finalizeMissingTitle": "Finalize with missing votes?",
"vote.finalizeMissingBody": "You still have {count} game(s) without a score. Finalizing will mark you as done while those stay unrated.",
"vote.finalizeMissingConfirm": "Finalize anyway",
"results.rank": "Rank",
"results.game": "Game",
@@ -250,6 +253,9 @@ const translations = {
"vote.unfinalize": "Abstimmung bearbeiten",
"vote.finalHint": "Schließe ab, wenn du fertig bist. Zum Ändern wieder öffnen.",
"vote.waitAdmin": "Warten, bis der Admin die Ergebnisse freigibt.",
"vote.finalizeMissingTitle": "Mit fehlenden Stimmen abschließen?",
"vote.finalizeMissingBody": "Für {count} Spiel(e) fehlt noch eine Wertung. Beim Abschließen gilt deine Abstimmung als fertig, obwohl diese Spiele unbewertet bleiben.",
"vote.finalizeMissingConfirm": "Trotzdem abschließen",
"results.rank": "Rang",
"results.game": "Spiel",