Show parent > child location on detail pages, add location move
Deploy to LXC / deploy (push) Successful in 18s

- Device/component detail pages show "Parent › Child" for locations
- Device list cards show full location path
- Location edit form now includes a Parent selector to move locations
  between parents or make them top-level
- Prevents setting a location as its own parent

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-04-07 17:07:08 +07:00
parent 948617a285
commit 9102ffd8b4
8 changed files with 65 additions and 8 deletions
+19 -2
View File
@@ -47,7 +47,8 @@ export const load: PageServerLoad = async ({ url }) => {
model: devices.model,
condition: devices.condition,
year: devices.year,
locationName: locations.name
locationName: locations.name,
locationParentId: locations.parentId
})
.from(devices)
.leftJoin(locations, eq(devices.locationId, locations.id))
@@ -56,6 +57,17 @@ export const load: PageServerLoad = async ({ url }) => {
.limit(pageSize)
.offset((page - 1) * pageSize);
// Resolve parent location names
const parentIds = [...new Set(deviceList.filter(d => d.locationParentId).map(d => d.locationParentId!))];
let parentNameMap: Record<string, string> = {};
if (parentIds.length > 0) {
const parents = await db
.select({ id: locations.id, name: locations.name })
.from(locations)
.where(sql`${locations.id} IN ${parentIds}`);
for (const p of parents) parentNameMap[p.id] = p.name;
}
// Fetch first image for each device
const deviceIds = deviceList.map((d) => d.id);
let imageMap: Record<string, string> = {};
@@ -80,7 +92,12 @@ export const load: PageServerLoad = async ({ url }) => {
return {
devices: deviceList.map((d) => ({
...d,
thumbnail: imageMap[d.id] ?? null
thumbnail: imageMap[d.id] ?? null,
fullLocation: d.locationName
? (d.locationParentId && parentNameMap[d.locationParentId]
? `${parentNameMap[d.locationParentId]} ${d.locationName}`
: d.locationName)
: null
})),
total,
page,