fix(categories): broaden leaf detection for /extern/*/{vin,mdl}_items #15

Merged
root merged 1 commits from fix-extern-items-leaves-prod into main 2026-05-16 10:30:56 +03:00
2 changed files with 22 additions and 15 deletions

View File

@@ -1190,8 +1190,12 @@ export class CatalogService {
lower.includes("/bom/") ||
lower.includes("/bomdetails") ||
lower.includes("/partinfo/") ||
lower.includes("/servicepart/vin_items") ||
lower.includes("image-board.action") // PSA illustration leaf
// PL24 P5 leaf items endpoints — chemicals, servicepart, accessories,
// any /extern/<kind>/(vin|mdl)_items combination. These return parts,
// not subgroups, so they must short-circuit drill-down.
/\/extern\/[^/]+\/(vin_items|mdl_items)\b/.test(lower) ||
lower.includes("image-board.action") || // PSA illustration leaf
lower.includes("json-vin-bom-detail.action")
);
}

View File

@@ -517,20 +517,17 @@ export class CategoriesService {
return [];
}
// BOM / servicepart item links are leaf categories — they return parts, not subgroups
// BOM / *_items / partinfo / image-board pages all return PARTS, not
// subgroups. Drilling into them used to insert per-part endpoints as
// ghost child categories — keep the regex wide so any /extern/{kind}/
// (vin|mdl)_items endpoint is recognised, not just /servicepart/.
const lp = linkPath.toLowerCase();
if (
lp.includes("/bom/") ||
lp.includes("/bomdetails") ||
lp.includes("/partinfo/") ||
lp.includes("/servicepart/vin_items") ||
// PSA / Hyundai / Opel / Volvo image-board pages and the Ford VIN
// vin-image-board.action equivalent. Drilling into them yields BOM rows,
// not sub-groups — let getCategoryWithParts handle those as parts.
/\/extern\/[^/]+\/(vin_items|mdl_items)\b/.test(lp) ||
lp.includes("image-board.action") ||
// json-vin-bom-detail.action is the per-part endpoint (one level past a
// leaf). If any code ever inserts it as a category linkPath, treat the
// node as a dead-end leaf so the UI doesn't loop into it.
lp.includes("json-vin-bom-detail.action")
) {
return [];
@@ -1178,11 +1175,17 @@ export class CategoriesService {
? !!c.linkPath && dbChildCount === 0
: c.source === "parts-catalogs"
? !!c.linkPath?.startsWith("pcat:") && dbChildCount === 0
: c.linkPath?.toLowerCase()?.includes("/bom/") ||
c.linkPath?.toLowerCase()?.includes("/bomdetails") ||
c.linkPath?.toLowerCase()?.includes("/partinfo/") ||
c.linkPath?.toLowerCase()?.includes("/servicepart/vin_items") ||
(!c.linkPath && dbChildCount === 0);
: (() => {
const lp = c.linkPath?.toLowerCase() ?? "";
return (
lp.includes("/bom/") ||
lp.includes("/bomdetails") ||
lp.includes("/partinfo/") ||
/\/extern\/[^/]+\/(vin_items|mdl_items)\b/.test(lp) ||
lp.includes("image-board.action") ||
(!c.linkPath && dbChildCount === 0)
);
})();
return {
...c,
schemaImageUrl: picMap.get(c.id) || null,