Fix relock popup visibility and buttons
This commit is contained in:
@@ -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);
|
||||
|
||||
@@ -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");
|
||||
actions.append(confirmBtn);
|
||||
if (cancelLabel !== null && cancelLabel !== undefined) {
|
||||
const cancelBtn = document.createElement("button");
|
||||
cancelBtn.className = "ghost";
|
||||
cancelBtn.type = "button";
|
||||
cancelBtn.textContent = cancelLabel;
|
||||
actions.append(confirmBtn, cancelBtn);
|
||||
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);
|
||||
|
||||
Reference in New Issue
Block a user