Jonna Marie Matthiesen Copilot commited on
Commit ·
9527fc8
1
Parent(s): ecc183e
Apply default_device when switching between base families
Browse filesPass resetDefaults flag to updateDependentFilters on family switch so
the device filter resets to the family's configured default rather than
keeping the previous family's device selection.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
app.js
CHANGED
|
@@ -339,8 +339,9 @@ function populateFilters() {
|
|
| 339 |
updateDependentFilters();
|
| 340 |
}
|
| 341 |
|
| 342 |
-
function updateDependentFilters() {
|
| 343 |
const opts = availableOptions();
|
|
|
|
| 344 |
|
| 345 |
config.filters.forEach(f => {
|
| 346 |
let vals = opts[f.column] || [];
|
|
@@ -354,9 +355,9 @@ function updateDependentFilters() {
|
|
| 354 |
});
|
| 355 |
}
|
| 356 |
const strVals = vals.map(String);
|
| 357 |
-
|
| 358 |
-
|
| 359 |
-
|
| 360 |
const defaultVal = f.column === GROUP_BY && familyCfg.default_device;
|
| 361 |
if (defaultVal && strVals.includes(String(defaultVal))) {
|
| 362 |
filters[f.column] = defaultVal;
|
|
@@ -746,7 +747,7 @@ async function switchBaseFamily(baseFamilyKey) {
|
|
| 746 |
);
|
| 747 |
assignModelColors();
|
| 748 |
renderSidebar();
|
| 749 |
-
updateDependentFilters();
|
| 750 |
render();
|
| 751 |
}
|
| 752 |
|
|
|
|
| 339 |
updateDependentFilters();
|
| 340 |
}
|
| 341 |
|
| 342 |
+
function updateDependentFilters(resetDefaults) {
|
| 343 |
const opts = availableOptions();
|
| 344 |
+
const familyCfg = config.model_families?.[activeFamilyKey()] || {};
|
| 345 |
|
| 346 |
config.filters.forEach(f => {
|
| 347 |
let vals = opts[f.column] || [];
|
|
|
|
| 355 |
});
|
| 356 |
}
|
| 357 |
const strVals = vals.map(String);
|
| 358 |
+
const needsReset = resetDefaults || !strVals.includes(String(filters[f.column]));
|
| 359 |
+
if (needsReset) {
|
| 360 |
+
// Prefer family-specific default_device for the device/group_by filter
|
| 361 |
const defaultVal = f.column === GROUP_BY && familyCfg.default_device;
|
| 362 |
if (defaultVal && strVals.includes(String(defaultVal))) {
|
| 363 |
filters[f.column] = defaultVal;
|
|
|
|
| 747 |
);
|
| 748 |
assignModelColors();
|
| 749 |
renderSidebar();
|
| 750 |
+
updateDependentFilters(true);
|
| 751 |
render();
|
| 752 |
}
|
| 753 |
|