Show parent > child location on detail pages, add location move
Deploy to LXC / deploy (push) Successful in 18s
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:
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user