// Lagerorte sind verschachtelbar (Hedingen → Keller → Schublade 1). Gleichnamige // Orte ("Schublade 1" an mehreren Stellen) sind nur am Pfad unterscheidbar – // deshalb zeigen die Auswahlfelder den ganzen Pfad statt nur den Namen. /** Pfad eines Lagerorts als "Hedingen → Keller → Schublade 1". */ export function locationPath(loc, all) { if (!loc) return ""; const byId = new Map(all.map((l) => [l.id, l])); const teile = [loc.name]; const gesehen = new Set([loc.id]); let pid = loc.parent_id; while (pid != null && byId.has(pid) && !gesehen.has(pid)) { const p = byId.get(pid); teile.unshift(p.name); gesehen.add(pid); pid = p.parent_id; } return teile.join(" → "); } /** Pfad zu einer Lagerort-ID (oder "" wenn unbekannt/leer). */ export function locationPathById(id, all) { if (id == null || id === "") return ""; const loc = all.find((l) => l.id === id); return loc ? locationPath(loc, all) : ""; } /** * Optionen fürs