diff --git a/tests/test_webui_source_guards.py b/tests/test_webui_source_guards.py index e6ebdfd..ebb1648 100644 --- a/tests/test_webui_source_guards.py +++ b/tests/test_webui_source_guards.py @@ -18,6 +18,7 @@ def test_config_form_bool_literal_coercion_guard(): assert 'if (type === "bool")' in src assert '["1", "true", "yes", "y", "on"]' in src assert '["0", "false", "no", "n", "off", ""]' in src + assert "syncRegionCoordEditability" in src def test_runtime_actions_reservation_fields_guarded(): @@ -41,4 +42,3 @@ def test_runtime_device_actions_send_back_key_handles_error(): body = m.group("body") assert "try {" in body assert "catch" in body - diff --git a/webui/js/config_form.js b/webui/js/config_form.js index 9ec45d8..5224ce1 100644 --- a/webui/js/config_form.js +++ b/webui/js/config_form.js @@ -25,6 +25,19 @@ function syncMirrorFields() { } } +function syncRegionCoordEditability() { + const toggle = document.querySelector('#region_coords_edit_enabled'); + if (!toggle) return; + const apply = () => { + const enabled = !!toggle.checked; + document.querySelectorAll('[data-index]').forEach((el) => { + el.disabled = !enabled; + }); + }; + apply(); + toggle.addEventListener('change', apply); +} + function getConfigValue(cfg, key) { if (!cfg || !key) return undefined; if (Object.prototype.hasOwnProperty.call(cfg, key)) return cfg[key]; @@ -128,6 +141,7 @@ async function loadConfig() { try { const cfg = await apiGet("/api/config"); applyConfigToUI(cfg); + syncRegionCoordEditability(); toast("配置已加载", "success"); } catch (e) { toast("配置加载失败:" + e.message, "error", { duration: 5000 });