Clean up label-embedding architecture

- Move {id,label} stripping into _SetCriterion.from_json() so both
  MultiCriterion and ChoiceCriterion normalise at the parse boundary;
  the querying layer stays typed (list[int] / list[str]) and clean.
- Revert MultiCriterion to a thin _extra_q() override; _SetCriterion.to_q()
  is no longer duplicated.
- JS: readSearchSelect always emits {id, label} objects — no conditional
  mixed-type arrays. filter_bar.js stores them as-is for all fields,
  removing the fragile isIdField hardcoded list.
- Update tests to use the {id, label} filter format.

https://claude.ai/code/session_01EyAJcMoDktLrY9tSbdHViA
This commit is contained in:
Claude
2026-06-08 18:33:33 +00:00
committed by Lukáš Kucharczyk
parent 83cbac9505
commit d9902146dc
5 changed files with 36 additions and 78 deletions
+7 -32
View File
@@ -71,38 +71,13 @@
if (modifier === "NOT_NULL" || modifier === "IS_NULL") {
filter[field] = { modifier: modifier };
} else if (included.length > 0 || excluded.length > 0) {
var isIdField =
field === "platform" ||
field === "game" ||
field === "device" ||
field === "games";
if (isIdField) {
// Store {id, label} objects so the filter URL/preset is self-describing
// and pills can be rendered without a DB lookup (Stash-style).
filter[field] = {
value: included.map(function (item) {
return typeof item === "object"
? {id: parseInt(item.id, 10), label: item.label || ""}
: {id: parseInt(item, 10), label: ""};
}),
excludes: excluded.map(function (item) {
return typeof item === "object"
? {id: parseInt(item.id, 10), label: item.label || ""}
: {id: parseInt(item, 10), label: ""};
}),
modifier: modifier || "INCLUDES",
};
} else {
filter[field] = {
value: included.map(function (item) {
return typeof item === "object" ? item.id : item;
}),
excludes: excluded.map(function (item) {
return typeof item === "object" ? item.id : item;
}),
modifier: modifier || "INCLUDES",
};
}
// All filter pills carry {id, label}; store them as-is so the filter
// URL and saved presets are self-describing (Stash-style).
filter[field] = {
value: included.map(function (item) { return {id: item.id, label: item.label}; }),
excludes: excluded.map(function (item) { return {id: item.id, label: item.label}; }),
modifier: modifier || "INCLUDES",
};
}
});
+2 -3
View File
@@ -436,11 +436,10 @@
}
var value = pill.getAttribute("data-value");
var label = pill.getAttribute("data-label") || "";
var entry = label ? {id: value, label: label} : value;
if (pill.getAttribute("data-search-select-type") === "exclude") {
excluded.push(entry);
excluded.push({id: value, label: label});
} else {
included.push(entry);
included.push({id: value, label: label});
}
});
}