fix(categories): broaden leaf detection to all /extern/*/{vin,mdl}_items endpoints

The leaf-path checks only matched /servicepart/vin_items literally, but
PL24's P5 modern catalog ships the same shape under /chemicals/vin_items,
/accessories/vin_items, /chemicals/mdl_items, etc. When user clicked a
"Rötuşkalemseti" (touch-up paint set) category whose linkPath was
/p5vwag/extern/chemicals/vin_items, the code drilled in, treated each
paint chemical's per-part URL (?partno=LLSMAX010) as a sub-category,
and inserted 228 ghost rows under it. Replace the literal substring
match with a regex that covers the whole /extern/{kind}/(vin|mdl)_items
pattern; apply to both the user-vehicle (categories.service) and the
catalog (catalog.service) flows.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-05-16 10:30:33 +03:00
parent 51607a3886
commit 3ddb18737c
2 changed files with 22 additions and 15 deletions

View File

@@ -1190,8 +1190,12 @@ export class CatalogService {
lower.includes("/bom/") || lower.includes("/bom/") ||
lower.includes("/bomdetails") || lower.includes("/bomdetails") ||
lower.includes("/partinfo/") || lower.includes("/partinfo/") ||
lower.includes("/servicepart/vin_items") || // PL24 P5 leaf items endpoints — chemicals, servicepart, accessories,
lower.includes("image-board.action") // PSA illustration leaf // 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 []; 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(); const lp = linkPath.toLowerCase();
if ( if (
lp.includes("/bom/") || lp.includes("/bom/") ||
lp.includes("/bomdetails") || lp.includes("/bomdetails") ||
lp.includes("/partinfo/") || lp.includes("/partinfo/") ||
lp.includes("/servicepart/vin_items") || /\/extern\/[^/]+\/(vin_items|mdl_items)\b/.test(lp) ||
// 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.
lp.includes("image-board.action") || 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") lp.includes("json-vin-bom-detail.action")
) { ) {
return []; return [];
@@ -1178,11 +1175,17 @@ export class CategoriesService {
? !!c.linkPath && dbChildCount === 0 ? !!c.linkPath && dbChildCount === 0
: c.source === "parts-catalogs" : c.source === "parts-catalogs"
? !!c.linkPath?.startsWith("pcat:") && dbChildCount === 0 ? !!c.linkPath?.startsWith("pcat:") && dbChildCount === 0
: c.linkPath?.toLowerCase()?.includes("/bom/") || : (() => {
c.linkPath?.toLowerCase()?.includes("/bomdetails") || const lp = c.linkPath?.toLowerCase() ?? "";
c.linkPath?.toLowerCase()?.includes("/partinfo/") || return (
c.linkPath?.toLowerCase()?.includes("/servicepart/vin_items") || lp.includes("/bom/") ||
(!c.linkPath && dbChildCount === 0); lp.includes("/bomdetails") ||
lp.includes("/partinfo/") ||
/\/extern\/[^/]+\/(vin_items|mdl_items)\b/.test(lp) ||
lp.includes("image-board.action") ||
(!c.linkPath && dbChildCount === 0)
);
})();
return { return {
...c, ...c,
schemaImageUrl: picMap.get(c.id) || null, schemaImageUrl: picMap.get(c.id) || null,