Add confirmation for missing vote finalize
This commit is contained in:
@@ -367,14 +367,38 @@ function bindNavButtons() {
|
|||||||
|
|
||||||
const finalizeBtn = $("finalize-votes");
|
const finalizeBtn = $("finalize-votes");
|
||||||
if (finalizeBtn) {
|
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 () => {
|
finalizeBtn.addEventListener("click", async () => {
|
||||||
try {
|
try {
|
||||||
const desired = !state.votesFinal;
|
const desired = !state.votesFinal;
|
||||||
await api.finalizeVotes(desired);
|
if (desired) {
|
||||||
state.votesFinal = desired;
|
const missing = missingVotes();
|
||||||
renderPhasePill();
|
if (missing.length > 0) {
|
||||||
renderVotes();
|
openConfirmModal({
|
||||||
toast(desired ? t("vote.finalize") : t("vote.unfinalize"));
|
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) {
|
} catch (err) {
|
||||||
toast(err.message, true);
|
toast(err.message, true);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -88,6 +88,9 @@ const translations = {
|
|||||||
"vote.unfinalize": "Edit votes",
|
"vote.unfinalize": "Edit votes",
|
||||||
"vote.finalHint": "Finalize when you’re done. You can unfinalize to change scores.",
|
"vote.finalHint": "Finalize when you’re done. You can unfinalize to change scores.",
|
||||||
"vote.waitAdmin": "Waiting for admin to unlock results.",
|
"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.rank": "Rank",
|
||||||
"results.game": "Game",
|
"results.game": "Game",
|
||||||
@@ -250,6 +253,9 @@ const translations = {
|
|||||||
"vote.unfinalize": "Abstimmung bearbeiten",
|
"vote.unfinalize": "Abstimmung bearbeiten",
|
||||||
"vote.finalHint": "Schließe ab, wenn du fertig bist. Zum Ändern wieder öffnen.",
|
"vote.finalHint": "Schließe ab, wenn du fertig bist. Zum Ändern wieder öffnen.",
|
||||||
"vote.waitAdmin": "Warten, bis der Admin die Ergebnisse freigibt.",
|
"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.rank": "Rang",
|
||||||
"results.game": "Spiel",
|
"results.game": "Spiel",
|
||||||
|
|||||||
Reference in New Issue
Block a user