Fixed build section status

This commit is contained in:
Djeex
2025-09-03 10:43:54 +02:00
parent be8ce4f62c
commit 24113a4aa8

View File

@ -292,29 +292,9 @@ document.addEventListener("DOMContentLoaded", () => {
}; };
} }
// --- Fetch theme list and populate select --- // --- Fetch theme list and populate select, then load config and update build status ---
if (themeSelect) {
fetch("/api/themes")
.then(res => res.json())
.then(themes => {
themeSelect.innerHTML = "";
themes.forEach(theme => {
const option = document.createElement("option");
option.value = theme;
option.textContent = theme;
themeSelect.appendChild(option);
});
// Set selected value after loading config
fetch("/api/site-info")
.then(res => res.json())
.then(data => {
themeSelect.value = data.build?.theme || "";
});
});
}
// --- Load config from server and populate forms ---
let loadedConfig = {}; let loadedConfig = {};
function loadConfigAndUpdateBuildStatus() {
fetch("/api/site-info") fetch("/api/site-info")
.then(res => res.json()) .then(res => res.json())
.then(data => { .then(data => {
@ -362,9 +342,31 @@ document.addEventListener("DOMContentLoaded", () => {
if (resizeImagesCheckbox) { if (resizeImagesCheckbox) {
resizeImagesCheckbox.checked = !!data.build?.resize_images; resizeImagesCheckbox.checked = !!data.build?.resize_images;
} }
// Initial status update // Initial status update for all sections except build
["info", "social", "menu", "footer", "legals", "build"].forEach(updateSectionStatus); ["info", "social", "menu", "footer", "legals"].forEach(updateSectionStatus);
// For build, update status after theme select is set
updateSectionStatus("build");
}); });
}
if (themeSelect) {
fetch("/api/themes")
.then(res => res.json())
.then(themes => {
themeSelect.innerHTML = "";
themes.forEach(theme => {
const option = document.createElement("option");
option.value = theme;
option.textContent = theme;
themeSelect.appendChild(option);
});
// Now load config and update build status after theme select is ready
loadConfigAndUpdateBuildStatus();
});
} else {
// If no theme select, just load config
loadConfigAndUpdateBuildStatus();
}
// --- Add menu item --- // --- Add menu item ---
if (addMenuBtn) { if (addMenuBtn) {
@ -531,7 +533,7 @@ document.addEventListener("DOMContentLoaded", () => {
values.intellectual_property.every(ip => ip.paragraph) values.intellectual_property.every(ip => ip.paragraph)
); );
case "build": case "build":
return values.theme; return !!values.theme; // Only check theme is present
default: default:
return true; return true;
} }
@ -556,7 +558,7 @@ document.addEventListener("DOMContentLoaded", () => {
statusEl.style.display = ""; statusEl.style.display = "";
statusEl.style.fontStyle = "normal"; statusEl.style.fontStyle = "normal";
} }
} }
// --- Listen for changes in each section --- // --- Listen for changes in each section ---
[ [