Add widget settings save button
This commit is contained in:
+11
-7
@@ -168,7 +168,7 @@ $("#onlineToggle").addEventListener("change", async () => {
|
||||
|
||||
$("#settingsForm").addEventListener("submit", async (event) => {
|
||||
event.preventDefault();
|
||||
const submitButton = event.currentTarget.querySelector("button[type='submit']");
|
||||
const submitButtons = [...event.currentTarget.querySelectorAll("button[type='submit']")];
|
||||
setSettingsSaveStatus("saving", "Ukládám...");
|
||||
const form = new FormData(event.currentTarget);
|
||||
const settings = structuredClone(state.site.settings);
|
||||
@@ -215,7 +215,9 @@ $("#settingsForm").addEventListener("submit", async (event) => {
|
||||
settings.notifications.badgeOnAdminReply = form.get("messageBadge") === "on";
|
||||
settings.notifications.labelOnAdminReply = form.get("messageLabel") === "on";
|
||||
settings.notifications.wiggleOnAdminReply = form.get("messageWiggle") === "on";
|
||||
submitButton.disabled = true;
|
||||
submitButtons.forEach((button) => {
|
||||
button.disabled = true;
|
||||
});
|
||||
try {
|
||||
setSettingsSaveStatus("translating", "Překládám...");
|
||||
const data = await saveSite({ settings, isOnline: state.site.isOnline });
|
||||
@@ -232,7 +234,9 @@ $("#settingsForm").addEventListener("submit", async (event) => {
|
||||
} catch (error) {
|
||||
setSettingsSaveStatus("error", "Akce se nepodařila.");
|
||||
} finally {
|
||||
submitButton.disabled = false;
|
||||
submitButtons.forEach((button) => {
|
||||
button.disabled = false;
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
@@ -1615,10 +1619,10 @@ async function saveSite(patch) {
|
||||
}
|
||||
|
||||
function setSettingsSaveStatus(type, text) {
|
||||
const status = $("#settingsSaveStatus");
|
||||
if (!status) return;
|
||||
status.className = `settings-save-status ${type || ""}`.trim();
|
||||
status.textContent = text || "";
|
||||
for (const status of document.querySelectorAll("[data-settings-save-status]")) {
|
||||
status.className = `settings-save-status ${type || ""}`.trim();
|
||||
status.textContent = text || "";
|
||||
}
|
||||
}
|
||||
|
||||
function notify() {
|
||||
|
||||
Reference in New Issue
Block a user