wire webui region coordinate edit toggle
This commit is contained in:
1 parent
9b03556b7d
commit
e3bf99149d
2 files changed
+15
-1
No files matched your search
@@ -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
|
||||
|
||||
@@ -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 });
|
||||
|
||||
Reference in new issue
Block a user