feat(places): bulk "change category" from the selection toolbar

Closes the UI half of #1168: in the Places selection mode, a new tag button
before delete opens a category picker that applies one category (or "No
category") to every selected place in a single request. Adds a REST
/places/bulk-update endpoint reusing updatePlacesMany, an offline-aware repo +
store action that patches both the place pool and the day-assignment
projections, undo grouped by each place's prior category, and the i18n keys
across all locales.
This commit is contained in:
Maurice
2026-06-29 23:01:16 +02:00
committed by Maurice
parent 42b45dcd82
commit 50609b078a
58 changed files with 356 additions and 5 deletions
@@ -225,6 +225,36 @@ export class PlacesController {
return { deleted, count: deleted.length };
}
@Post('bulk-update')
@HttpCode(200)
bulkUpdate(
@CurrentUser() user: User,
@Param('tripId') tripId: string,
@Body() body: { ids?: unknown; category_id?: unknown },
@Headers('x-socket-id') socketId?: string,
) {
const trip = this.requireTrip(tripId, user);
this.requireEdit(trip, user);
const { ids } = body;
if (!Array.isArray(ids) || ids.some((v) => typeof v !== 'number')) {
throw new HttpException({ error: 'ids must be an array of numbers' }, 400);
}
if (ids.length === 0) {
return { updated: [], count: 0 };
}
// `category_id` may be a number or null (null clears it), so key presence —
// not truthiness — is what signals there's something to change.
if (!('category_id' in body)) {
throw new HttpException({ error: 'Provide at least one field to update' }, 400);
}
const updated = this.places.updateMany(tripId, ids, { category_id: body.category_id as number | null });
for (const place of updated) {
this.places.broadcast(tripId, 'place:updated', { place }, socketId);
this.places.onUpdated(place.id);
}
return { updated: updated.map((p) => p.id), count: updated.length };
}
@Get(':id')
get(@CurrentUser() user: User, @Param('tripId') tripId: string, @Param('id') id: string) {
this.requireTrip(tripId, user);
+4
View File
@@ -52,6 +52,10 @@ export class PlacesService {
return svc.deletePlacesMany(tripId, ids);
}
updateMany(tripId: string, ids: number[], data: Parameters<typeof svc.updatePlacesMany>[2]) {
return svc.updatePlacesMany(tripId, ids, data);
}
importGpx(
tripId: string,
buffer: Buffer,