From 2814548ea246bbb7fe66dfcbdb1e28eb0f71b817 Mon Sep 17 00:00:00 2001 From: Frank Tovar Date: Fri, 6 Feb 2026 23:09:58 +0100 Subject: [PATCH] Fix relock popup visibility and buttons --- wwwroot/app.js | 7 +++++++ wwwroot/js/ui.js | 17 ++++++++++------- 2 files changed, 17 insertions(+), 7 deletions(-) diff --git a/wwwroot/app.js b/wwwroot/app.js index 8ff3ab5..c442fad 100644 --- a/wwwroot/app.js +++ b/wwwroot/app.js @@ -18,6 +18,7 @@ import { openNewSuggestionModal, updatePhaseNav, openConfirmModal, + openResultsRelockModal, } from "./js/ui.js"; import { loadState, @@ -180,9 +181,15 @@ function setupHandlers() { const desired = !!e.target.checked; try { const resp = await adminApi.setResultsOpen(desired); + const wasResultsOpen = state.resultsOpen; + const wasPhase = state.phase; state.resultsOpen = resp.resultsOpen; + if (wasResultsOpen && !resp.resultsOpen && wasPhase === "Results") { + openResultsRelockModal(); + } renderPhasePill(); toast(t("admin.resultsUpdated")); + await refreshPhaseData(); } catch (err) { e.target.checked = !desired; toast(err.message, true); diff --git a/wwwroot/js/ui.js b/wwwroot/js/ui.js index c4bc231..3cbab11 100644 --- a/wwwroot/js/ui.js +++ b/wwwroot/js/ui.js @@ -729,7 +729,7 @@ export function openResultsRelockModal() { title: t("results.relockedTitle"), body: t("results.relockedBody"), confirmLabel: t("results.relockedConfirm"), - cancelLabel: t("modal.close"), + cancelLabel: null, onConfirm: (close) => close(), }); } @@ -752,11 +752,15 @@ export function openConfirmModal({ title, body, confirmLabel, cancelLabel = t("m actions.className = "stack horizontal"; const confirmBtn = document.createElement("button"); confirmBtn.textContent = confirmLabel ?? t("modal.confirm"); - const cancelBtn = document.createElement("button"); - cancelBtn.className = "ghost"; - cancelBtn.type = "button"; - cancelBtn.textContent = cancelLabel; - actions.append(confirmBtn, cancelBtn); + actions.append(confirmBtn); + if (cancelLabel !== null && cancelLabel !== undefined) { + const cancelBtn = document.createElement("button"); + cancelBtn.className = "ghost"; + cancelBtn.type = "button"; + cancelBtn.textContent = cancelLabel; + actions.append(cancelBtn); + cancelBtn.addEventListener("click", close); + } panel.querySelector(".edit-body")?.appendChild(actions); const close = () => overlay.remove(); @@ -767,7 +771,6 @@ export function openConfirmModal({ title, body, confirmLabel, cancelLabel = t("m ) close(); }); - cancelBtn.addEventListener("click", close); confirmBtn.addEventListener("click", async () => { try { await onConfirm?.(close);