mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-11-26 06:37:33 +00:00
* feat(dayplan): persist per-leg and per-day travel mode (#1281) The day-plan route used one transport mode for the whole day, held only in ephemeral state. Store it instead: leg_transport_mode on an assignment is the mode of the leg leaving that stop (null = inherit the day default), and days gains a default_transport_mode. Both nullable, so existing itineraries are unchanged. Adds PUT /assignments/:id/transport and PUT /days/:id/transport — their own endpoints so setting the day default can't wipe notes/title the way the general day update would — mirroring the assignment_time path. * feat(dayplan): choose the travel mode per segment (#1281) Each leg between two stops now routes with its own mode, so a day can mix walking, driving and plugin-routed legs. Tap the connector between two places to change that leg's mode (desktop popup / mobile sheet); the whole-day Foot/Car picker sets the persisted day default and leaves explicitly-set legs alone. The connector and map redraw in the chosen mode, and each route segment is tagged with the mode it was drawn in. New strings across all 23 locales.
This commit is contained in:
@@ -40,6 +40,7 @@ export function getAssignmentWithPlace(assignmentId: number | bigint) {
|
||||
notes: a.notes,
|
||||
assignment_time: a.assignment_time ?? null,
|
||||
assignment_end_time: a.assignment_end_time ?? null,
|
||||
leg_transport_mode: a.leg_transport_mode ?? null,
|
||||
participants,
|
||||
created_at: a.created_at,
|
||||
place: {
|
||||
@@ -201,6 +202,17 @@ export function updateTime(id: string | number, placeTime: string | null, endTim
|
||||
return getAssignmentWithPlace(Number(id));
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the travel mode of the leg leaving this stop (#1281). null clears the
|
||||
* override so the leg falls back to the day's default_transport_mode. This is
|
||||
* sticky by design: changing the whole-day default never touches a leg that
|
||||
* carries its own explicit mode.
|
||||
*/
|
||||
export function setLegTransportMode(id: string | number, mode: string | null) {
|
||||
db.prepare('UPDATE day_assignments SET leg_transport_mode = ? WHERE id = ?').run(mode ?? null, id);
|
||||
return getAssignmentWithPlace(Number(id));
|
||||
}
|
||||
|
||||
export function setParticipants(assignmentId: string | number, userIds: number[]) {
|
||||
db.prepare('DELETE FROM assignment_participants WHERE assignment_id = ?').run(assignmentId);
|
||||
if (userIds.length > 0) {
|
||||
|
||||
Reference in New Issue
Block a user