mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-10-23 23:46:35 +00:00
feat(tours): show a multi-day tour's stages in the list and put each on a day
A multi-day tour in the planner's list of the trip's tours now unfolds into its stages (MDT-02), so the stages can be seen together and fitted into the trip without leaving the one route they are cut from. - The fold beside a multi-day tour lists its stages in route order, each from stop to stop with its distance, climb, descent and moving time, read off the saved tour the way the planner reads them, and below them what the whole tour adds up to. A value no stage tells is left out, a total some stages do not tell is marked as at least that much and says for how many, and a stage whose route is not planned yet says so. - Each stage has its own day: a pill opens the trip's days, moves the stage to another one or takes it off again. A stage without a day shows a dashed "No day" pill. A day holds a tour, or one of its stages, once, and a stage is on one day at most; the plan's own offline path writes it. - A stage opens in the planner: the tour opens as any tour does and the stage is shown once its points are in. - The day plan names the stage a day holds with its own figures, and the day's route runs to that stage's start and on from its end; the trip map draws that stretch only. The tour list still counts a tour once, however many days hold it or its stages. - A saved change that takes a stage away (its stage end gone, the tour a day tour again, back to the recorded track) takes it off its day in the same write and tells every client; the planner says so before the save. - REST and the assign_place_to_day tool take the stage by the key of the stop it starts at, with the same checks; list_tours names the stops between the stages and the stage each day holds. A day assignment remembers its stage by that key (migration 046010); every assignment made before holds the whole tour, as it did.
This commit is contained in:
@@ -28,6 +28,9 @@ describe('assignment Tours read-model merge', () => {
|
||||
incoming_leg_transport_mode: 'cycling',
|
||||
};
|
||||
expect(assignmentSchema.parse({ ...ordinary, ...fields })).toMatchObject(fields);
|
||||
// MDT-02: the stage of a multi-day tour the day holds, null for the whole tour.
|
||||
expect(assignmentSchema.parse({ ...ordinary, tour_stage_key: 'stop-1xx' }).tour_stage_key).toBe('stop-1xx');
|
||||
expect(assignmentSchema.parse({ ...ordinary, tour_stage_key: null }).tour_stage_key).toBeNull();
|
||||
expect(assignmentSchema.parse({ ...ordinary, tour_place_id: null, tour_route_geometry: null })).toMatchObject({
|
||||
tour_place_id: null,
|
||||
tour_route_geometry: null,
|
||||
@@ -55,6 +58,16 @@ describe('assignmentCreateRequestSchema', () => {
|
||||
expect(assignmentCreateRequestSchema.safeParse({ place_id: '2', notes: null }).success).toBe(true);
|
||||
expect(assignmentCreateRequestSchema.safeParse({}).success).toBe(false);
|
||||
});
|
||||
|
||||
it('MDT-SH-012: takes the stage of a multi-day tour by the key of the stop it starts at', () => {
|
||||
expect(assignmentCreateRequestSchema.parse({ place_id: 2, tour_stage_key: 'stop-1xx' })).toEqual({
|
||||
place_id: 2,
|
||||
tour_stage_key: 'stop-1xx',
|
||||
});
|
||||
for (const tour_stage_key of ['', 'short', 'not a key!', null, 3]) {
|
||||
expect(assignmentCreateRequestSchema.safeParse({ place_id: 2, tour_stage_key }).success).toBe(false);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
describe('assignmentMoveRequestSchema', () => {
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import { assignmentPlaceSchema } from '../place/place.schema';
|
||||
import { stationKeySchema } from '../tours/tours.schema';
|
||||
|
||||
import { z } from 'zod';
|
||||
|
||||
@@ -57,6 +58,11 @@ export const assignmentSchema = z.object({
|
||||
accommodation_id: z.number().nullable().optional(),
|
||||
tour_place_id: z.number().nullable().optional(),
|
||||
tour_route_geometry: z.string().nullable().optional(),
|
||||
/**
|
||||
* MDT-02: the stage of a multi-day tour this day holds, by the key of the
|
||||
* stop the stage starts at; null where the day holds the whole tour or a place.
|
||||
*/
|
||||
tour_stage_key: z.string().nullable().optional(),
|
||||
participants: z.array(assignmentParticipantSchema).optional(),
|
||||
created_at: z.string().optional(),
|
||||
place: assignmentPlaceSchema,
|
||||
@@ -66,6 +72,12 @@ export type Assignment = z.infer<typeof assignmentSchema>;
|
||||
export const assignmentCreateRequestSchema = z.object({
|
||||
place_id: z.union([z.number(), z.string()]),
|
||||
notes: z.string().nullable().optional(),
|
||||
/**
|
||||
* MDT-02: puts one stage of a multi-day tour on the day instead of the whole
|
||||
* tour, by the key of the stop the stage starts at (the tour list's
|
||||
* `stage_stops`). A stage is on one day at most.
|
||||
*/
|
||||
tour_stage_key: stationKeySchema.optional(),
|
||||
});
|
||||
export type AssignmentCreateRequest = z.infer<typeof assignmentCreateRequestSchema>;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user