From 7fb117a95e326783d550eddf70d2ea597cb7b389 Mon Sep 17 00:00:00 2001 From: Yaro Kasear Date: Thu, 17 Jul 2025 14:04:28 -0500 Subject: [PATCH] Refactor settings template to improve structure and enhance readability of room editor functionality --- inventory/templates/settings.html | 236 +++++++++++++++--------------- 1 file changed, 119 insertions(+), 117 deletions(-) diff --git a/inventory/templates/settings.html b/inventory/templates/settings.html index e159e51..25460aa 100644 --- a/inventory/templates/settings.html +++ b/inventory/templates/settings.html @@ -25,32 +25,32 @@ }; }); } - + function sanitizeFk(val) { if (val && val !== "null" && val !== "" && val !== "None") { return /^\d+$/.test(val) ? parseInt(val, 10) : val; } return null; } - + const roomOptions = Array.from(document.getElementById('room-list').options); - + const rooms = roomOptions.map(opt => { const id = opt.value?.trim(); const name = opt.textContent.trim(); const sectionId = sanitizeFk(opt.dataset.sectionId); const functionId = sanitizeFk(opt.dataset.functionId); - + const result = { name, ...(id ? { id } : {}), section_id: sectionId, function_id: functionId }; - + return result; }); - + return { brands: extractOptions("brand"), types: extractOptions("type"), @@ -76,9 +76,9 @@ headers: { 'Content-Type': 'application/json' }, body: JSON.stringify(state) }); - + const contentType = response.headers.get("content-type"); - + if (!response.ok) { if (contentType && contentType.includes("application/json")) { const data = await response.json(); @@ -88,11 +88,11 @@ throw new Error("Unexpected response:\n" + text.slice(0, 200)); } } - + const data = await response.json(); console.log("Sync result:", data); renderToast({ message: 'Settings updated successfully.', type: 'success' }); - + } catch (err) { console.error("Submission error:", err); renderToast({ message: `Failed to update settings, ${err}`, type: 'danger' }); @@ -112,13 +112,19 @@ {% endblock %} {% block content %} -
-
-
-
- Inventory Settings -
+ +
+
{{ combos.render_combobox( @@ -138,10 +144,7 @@
-
-
-
-
Location Settings
+
{{ combos.render_combobox( @@ -196,127 +199,126 @@
-
-