Fix weather settings layout groups

This commit is contained in:
firestar5683
2026-04-22 11:19:52 -05:00
parent 94e28e2708
commit 04f52c4ac7
2 changed files with 42 additions and 33 deletions
@@ -43,6 +43,18 @@ function getSectionsWithSlug() {
}))
}
function isGroupParam(param) {
return param?.ui_type === "group"
}
function isParamEnabledForChildren(paramOrKey) {
const param = typeof paramOrKey === "string" ? state.paramMetaByKey[paramOrKey] : paramOrKey
if (isGroupParam(param)) return true
const key = typeof paramOrKey === "string" ? paramOrKey : param?.key
return !!state.values[key]
}
function toSelectValue(value) {
return value === null || value === undefined ? "" : String(value)
}
@@ -715,12 +727,13 @@ function handleSectionTabClick(sectionSlug, event) {
function renderSettingRow(p) {
if (p.parent_key && !state.filter) {
if (!state.values[p.parent_key]) return ""
if (!isParamEnabledForChildren(p.parent_key)) return ""
if (!state.expanded[p.parent_key]) return ""
}
const isNumeric = p.ui_type === "numeric"
const isColor = p.ui_type === "color"
const isGroup = isGroupParam(p)
const isChild = p.parent_key ? "ds-child-modifier" : ""
const lockReason = getSettingLockReason(p)
const isLocked = lockReason !== ""
@@ -733,7 +746,7 @@ function renderSettingRow(p) {
${p.description ? html`<div class="ds-row-desc">${p.description}</div>` : ""}
${lockReason ? html`<div class="ds-row-desc"><strong>Locked:</strong> ${lockReason}</div>` : ""}
${() => p.is_parent_toggle && state.values[p.key] ? html`
${() => p.is_parent_toggle && isParamEnabledForChildren(p) ? html`
<div class="ds-manage-btn" @click="${() => toggleManage(p.key)}">
${state.expanded[p.key] ? "Close" : "Manage"}
<i class="bi bi-chevron-${state.expanded[p.key] ? "up" : "down"}"></i>
@@ -829,7 +842,7 @@ function renderSettingRow(p) {
?disabled="${() => isLocked || isStockColorValue(state.values[p.key])}"
@click="${() => resetColorParam(p)}">Stock</button>
</div>
` : html`
` : isGroup ? "" : html`
<input
type="checkbox"
class="ds-toggle"
@@ -853,7 +866,7 @@ function renderSettingTree(paramsList, parentKey = null) {
if (row) rendered.push(row)
if (!hasChildParams(paramsList, param.key)) continue
if (!state.values[param.key] || !state.expanded[param.key]) continue
if (!isParamEnabledForChildren(param) || !state.expanded[param.key]) continue
rendered.push(...renderSettingTree(paramsList, param.key))
}
@@ -1087,15 +1087,14 @@
"description": "Automatically adjust driving behavior based on real-time weather. Helps maintain comfort and safety in low visibility, rain, or snow.",
"data_type": "bool",
"ui_type": "toggle",
"is_parent_toggle": true
"is_parent_toggle": true,
"parent_key": "QOLLongitudinal"
},
{
"key": "LowVisiblityWeather",
"key": "LowVisibilityOffsets",
"label": "Low Visibility (fog)",
"description": "Customise settings for driving in low visibility situations",
"data_type": "bool",
"ui_type": "toggle",
"ui_type": "group",
"is_parent_toggle": true,
"parent_key": "WeatherPresets"
},
@@ -1108,7 +1107,7 @@
"min": 0.0,
"max": 3.0,
"step": 0.01,
"parent_key": "LowVisiblityWeather"
"parent_key": "LowVisibilityOffsets"
},
{
"key": "IncreasedStoppedDistanceLowVisibility",
@@ -1118,7 +1117,7 @@
"ui_type": "numeric",
"min": 0.0,
"max": 10.0,
"parent_key": "LowVisiblityWeather"
"parent_key": "LowVisibilityOffsets"
},
{
"key": "ReduceAccelerationLowVisibility",
@@ -1129,7 +1128,7 @@
"min": 0.0,
"max": 99.0,
"step": 1.0,
"parent_key": "LowVisiblityWeather"
"parent_key": "LowVisibilityOffsets"
},
{
"key": "ReduceLateralAccelerationLowVisibility",
@@ -1140,14 +1139,13 @@
"min": 0.0,
"max": 99.0,
"step": 1.0,
"parent_key": "LowVisiblityWeather"
"parent_key": "LowVisibilityOffsets"
},
{
"key": "RainWeather",
"key": "RainOffsets",
"label": "Light/Medium Rain",
"description": "Customise settings for driving in light & medium rain",
"data_type": "bool",
"ui_type": "toggle",
"ui_type": "group",
"is_parent_toggle": true,
"parent_key": "WeatherPresets"
},
@@ -1160,7 +1158,7 @@
"min": 0.0,
"max": 3.0,
"step": 0.01,
"parent_key": "RainWeather"
"parent_key": "RainOffsets"
},
{
"key": "IncreasedStoppedDistanceRain",
@@ -1170,7 +1168,7 @@
"ui_type": "numeric",
"min": 0.0,
"max": 10.0,
"parent_key": "RainWeather"
"parent_key": "RainOffsets"
},
{
"key": "ReduceAccelerationRain",
@@ -1181,7 +1179,7 @@
"min": 0.0,
"max": 99.0,
"step": 1.0,
"parent_key": "RainWeather"
"parent_key": "RainOffsets"
},
{
"key": "ReduceLateralAccelerationRain",
@@ -1192,14 +1190,13 @@
"min": 0.0,
"max": 99.0,
"step": 1.0,
"parent_key": "RainWeather"
"parent_key": "RainOffsets"
},
{
"key": "HeavyRainWeather",
"key": "RainStormOffsets",
"label": "Heavy Rain",
"description": "Customise settings for driving in heavy rain",
"data_type": "bool",
"ui_type": "toggle",
"ui_type": "group",
"is_parent_toggle": true,
"parent_key": "WeatherPresets"
},
@@ -1212,7 +1209,7 @@
"min": 0.0,
"max": 3.0,
"step": 0.01,
"parent_key": "HeavyRainWeather"
"parent_key": "RainStormOffsets"
},
{
"key": "IncreasedStoppedDistanceRainStorm",
@@ -1222,7 +1219,7 @@
"ui_type": "numeric",
"min": 0.0,
"max": 10.0,
"parent_key": "HeavyRainWeather"
"parent_key": "RainStormOffsets"
},
{
"key": "ReduceAccelerationRainStorm",
@@ -1233,7 +1230,7 @@
"min": 0.0,
"max": 99.0,
"step": 1.0,
"parent_key": "HeavyRainWeather"
"parent_key": "RainStormOffsets"
},
{
"key": "ReduceLateralAccelerationRainStorm",
@@ -1244,14 +1241,13 @@
"min": 0.0,
"max": 99.0,
"step": 1.0,
"parent_key": "HeavyRainWeather"
"parent_key": "RainStormOffsets"
},
{
"key": "SnowWeather",
"key": "SnowOffsets",
"label": "Snow",
"description": "Customise settings for driving in snow",
"data_type": "bool",
"ui_type": "toggle",
"ui_type": "group",
"is_parent_toggle": true,
"parent_key": "WeatherPresets"
},
@@ -1264,7 +1260,7 @@
"min": 0.0,
"max": 3.0,
"step": 0.01,
"parent_key": "SnowWeather"
"parent_key": "SnowOffsets"
},
{
"key": "IncreasedStoppedDistanceSnow",
@@ -1274,7 +1270,7 @@
"ui_type": "numeric",
"min": 0.0,
"max": 10.0,
"parent_key": "SnowWeather"
"parent_key": "SnowOffsets"
},
{
"key": "ReduceAccelerationSnow",
@@ -1285,7 +1281,7 @@
"min": 0.0,
"max": 99.0,
"step": 1.0,
"parent_key": "SnowWeather"
"parent_key": "SnowOffsets"
},
{
"key": "ReduceLateralAccelerationSnow",
@@ -1296,7 +1292,7 @@
"min": 0.0,
"max": 99.0,
"step": 1.0,
"parent_key": "SnowWeather"
"parent_key": "SnowOffsets"
},
{
"key": "SpeedLimitController",