Beta-2.1 - The clearer, the faster #22

Merged
Djeex merged 27 commits from Beta-2.1 into main 2025-09-04 12:50:26 +02:00
24 changed files with 1334 additions and 671 deletions
Showing only changes of commit 24113a4aa8 - Show all commits

View File

@ -292,29 +292,9 @@ document.addEventListener("DOMContentLoaded", () => {
};
}
// --- Fetch theme list and populate select ---
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 ---
// --- Fetch theme list and populate select, then load config and update build status ---
let loadedConfig = {};
function loadConfigAndUpdateBuildStatus() {
fetch("/api/site-info")
.then(res => res.json())
.then(data => {
@ -362,9 +342,31 @@ document.addEventListener("DOMContentLoaded", () => {
if (resizeImagesCheckbox) {
resizeImagesCheckbox.checked = !!data.build?.resize_images;
}
// Initial status update
["info", "social", "menu", "footer", "legals", "build"].forEach(updateSectionStatus);
// Initial status update for all sections except build
["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 ---
if (addMenuBtn) {
@ -531,7 +533,7 @@ document.addEventListener("DOMContentLoaded", () => {
values.intellectual_property.every(ip => ip.paragraph)
);
case "build":
return values.theme;
return !!values.theme; // Only check theme is present
default:
return true;
}
@ -556,7 +558,7 @@ document.addEventListener("DOMContentLoaded", () => {
statusEl.style.display = "";
statusEl.style.fontStyle = "normal";
}
}
}
// --- Listen for changes in each section ---
[