mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-10-19 13:36:48 +00:00
api: PUT /assignments/:id/transport gains direction (outgoing|incoming)
This commit is contained in:
@@ -175,7 +175,9 @@ export class AssignmentOpsController {
|
||||
if (!this.assignments.getAssignmentForTrip(id, tripId)) {
|
||||
throw new HttpException({ error: 'Assignment not found' }, 404);
|
||||
}
|
||||
const assignment = this.assignments.setLegTransportMode(id, body.transport_mode ?? null);
|
||||
const assignment = body.direction === 'incoming'
|
||||
? this.assignments.setIncomingLegTransportMode(id, body.transport_mode ?? null)
|
||||
: this.assignments.setLegTransportMode(id, body.transport_mode ?? null);
|
||||
this.assignments.broadcast(tripId, 'assignment:updated', { assignment }, socketId);
|
||||
return { assignment };
|
||||
}
|
||||
|
||||
@@ -272,6 +272,17 @@ export class AssignmentsService {
|
||||
return this.getAssignmentWithPlace(Number(id));
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the travel mode of the leg arriving at this stop (#1281 boundary legs).
|
||||
* Mirrors setLegTransportMode but targets incoming_leg_transport_mode; inert
|
||||
* when the previous timeline element is a place (the column is only read for
|
||||
* non-place origins like a booking arrival or a morning hotel departure).
|
||||
*/
|
||||
setIncomingLegTransportMode(id: string | number, mode: string | null) {
|
||||
this.dbs.run('UPDATE day_assignments SET incoming_leg_transport_mode = ? WHERE id = ?', mode ?? null, id);
|
||||
return this.getAssignmentWithPlace(Number(id));
|
||||
}
|
||||
|
||||
setParticipants(assignmentId: string | number, userIds: number[]) {
|
||||
this.dbs.transaction(() => {
|
||||
this.dbs.run('DELETE FROM assignment_participants WHERE assignment_id = ?', assignmentId);
|
||||
|
||||
Reference in New Issue
Block a user