From ec08915a1610eab4087ec82f589b5de74336f5e9 Mon Sep 17 00:00:00 2001 From: Maurice Date: Wed, 18 Nov 2026 16:52:05 +0100 Subject: [PATCH] fix(trips): a day added before the start leaves the plan on its dates Adding a day before a trip's start with "Keep bookings on their dates" moved almost everything a day earlier and emptied the last day. The day grid was always rebuilt by position: the n-th day row took the n-th date of the new range. With bookings kept on their dates, only timed bookings and stays were re-anchored afterwards. Places, day notes, bookings with no time and a booking's place in a day's order stayed on their re-dated rows and slid to the day before. Days added at both ends had the same problem. planDayGrid now takes keepDates. When the new range still holds every dated day, each of them keeps its date and the new days go around them. The server passes it unless the traveller chose to shift everything, and the trip dialog's warning check uses the same rule. A moved or shorter range still follows the positional rule the dialog describes, and "Shift everything" still moves the whole plan with the new start. Two things keyed outside the day rows followed the old rule. Road trip day boundaries are keyed by day number, so a new first day left each one on the day before its own. They now follow their days to their new numbers and go out to every screen. The owner's leave days moved by the change of start even when days were only added. They now move by as far as the trip's first day moved, which is nothing when days are only added. The help text of the option and the MCP description say what happens when days are added. Closes #3119 --- client/src/hooks/useTripRangeGuard.ts | 4 + scripts/ci/knip-baseline.json | 1 - .../RoadtripDayBoundaries.repository.ts | 9 + server/src/nest/days/days.service.ts | 44 +++ server/src/nest/trips/trips.controller.ts | 3 + server/src/nest/trips/trips.helpers.ts | 22 +- server/src/nest/trips/trips.mcp.ts | 5 +- server/src/nest/trips/trips.rpc.ts | 2 + server/src/nest/trips/trips.service.ts | 67 ++-- .../tests/integration/trip-date-range.test.ts | 351 ++++++++++++++++++ .../RoadtripDayBoundaries.repository.test.ts | 20 + server/tests/unit/mcp/tools-trips.test.ts | 31 ++ server/tests/unit/trips/trips.rpc.test.ts | 22 +- shared/src/i18n/ar/dashboard.ts | 2 +- shared/src/i18n/az/dashboard.ts | 2 +- shared/src/i18n/br/dashboard.ts | 2 +- shared/src/i18n/ca/dashboard.ts | 2 +- shared/src/i18n/cs/dashboard.ts | 2 +- shared/src/i18n/de/dashboard.ts | 2 +- shared/src/i18n/en/dashboard.ts | 2 +- shared/src/i18n/es/dashboard.ts | 2 +- shared/src/i18n/et/dashboard.ts | 2 +- shared/src/i18n/fr/dashboard.ts | 2 +- shared/src/i18n/gr/dashboard.ts | 2 +- shared/src/i18n/he/dashboard.ts | 2 +- shared/src/i18n/hu/dashboard.ts | 2 +- shared/src/i18n/id/dashboard.ts | 2 +- shared/src/i18n/it/dashboard.ts | 2 +- shared/src/i18n/ja/dashboard.ts | 2 +- shared/src/i18n/ko/dashboard.ts | 2 +- shared/src/i18n/nl/dashboard.ts | 2 +- shared/src/i18n/pl/dashboard.ts | 2 +- shared/src/i18n/ru/dashboard.ts | 2 +- shared/src/i18n/sk/dashboard.ts | 2 +- shared/src/i18n/sv/dashboard.ts | 2 +- shared/src/i18n/th/dashboard.ts | 2 +- shared/src/i18n/tr/dashboard.ts | 2 +- shared/src/i18n/uk/dashboard.ts | 2 +- shared/src/i18n/vi/dashboard.ts | 2 +- shared/src/i18n/zh-TW/dashboard.ts | 2 +- shared/src/i18n/zh/dashboard.ts | 2 +- shared/src/trip/day-grid.spec.ts | 36 ++ shared/src/trip/day-grid.ts | 29 +- 43 files changed, 625 insertions(+), 77 deletions(-) create mode 100644 server/tests/integration/trip-date-range.test.ts diff --git a/client/src/hooks/useTripRangeGuard.ts b/client/src/hooks/useTripRangeGuard.ts index e983425f6..4f39e7ef0 100644 --- a/client/src/hooks/useTripRangeGuard.ts +++ b/client/src/hooks/useTripRangeGuard.ts @@ -69,6 +69,10 @@ export function useTripRangeGuard(): { checking: boolean; check: (trip: Pick { + if (day_numbers.length === 0) return; + await this.nativeDelete({ trip: trip_id, day_number: { $in: [...day_numbers] } }); + } + /** * RB5 (`DaysService.shiftBoundariesBack`, the dated append) — `SELECT * day_number FROM roadtrip_day_boundaries WHERE trip_id = ? AND day_number diff --git a/server/src/nest/days/days.service.ts b/server/src/nest/days/days.service.ts index 43ca824a2..4ee37635d 100644 --- a/server/src/nest/days/days.service.ts +++ b/server/src/nest/days/days.service.ts @@ -737,6 +737,50 @@ export class DaysService { return { ...appended, trip: await this.getTripForViewer(trip, viewerId) }; } + /** + * After the trip's days were laid out again (TripsService.generateDays), each + * road trip day boundary follows its day to the number the day now has: they + * are keyed by day number, not by day (#3119). `before` is the days as they + * were, `rows` the new order. One on a day that went applies to no day and + * goes; one on a number no day held stays, unless a day takes that number now. + * Two steps, through numbers above every old and new one, since the number is + * the primary key and a CHECK keeps it at 1 or above. Returns the list after + * the move, or null when nothing changed. Runs inside the caller's transaction. + */ + async followDayNumbers( + tripId: number, + before: readonly { id: number; day_number: number }[], + rows: readonly { id: number | null }[], + ): Promise { + const dayAt = new Map(before.map((d) => [d.day_number, d.id])); + const numberOf = new Map(); + rows.forEach((row, i) => { + if (row.id !== null) numberOf.set(row.id, i + 1); + }); + // RB6 + const numbers = await this.roadtripDayBoundariesRepo.listDayNumbers(tripId); + const moves: { from: number; to: number }[] = []; + const dropped: number[] = []; + for (const from of numbers) { + const dayId = dayAt.get(from); + const to = dayId === undefined ? from : numberOf.get(dayId); + if (to === undefined) dropped.push(from); + else if (to !== from) moves.push({ from, to }); + } + const taken = new Set(moves.map((m) => m.to)); + dropped.push(...numbers.filter((n) => !dayAt.has(n) && taken.has(n))); + if (moves.length === 0 && dropped.length === 0) return null; + // RB4 + await this.roadtripDayBoundariesRepo.deleteForDays(tripId, dropped); + const parked = Math.max(...numbers, ...taken) + 1; + // RB7, twice. Within each step every target is distinct, so the order of + // the moves does not matter; the second step starts once all are parked. + await Promise.all(moves.map((m) => this.roadtripDayBoundariesRepo.moveDayNumber(tripId, m.from, m.from + parked))); + await Promise.all(moves.map((m) => this.roadtripDayBoundariesRepo.moveDayNumber(tripId, m.from + parked, m.to))); + // RB1 + return await this.roadtripDayBoundariesRepo.listForTrip(tripId); + } + /** * Boundaries are keyed by day number, so the ones on the days that moved back * move back with them. One at a time and from the last one down: the key is diff --git a/server/src/nest/trips/trips.controller.ts b/server/src/nest/trips/trips.controller.ts index 2f647eb2f..199239fee 100644 --- a/server/src/nest/trips/trips.controller.ts +++ b/server/src/nest/trips/trips.controller.ts @@ -226,6 +226,9 @@ export class TripsController { else logInfo(`${user.email} removed reminder for trip "${result.newTitle}"`); } this.trips.broadcast(id, 'trip:updated', { trip: result.updatedTrip }, socketId); + // To every screen, the saving one included: it holds the boundaries outside the trip. + if (result.boundaries) + this.trips.broadcast(id, 'roadtripBoundary:changed', { boundaries: result.boundaries }, undefined); return { trip: result.updatedTrip }; } catch (e: unknown) { if (e instanceof NotFoundError) throw new HttpException({ error: e.message }, 404); diff --git a/server/src/nest/trips/trips.helpers.ts b/server/src/nest/trips/trips.helpers.ts index 96b347cb4..10956f5e4 100644 --- a/server/src/nest/trips/trips.helpers.ts +++ b/server/src/nest/trips/trips.helpers.ts @@ -1,5 +1,5 @@ import { ValidationError } from '../common/domain-errors'; -import { MAX_TRIP_DAYS, tripSpanDays, type PermissionKey } from '@trek/shared'; +import { addIsoDays, MAX_TRIP_DAYS, tripSpanDays, type PermissionKey } from '@trek/shared'; /** * Pure helpers of the trips domain, moved out of trips.service.ts. Nothing @@ -61,3 +61,23 @@ export function tripUpdatePermissions(body: object): { action: PermissionKey; re if (TRIP_EDIT_FIELDS.some(sent)) needed.push({ action: 'trip_edit', refusal: 'No permission to edit this trip' }); return needed; } + +/** + * The start the owner's leave days move to when the trip's dates change: the + * old start moved by as far as the trip's first dated day moved. When the days + * move with a new start, that is the new start; when days were only added + * around the plan, the first day kept its date and the leave stays (#3119). + * Without a dated day to go by, the new start as it always was. + */ +export function leaveStartFor( + oldStart: string | null | undefined, + daysBefore: readonly { id: number; date: string | null }[], + dateNow: ReadonlyMap, + newStart: string | null | undefined, +): string | null | undefined { + const first = daysBefore.find((d) => d.date); + const firstNow = first ? dateNow.get(first.id) : null; + if (!oldStart || !first?.date || !firstNow) return newStart; + const moved = Math.round((Date.parse(`${firstNow}T00:00:00Z`) - Date.parse(`${first.date}T00:00:00Z`)) / 86_400_000); + return addIsoDays(oldStart, moved); +} diff --git a/server/src/nest/trips/trips.mcp.ts b/server/src/nest/trips/trips.mcp.ts index 339d54ee3..568bd3b06 100644 --- a/server/src/nest/trips/trips.mcp.ts +++ b/server/src/nest/trips/trips.mcp.ts @@ -251,7 +251,7 @@ export class TripsMcp { .enum(['keep_bookings', 'shift_all']) .optional() .describe( - 'When changing dates: keep_bookings (default) keeps dated reservations/accommodations on their dates while day plans move; shift_all moves the whole itinerary, bookings included', + 'When changing dates: keep_bookings (default) leaves everything on its date when days are only added before the start or after the end, and when the trip moves keeps dated reservations/accommodations on their dates while day plans move; shift_all moves the whole itinerary, bookings included', ), costs_mode: tripUpdateRequestSchema.shape.costs_mode.describe( 'How the trip keeps its costs: split (who paid and who shares each expense, with settling up) or totals (what the trip costs, nothing split). Who paid and the shares stay stored either way. Needs the budget_edit permission rather than trip_edit', @@ -336,13 +336,14 @@ export class TripsMcp { // role, as REST hands it on, so an admin's edit of a trip they do not own is one. const { role } = await this.guards.tripWriter(tripId, ctx.userId); try { - const { updatedTrip, removedDays } = await this.trips.update( + const { updatedTrip, removedDays, boundaries } = await this.trips.update( tripId, ctx.userId, { ...fields, date_shift_mode }, role, ); this.guards.safeBroadcast(tripId, 'trip:updated', { trip: updatedTrip }); + if (boundaries) this.guards.safeBroadcast(tripId, 'roadtripBoundary:changed', { boundaries }); // Only when days went, so the answer to a rename or a longer trip stays as it was. return ok({ trip: updatedTrip, ...(removedDays.length > 0 ? { removed_days: removedDays } : {}) }); } catch (err) { diff --git a/server/src/nest/trips/trips.rpc.ts b/server/src/nest/trips/trips.rpc.ts index 0265eccc2..ce84526bf 100644 --- a/server/src/nest/trips/trips.rpc.ts +++ b/server/src/nest/trips/trips.rpc.ts @@ -173,6 +173,8 @@ export class TripsRpc { role ?? 'user', ); this.realtime.broadcast(tripId, 'trip:updated', { trip: result.updatedTrip }); + if (result.boundaries) + this.realtime.broadcast(tripId, 'roadtripBoundary:changed', { boundaries: result.boundaries }); return result.updatedTrip; } catch (e) { if (e instanceof ValidationError) throw new BadParams(e.message); diff --git a/server/src/nest/trips/trips.service.ts b/server/src/nest/trips/trips.service.ts index b1dfc814f..6ae0bf753 100644 --- a/server/src/nest/trips/trips.service.ts +++ b/server/src/nest/trips/trips.service.ts @@ -32,6 +32,7 @@ import { type ActiveTrip, type DayGridPlan, type DayGridRemoval, + type RoadtripDayBoundary, type TrekWsPayload, type TrekWsTripEventName, type TripUpdateRequest, @@ -52,7 +53,7 @@ import { inOrder } from '../common/in-order'; import { UnitOfWork } from '../database/unit-of-work'; import { legacyBoundIntegerText } from '../common/row-id'; import { appClock } from '../common/timezoneService'; -import { assertTripSpan } from './trips.helpers'; +import { assertTripSpan, leaveStartFor } from './trips.helpers'; interface CreateTripData { title: string; @@ -78,6 +79,8 @@ export interface UpdateTripResult { oldReminder: number; /** The day rows a changed range took away, as they stood before; empty when none went. */ removedDays: DayGridRemoval[]; + /** The road trip day boundaries after they followed their days, or null when none moved. */ + boundaries: RoadtripDayBoundary[] | null; } export interface DeleteTripInfo { @@ -88,36 +91,6 @@ export interface DeleteTripInfo { ownerEmail?: string; } -export interface AddMemberResult { - member: { id: number; username: string; email: string; avatar?: string | null; role: string; avatar_url: string | null }; - targetUserId: number; - tripTitle: string; -} - -export interface TransferOwnershipResult { - tripTitle: string; - fromEmail: string; - toEmail: string; -} - -// ── Guest members (#1362) ─────────────────────────────────────────────────── -// -// A guest is a credential-less users row (is_guest=1) joined into trip_members, so -// it is assignable everywhere a real member is (budget splits, packing, to-dos, day -// participants) yet can never authenticate (the auth/global-list guards exclude -// is_guest=1). The display name lives in users.username so every existing JOIN that -// renders a member name shows the guest correctly; a synthetic, non-deliverable -// email keeps the UNIQUE/NOT NULL constraints satisfied. - -export interface GuestMember { - id: number; - username: string; - email: string; - role: 'member'; - is_guest: true; - avatar_url: null; -} - /** * Trip aggregate root, DI-native. Membership, the calendar export and the two * read aggregates live in their own domains now; what is left is the write core @@ -330,8 +303,11 @@ export class TripsService { * load-bearing against `UNIQUE(trip_id, day_number)`). The whole rebuild * runs in one `uow.transactional` — a savepoint when `updateTrip`'s own * block already holds the transaction, its own transaction from `create`. + * `keepDates` lets every day the new range still holds keep its date (#3119). + * The road trip day boundaries follow their days to the numbers they take; + * `boundaries` is the list after that, or null when none had to move. */ - async generateDays(tripId: number | bigint | string, startDate: string | null, endDate: string | null, dayCount?: number): Promise { + async generateDays(tripId: number | bigint | string, startDate: string | null, endDate: string | null, dayCount?: number, keepDates = false): Promise { const trip_id = Number(tripId); return await this.uow.transactional(async () => { const existing = await this.daysRepo.listForDayGrid(trip_id); // TP77 @@ -343,6 +319,7 @@ export class TripsService { startDate, endDate, dayCount, + keepDates, }); const dateBefore = new Map(existing.map(d => [d.id, d.date])); @@ -356,7 +333,7 @@ export class TripsService { else await this.daysRepo.setDayNumberAndDate(row.id, i + 1, row.date); // TP9 } for (const gone of plan.removed) await this.daysRepo.deleteById(gone.id); // TP11 - return plan; + return { ...plan, boundaries: await this.days.followDayNumbers(trip_id, existing, plan.rows) }; }); } @@ -486,6 +463,7 @@ export class TripsService { // The row, the leave entries that follow its dates and the rebuilt day grid are // one write: a failure halfway used to leave a trip whose days missed its dates. let removedDays: DayGridRemoval[] = []; + let boundaries: RoadtripDayBoundary[] | null = null; // the road trip day boundaries, when they moved with their days let vacayId: number | undefined; // the vacay plan whose leave days moved along (#2604) await this.uow.transactional(async () => { // Before the row: the rebase reads the outgoing currency off it (#1543). @@ -507,20 +485,27 @@ export class TripsService { costs_mode: newCostsMode, }); - if (trip.start_date && trip.end_date && newStart && newStart !== trip.start_date) - vacayId = await this.vacay.shiftOwnerEntriesForTripWindow(trip.user_id, trip.start_date, trip.end_date, newStart); - if (regenerate) { // Accommodations have no absolute date columns, so their pre-change dates must be // snapshotted before generateDays re-dates the day rows in place. const prevDays = await this.daysRepo.listOrderedForReorder(tripIdNum); // TP26 const prevDateByDayId = new Map(prevDays.map(d => [d.id, d.date])); - removedDays = (await this.generateDays(tripId, newStart || null, newEnd || null, dayCount)).removed; - if (data.date_shift_mode === 'shift_all') { + // Unless everything shifts, a range that still holds every day (one more day + // before the start or after the end) leaves each day, and all on it, on its + // date (#3119); only a moved or shorter range re-dates the days by position. + const shiftAll = data.date_shift_mode === 'shift_all'; + const grid = await this.generateDays(tripId, newStart || null, newEnd || null, dayCount, !shiftAll); + removedDays = grid.removed; + boundaries = grid.boundaries; + const newDays = await this.daysRepo.listOrderedForReorder(tripIdNum); // TP27 + const newDateByDayId = new Map(newDays.map(d => [d.id, d.date])); + // The owner's leave days follow the plan, not the new start (#3119). + const leaveStart = leaveStartFor(trip.start_date, prevDays, newDateByDayId, newStart); + if (trip.start_date && trip.end_date && leaveStart && leaveStart !== trip.start_date) + vacayId = await this.vacay.shiftOwnerEntriesForTripWindow(trip.user_id, trip.start_date, trip.end_date, leaveStart); + if (shiftAll) { // Explicit "shift everything": bookings stay glued to their (re-dated) day rows, // so re-stamp reservation_time to follow — same rules as reorderDays/insertDay. - const newDays = await this.daysRepo.listOrderedForReorder(tripIdNum); // TP27 - const newDateByDayId = new Map(newDays.map(d => [d.id, d.date])); await this.days.restampReservationDates(tripIdNum, prevDateByDayId, newDateByDayId); } else { // Default: generateDays re-dates day rows positionally; re-anchor dated bookings to @@ -554,7 +539,7 @@ export class TripsService { // same reasoning as `create`'s TP19 re-select above. const updatedTrip = await this.tripsRepo.findForViewer(tripId, userId); - return { updatedTrip, changes, isAdminEdit, ownerEmail, newTitle, newReminder, oldReminder, removedDays }; + return { updatedTrip, changes, isAdminEdit, ownerEmail, newTitle, newReminder, oldReminder, removedDays, boundaries }; } /** diff --git a/server/tests/integration/trip-date-range.test.ts b/server/tests/integration/trip-date-range.test.ts new file mode 100644 index 000000000..b36f079e4 --- /dev/null +++ b/server/tests/integration/trip-date-range.test.ts @@ -0,0 +1,351 @@ +/** + * What a new date range does to everything planned on a trip's days (#3119). + * Covers TRIP-RANGE-001 to TRIP-RANGE-009. + * + * Each case builds the same trip, Sun 10 to Thu 14 May 2026, with places, notes, + * timed and untimed bookings, a booking over two days, a flight leg, a booking's + * place in a day's order and two stays, one of them checking out on the last day. + * It then reads all of it in calendar terms (the date of the day each row hangs + * on, plus its own times) before and after the save, so a row that moves to + * another day shows up as a changed date, whatever the day ids do. + */ +import { buildApp } from '../../src/bootstrap'; +import { DayAccommodations } from '../../src/db/entities/DayAccommodations.entity'; +import { DayAssignments } from '../../src/db/entities/DayAssignments.entity'; +import { DayNotes } from '../../src/db/entities/DayNotes.entity'; +import { ReservationDayPositions } from '../../src/db/entities/ReservationDayPositions.entity'; +import { ReservationEndpoints } from '../../src/db/entities/ReservationEndpoints.entity'; +import { Reservations } from '../../src/db/entities/Reservations.entity'; +import { RoadtripDayBoundaries } from '../../src/db/entities/RoadtripDayBoundaries.entity'; +import { VacayEntries } from '../../src/db/entities/VacayEntries.entity'; +import { legacyBoundIntegerText } from '../../src/nest/common/row-id'; +import { authCookie } from '../helpers/auth'; +import type { FactoryOrm } from '../helpers/factories/context'; +import { makeDayAccommodation, makeDayAssignment, makeDayNote } from '../helpers/factories/itinerary'; +import { makePlace } from '../helpers/factories/places'; +import { makeReservation, makeReservationEndpoint } from '../helpers/factories/reservations'; +import { findRows, insertRow } from '../helpers/factories/rows'; +import { makeTrip, readTripDays } from '../helpers/factories/trips'; +import { makeUser } from '../helpers/factories/users'; +import { makeVacayEntry, makeVacayPlan } from '../helpers/factories/vacay'; +import { resetDatabase } from '../helpers/reset-database'; +import { resetRateLimits } from '../helpers/test-db'; +import { MikroORM } from '@mikro-orm/core'; +import type { INestApplication } from '@nestjs/common'; + +import type { Application } from 'express'; +import request from 'supertest'; +import { describe, it, expect, beforeAll, beforeEach, afterAll } from 'vitest'; + +let nestApp: INestApplication; +let app: Application; +let orm: FactoryOrm; + +beforeAll(async () => { + nestApp = await buildApp(); + app = nestApp.getHttpAdapter().getInstance(); + orm = nestApp.get(MikroORM); +}); +beforeEach(async () => { + await resetDatabase(orm); + await resetRateLimits(nestApp); +}); +afterAll(async () => { + await nestApp.close(); +}); + +const START = '2026-05-10'; +const END = '2026-05-14'; + +/** The trip of every case, with something on each of its five days. */ +async function plannedTrip() { + const { user } = await makeUser(orm); + const trip = await makeTrip(orm, user.id, { start_date: START, end_date: END }); + const days = await readTripDays(orm, trip.id); + const day = (date: string): number => { + const found = days.find((d) => d.date === date); + if (!found) throw new Error(`no day on ${date}`); + return found.id; + }; + const [d10, d11, d12, d13, d14] = ['10', '11', '12', '13', '14'].map((d) => day(`2026-05-${d}`)); + const museum = await makePlace(orm, trip.id, { name: 'Museum' }); + const market = await makePlace(orm, trip.id, { name: 'Market' }); + const beach = await makePlace(orm, trip.id, { name: 'Beach' }); + const hotel = await makePlace(orm, trip.id, { name: 'Harbour Hotel' }); + const lodge = await makePlace(orm, trip.id, { name: 'Lake Lodge' }); + + await makeDayAssignment(orm, d10, museum.id, { assignment_time: '10:00', assignment_end_time: '12:00' }); + await makeDayAssignment(orm, d12, market.id, { assignment_time: '09:00' }); + await makeDayAssignment(orm, d14, beach.id, { assignment_time: '15:00' }); + await makeDayNote(orm, d11, trip.id, { text: 'Pick up the car', time: '08:00' }); + await makeDayNote(orm, d14, trip.id, { text: 'Return the car', time: '18:00' }); + + const flight = await makeReservation(orm, trip.id, { + title: 'Flight out', + type: 'flight', + day: d10, + reservation_time: `${START}T08:30`, + }); + await makeReservationEndpoint(orm, flight.id, { role: 'from', local_date: START, local_time: '08:30' }); + const train = await makeReservation(orm, trip.id, { + title: 'Night train', + type: 'train', + day: d12, + endDay: d13, + reservation_time: '2026-05-12T22:15', + reservation_end_time: '2026-05-13T07:40', + }); + await insertRow(orm, ReservationDayPositions, { reservation: train.id, day: d12, position: 1.5 }); + await makeReservation(orm, trip.id, { title: 'Cooking class', type: 'event', day: d13 }); + await makeReservation(orm, trip.id, { + title: 'Farewell dinner', + type: 'restaurant', + day: d14, + reservation_time: `${END}T19:30`, + }); + + const harbour = await makeDayAccommodation(orm, trip.id, hotel.id, d10, d12, { check_in: '15:00' }); + await makeReservation(orm, trip.id, { + title: 'Harbour Hotel booking', + type: 'hotel', + day: d10, + reservation_time: `${START}T15:00`, + accommodation_id: legacyBoundIntegerText(harbour.id), + }); + await makeDayAccommodation(orm, trip.id, lodge.id, d12, d14, { check_in: '16:00' }); + + return { user, trip }; +} + +/** + * Everything on the trip as it reads on a calendar: the date of the day each row + * hangs on and its own times, keyed by a name, never by a day id. + */ +async function calendar(tripId: number): Promise> { + const days = await readTripDays(orm, tripId); + const dateOf = new Map(days.map((d) => [d.id, d.date ?? null])); + const on = (dayId: number | null | undefined) => (dayId == null ? null : (dateOf.get(dayId) ?? 'gone')); + const out: Record = {}; + + const dayIds = days.map((d) => d.id); + for (const a of await findRows(orm, DayAssignments, { day: { $in: dayIds } })) { + const kind = a.accommodation_id ? 'stay stop' : 'place'; + out[`${kind} ${a.place_id}`] = [on(a.day_id), a.assignment_time ?? null, a.assignment_end_time ?? null]; + } + for (const n of await findRows(orm, DayNotes, { trip: tripId })) { + out[`note ${n.text}`] = [on(n.day_id), n.time ?? null]; + } + const bookings = await findRows(orm, Reservations, { trip: tripId }); + const titleOf = new Map(bookings.map((r) => [r.id, r.title])); + for (const r of bookings) { + out[`booking ${r.title}`] = [ + on(r.day_id), + on(r.end_day_id), + r.reservation_time ?? null, + r.reservation_end_time ?? null, + ]; + } + const bookingIds = [...titleOf.keys()]; + for (const ep of await findRows(orm, ReservationEndpoints, { reservation: { $in: bookingIds } })) { + out[`leg ${titleOf.get(ep.reservation_id)} ${ep.role}`] = [ep.local_date ?? null, ep.local_time ?? null]; + } + for (const pos of await findRows(orm, ReservationDayPositions, { reservation: { $in: bookingIds } })) { + out[`position ${titleOf.get(pos.reservation_id)}`] = [on(pos.day_id), pos.position]; + } + for (const s of await findRows(orm, DayAccommodations, { trip: tripId })) { + out[`stay ${s.place_id}`] = [on(s.start_day_id), on(s.end_day_id), s.check_in ?? null]; + } + return out; +} + +async function saveDates(userId: number, tripId: number, body: Record) { + const res = await request(app).put(`/api/trips/${tripId}`).set('Cookie', authCookie(userId)).send(body); + expect(res.status).toBe(200); +} + +async function dayDates(tripId: number) { + return (await readTripDays(orm, tripId)).map((d) => d.date); +} + +/** The same calendar, with every date it names moved by `delta` days. */ +function shifted(before: Record, delta: number): Record { + const move = (value: unknown): unknown => { + if (Array.isArray(value)) return value.map(move); + if (typeof value !== 'string') return value; + const m = /^(\d{4}-\d{2}-\d{2})(.*)$/.exec(value); + if (!m) return value; + const d = new Date(`${m[1]}T00:00:00Z`); + d.setUTCDate(d.getUTCDate() + delta); + return `${d.toISOString().slice(0, 10)}${m[2]}`; + }; + return Object.fromEntries(Object.entries(before).map(([k, v]) => [k, move(v)])); +} + +describe('a longer range keeps everything on its date (#3119)', () => { + it('TRIP-RANGE-001: a day added before the start, bookings kept on their dates, moves nothing', async () => { + const { user, trip } = await plannedTrip(); + const before = await calendar(trip.id); + + await saveDates(user.id, trip.id, { start_date: '2026-05-09', end_date: END, date_shift_mode: 'keep_bookings' }); + + expect(await dayDates(trip.id)).toEqual(['2026-05-09', START, '2026-05-11', '2026-05-12', '2026-05-13', END]); + expect(await calendar(trip.id)).toEqual(before); + }); + + it('TRIP-RANGE-002: the same without a mode, as the phone and MCP save it', async () => { + const { user, trip } = await plannedTrip(); + const before = await calendar(trip.id); + + await saveDates(user.id, trip.id, { start_date: '2026-05-07', end_date: END }); + + expect((await dayDates(trip.id)).slice(0, 4)).toEqual(['2026-05-07', '2026-05-08', '2026-05-09', START]); + expect(await calendar(trip.id)).toEqual(before); + }); + + it('TRIP-RANGE-003: days added after the end, or at both ends, move nothing either', async () => { + const { user, trip } = await plannedTrip(); + const before = await calendar(trip.id); + + await saveDates(user.id, trip.id, { start_date: START, end_date: '2026-05-16' }); + expect(await calendar(trip.id)).toEqual(before); + + await saveDates(user.id, trip.id, { + start_date: '2026-05-08', + end_date: '2026-05-17', + date_shift_mode: 'keep_bookings', + }); + expect((await dayDates(trip.id)).length).toBe(10); + expect(await calendar(trip.id)).toEqual(before); + }); + + it('TRIP-RANGE-004: "shift everything" still moves the whole plan with the new start', async () => { + const { user, trip } = await plannedTrip(); + const before = await calendar(trip.id); + + await saveDates(user.id, trip.id, { start_date: '2026-05-09', end_date: END, date_shift_mode: 'shift_all' }); + + // Every day, booking, stay and leg sits one day earlier; the new last day is empty. + expect(await calendar(trip.id)).toEqual(shifted(before, -1)); + }); +}); + +describe('a moved or shorter range follows the positional rule the dialog warns about', () => { + it('TRIP-RANGE-005: moving the trip a day later keeps the plans on their days and the bookings on their dates', async () => { + const { user, trip } = await plannedTrip(); + const before = await calendar(trip.id); + + await saveDates(user.id, trip.id, { start_date: '2026-05-11', end_date: '2026-05-15' }); + + const after = await calendar(trip.id); + // The plans move with the days... + expect(after['note Pick up the car']).toEqual(shifted(before, 1)['note Pick up the car']); + expect(after['note Return the car']).toEqual(shifted(before, 1)['note Return the car']); + // ...the timed bookings still in the range stay on their dates and times. + expect(after['booking Farewell dinner']).toEqual(before['booking Farewell dinner']); + expect(after['booking Night train']).toEqual(before['booking Night train']); + }); + + it('TRIP-RANGE-006: an earlier end removes only the last day and leaves the rest where it was', async () => { + const { user, trip } = await plannedTrip(); + const before = await calendar(trip.id); + + await saveDates(user.id, trip.id, { start_date: START, end_date: '2026-05-13' }); + + const after = await calendar(trip.id); + expect(after['note Return the car']).toBeUndefined(); + expect(after['note Pick up the car']).toEqual(before['note Pick up the car']); + expect(after['booking Night train']).toEqual(before['booking Night train']); + expect(after['booking Flight out']).toEqual(before['booking Flight out']); + expect(after['leg Flight out from']).toEqual(before['leg Flight out from']); + }); + + it('TRIP-RANGE-007: a later start takes the last day, as the dialog says, and keeps the bookings on their dates', async () => { + const { user, trip } = await plannedTrip(); + const before = await calendar(trip.id); + + await saveDates(user.id, trip.id, { start_date: '2026-05-11', end_date: END }); + + const after = await calendar(trip.id); + expect(await dayDates(trip.id)).toEqual(['2026-05-11', '2026-05-12', '2026-05-13', END]); + expect(after['note Return the car']).toBeUndefined(); + expect(after['note Pick up the car']).toEqual(shifted(before, 1)['note Pick up the car']); + expect(after['booking Night train']).toEqual(before['booking Night train']); + }); +}); + +describe('what hangs on day numbers or dates outside the day rows follows the plan (#3119)', () => { + /** A boundary on the days of 12 and 14 May, each after a stop of its own there. */ + async function roadTrip(tripId: number) { + const days = await readTripDays(orm, tripId); + const stop = await makePlace(orm, tripId, { name: 'Viewpoint' }); + const boundaryOn = async (date: string): Promise<[string, number]> => { + const day = days.find((d) => d.date === date); + if (!day) throw new Error(`no day on ${date}`); + const a = await makeDayAssignment(orm, day.id, stop.id); + await insertRow(orm, RoadtripDayBoundaries, { + trip: tripId, + day_number: day.day_number, + fromAssignment: a.id, + fraction: 0.5, + }); + return [date, a.id]; + }; + return Object.fromEntries(await Promise.all(['2026-05-12', END].map(boundaryOn))); + } + + /** Each boundary by the date of the day its number points at, with the stop it starts from. */ + async function boundaryDates(tripId: number) { + const days = await readTripDays(orm, tripId); + const rows = await findRows(orm, RoadtripDayBoundaries, { trip: tripId }, { day_number: 'asc' }); + return rows.map((b) => [days.find((d) => d.day_number === b.day_number)?.date ?? null, b.from_assignment_id]); + } + + it('TRIP-RANGE-008: road trip day boundaries stay on their days when a day is added before the start', async () => { + const { user, trip } = await plannedTrip(); + const stops = await roadTrip(trip.id); + const expected = [ + ['2026-05-12', stops['2026-05-12']], + [END, stops[END]], + ]; + + await saveDates(user.id, trip.id, { start_date: '2026-05-09', end_date: END, date_shift_mode: 'keep_bookings' }); + expect(await boundaryDates(trip.id)).toEqual(expected); + + // Both ends at once, then shifting everything: the boundaries go with their days either way. + await saveDates(user.id, trip.id, { start_date: '2026-05-07', end_date: '2026-05-16' }); + expect(await boundaryDates(trip.id)).toEqual(expected); + await saveDates(user.id, trip.id, { + start_date: '2026-05-06', + end_date: '2026-05-16', + date_shift_mode: 'shift_all', + }); + expect(await boundaryDates(trip.id)).toEqual([ + ['2026-05-11', stops['2026-05-12']], + ['2026-05-13', stops[END]], + ]); + }); + + it("TRIP-RANGE-009: the owner's leave days stay when days are only added, and still move with a moved trip", async () => { + const { user, trip } = await plannedTrip(); + const plan = await makeVacayPlan(orm, user.id); + await Promise.all( + ['2026-05-11', '2026-05-12', '2026-05-13', END].map((date) => makeVacayEntry(orm, plan.id, user.id, date)), + ); + const leave = async () => + (await findRows(orm, VacayEntries, { plan: plan.id, user: user.id }, { date: 'asc' })).map((e) => e.date); + + await saveDates(user.id, trip.id, { start_date: '2026-05-09', end_date: END, date_shift_mode: 'keep_bookings' }); + expect(await leave()).toEqual(['2026-05-11', '2026-05-12', '2026-05-13', END]); + + await saveDates(user.id, trip.id, { start_date: '2026-05-09', end_date: '2026-05-16' }); + expect(await leave()).toEqual(['2026-05-11', '2026-05-12', '2026-05-13', END]); + + // Shifting everything a day later moves the plan, and the leave with it. + await saveDates(user.id, trip.id, { + start_date: '2026-05-10', + end_date: '2026-05-16', + date_shift_mode: 'shift_all', + }); + expect(await leave()).toEqual(['2026-05-12', '2026-05-13', END, '2026-05-15']); + }); +}); diff --git a/server/tests/unit/db/repositories/RoadtripDayBoundaries.repository.test.ts b/server/tests/unit/db/repositories/RoadtripDayBoundaries.repository.test.ts index c8c67eaa3..50bcb6c04 100644 --- a/server/tests/unit/db/repositories/RoadtripDayBoundaries.repository.test.ts +++ b/server/tests/unit/db/repositories/RoadtripDayBoundaries.repository.test.ts @@ -125,6 +125,26 @@ describe('RoadtripDayBoundariesRepository', () => { expect((await repo.listForTrip(trip.id)).map((b) => b.day_number)).toEqual([2]); }); + it('RB4REPO-002: deleteForDays removes exactly the named day_numbers, and nothing for an empty list', async () => { + const { trip, from, to } = fixture(); + await Promise.all( + [1, 2, 3].map((day_number) => + repo.upsertBoundary(trip.id, { + day_number, + from_assignment_id: from.id, + to_assignment_id: to.id, + fraction: 0.4, + }), + ), + ); + + await repo.deleteForDays(trip.id, []); + expect(await repo.listForTrip(trip.id)).toHaveLength(3); + + await repo.deleteForDays(trip.id, [1, 3, 99]); + expect((await repo.listForTrip(trip.id)).map((b) => b.day_number)).toEqual([2]); + }); + it('RB7REPO-001: moveDayNumber rewrites only the named day_number of the named trip, silent on a miss', async () => { const { trip, from, to } = fixture(); const { trip: other, from: otherFrom, to: otherTo } = fixture(); diff --git a/server/tests/unit/mcp/tools-trips.test.ts b/server/tests/unit/mcp/tools-trips.test.ts index 0be1e0a01..4b3178e0d 100644 --- a/server/tests/unit/mcp/tools-trips.test.ts +++ b/server/tests/unit/mcp/tools-trips.test.ts @@ -8,6 +8,7 @@ * trips:write markers + the canReadTrips/canDeleteTrips predicates). */ import { Days } from '../../../src/db/entities/Days.entity'; +import { RoadtripDayBoundaries } from '../../../src/db/entities/RoadtripDayBoundaries.entity'; import { Trips } from '../../../src/db/entities/Trips.entity'; import { VacayEntries } from '../../../src/db/entities/VacayEntries.entity'; import { VacayUserYears } from '../../../src/db/entities/VacayUserYears.entity'; @@ -306,6 +307,36 @@ describe('Tool: update_trip', () => { }); }); + it('a day added before the start moves the road trip day boundaries with their days and announces them (#3119)', async () => { + const { user } = await makeUser(orm); + const trip = await makeTrip(orm, user.id, { start_date: '2026-05-10', end_date: '2026-05-12' }); + const day2 = await findRow(orm, Days, { trip: trip.id, day_number: 2 }); + if (!day2) throw new Error('the trip has no second day'); + const place = await makePlace(orm, trip.id, { name: 'Viewpoint' }); + const stop = await makeDayAssignment(orm, day2.id, place.id); + await insertRow(orm, RoadtripDayBoundaries, { + trip: trip.id, + day_number: 2, + fromAssignment: stop.id, + fraction: 0.5, + }); + await withHarness(user.id, async (h) => { + await h.client.callTool({ + name: 'update_trip', + arguments: { tripId: trip.id, start_date: '2026-05-09', end_date: '2026-05-12' }, + }); + }); + const boundaries = await findRows(orm, RoadtripDayBoundaries, { trip: trip.id }); + expect(boundaries.map((b) => b.day_number)).toEqual([3]); + expect(broadcastMock).toHaveBeenCalledWith( + trip.id, + 'roadtripBoundary:changed', + expect.objectContaining({ + boundaries: [expect.objectContaining({ day_number: 3, from_assignment_id: stop.id })], + }), + ); + }); + it('returns access denied for non-member', async () => { const { user } = await makeUser(orm); const { user: other } = await makeUser(orm); diff --git a/server/tests/unit/trips/trips.rpc.test.ts b/server/tests/unit/trips/trips.rpc.test.ts index 293f906fb..d0b0ebbe3 100644 --- a/server/tests/unit/trips/trips.rpc.test.ts +++ b/server/tests/unit/trips/trips.rpc.test.ts @@ -46,12 +46,22 @@ const req = (method: string, params: Record = {}): RpcRequest = const ALL_TRIP_GRANTS = ['db:read:trips', 'db:write:trips', 'db:create:trips', 'db:write:members']; /** Trip 1 belongs to user 42. `allow` decides each individual permission check. */ -export function build(opts: { allow?: (action: string) => boolean; updateThrows?: Error; createThrows?: Error } = {}) { +export function build( + opts: { + allow?: (action: string) => boolean; + updateThrows?: Error; + createThrows?: Error; + updateBoundaries?: unknown[]; + } = {}, +) { const trips = { list: vi.fn(() => [{ id: 1, title: 'Japan' }]), updateTrip: vi.fn(() => { if (opts.updateThrows) throw opts.updateThrows; - return { updatedTrip: { id: 1, title: 'Japan' } }; + return { + updatedTrip: { id: 1, title: 'Japan' }, + ...(opts.updateBoundaries ? { boundaries: opts.updateBoundaries } : {}), + }; }), create: vi.fn((userId: number) => { if (opts.createThrows) throw opts.createThrows; @@ -296,6 +306,14 @@ describe('TripsRpc writes', () => { expect(f.trips.updateTrip).toHaveBeenCalledWith(1, 42, { costs_mode: 'totals' }, 'user'); }); + it('TRIPS-RPC-024 road trip day boundaries that moved with their days go out with the trip (#3119)', async () => { + const boundaries = [{ day_number: 4, from_assignment_id: 8, to_assignment_id: null, fraction: 0.5 }]; + const f = build({ updateBoundaries: boundaries }); + const input = { start_date: '2026-05-09', end_date: '2026-05-14' }; + expect((await f.host().dispatch(req('trips.update', { tripId: 1, input }), 42)).ok).toBe(true); + expect(f.realtime.broadcast).toHaveBeenCalledWith(1, 'roadtripBoundary:changed', { boundaries }); + }); + it('TRIPS-RPC-009 service errors map onto the right RPC codes', async () => { const invalid = build({ updateThrows: new ValidationError('bad dates') }); expect( diff --git a/shared/src/i18n/ar/dashboard.ts b/shared/src/i18n/ar/dashboard.ts index 6a6b3f891..770da1044 100644 --- a/shared/src/i18n/ar/dashboard.ts +++ b/shared/src/i18n/ar/dashboard.ts @@ -139,7 +139,7 @@ const dashboard: TranslationStrings = { 'dashboard.dateShiftIntro': 'لقد غيّرت موعد بداية هذه الرحلة. كيف تريد أن تتبع خططك التواريخ الجديدة؟', 'dashboard.dateShiftKeepBookings': 'إبقاء الحجوزات في تواريخها', 'dashboard.dateShiftKeepBookingsDesc': - 'تنتقل خطط الأيام مع التواريخ الجديدة، بينما تبقى الحجوزات وأماكن الإقامة في تواريخها الأصلية ما دامت تلك التواريخ لا تزال ضمن الرحلة.', + 'تبقى الأيام المضافة فارغة ولا يتحرك أي شيء آخر. وإذا انتقلت الرحلة، تنتقل خطط الأيام مع التواريخ الجديدة، بينما تبقى الحجوزات وأماكن الإقامة في تواريخها الأصلية ما دامت تلك التواريخ لا تزال ضمن الرحلة.', 'dashboard.dateShiftAll': 'نقل كل شيء', 'dashboard.dateShiftAllDesc': 'ينتقل خط سير الرحلة بالكامل مع التواريخ الجديدة، بما في ذلك الحجوزات وأماكن الإقامة.', 'dashboard.dateShiftHint': diff --git a/shared/src/i18n/az/dashboard.ts b/shared/src/i18n/az/dashboard.ts index b2717a9cd..47c8aae6b 100644 --- a/shared/src/i18n/az/dashboard.ts +++ b/shared/src/i18n/az/dashboard.ts @@ -123,7 +123,7 @@ const dashboard: TranslationStrings = { 'Səyahətin başlama tarixini dəyişdiniz. Planlarınız yeni tarixlərə necə uyğunlaşdırılsın?', 'dashboard.dateShiftKeepBookings': 'Rezervasiyaların tarixlərini saxla', 'dashboard.dateShiftKeepBookingsDesc': - 'Günlük planlar yeni tarixlərə köçürülür, rezervasiya və yaşayış yerləri isə tarixləri hələ də səyahət müddətinə daxil olduğu halda ilkin tarixlərində qalır.', + 'Əlavə etdiyiniz günlər boş qalır və başqa heç nə yerini dəyişmir. Səyahət köçürülərsə, günlük planlar yeni tarixlərə köçürülür, rezervasiya və yaşayış yerləri isə tarixləri hələ də səyahət müddətinə daxil olduğu halda ilkin tarixlərində qalır.', 'dashboard.dateShiftAll': 'Hər şeyi yeni tarixlərə köçür', 'dashboard.dateShiftAllDesc': 'Rezervasiya və yaşayış yerləri də daxil olmaqla bütün səyahət planı yeni tarixlərə köçürülür.', diff --git a/shared/src/i18n/br/dashboard.ts b/shared/src/i18n/br/dashboard.ts index 3dedccb2e..c7de9b975 100644 --- a/shared/src/i18n/br/dashboard.ts +++ b/shared/src/i18n/br/dashboard.ts @@ -107,7 +107,7 @@ const dashboard: TranslationStrings = { 'dashboard.dateShiftIntro': 'Você alterou o início desta viagem. Como seus planos devem acompanhar as novas datas?', 'dashboard.dateShiftKeepBookings': 'Manter reservas em suas datas', 'dashboard.dateShiftKeepBookingsDesc': - 'Os planos diários acompanham as novas datas, enquanto reservas e hospedagens permanecem nas datas originais, desde que ainda façam parte da viagem.', + 'Os dias adicionados ficam vazios e nada mais muda de lugar. Se a viagem mudar de data, os planos diários acompanham as novas datas, enquanto reservas e hospedagens permanecem nas datas originais, desde que ainda façam parte da viagem.', 'dashboard.dateShiftAll': 'Mover tudo', 'dashboard.dateShiftAllDesc': 'Todo o itinerário acompanha as novas datas, incluindo reservas e hospedagens.', 'dashboard.dateShiftHint': diff --git a/shared/src/i18n/ca/dashboard.ts b/shared/src/i18n/ca/dashboard.ts index b146baf34..8236b2d02 100644 --- a/shared/src/i18n/ca/dashboard.ts +++ b/shared/src/i18n/ca/dashboard.ts @@ -195,7 +195,7 @@ const dashboard: TranslationStrings = { 'Has canviat quan comença aquest viatge. Com han de seguir els teus plans les noves dates?', 'dashboard.dateShiftKeepBookings': 'Mantén les reserves a les seves dates', 'dashboard.dateShiftKeepBookingsDesc': - 'Els plans de cada dia es mouen amb les noves dates, mentre que les reserves i els allotjaments es mantenen a les seves dates originals sempre que aquestes segueixin formant part del viatge.', + 'Els dies que afegeixis queden buits i res més es mou. Si el viatge es desplaça, els plans de cada dia es mouen amb les noves dates, mentre que les reserves i els allotjaments es mantenen a les seves dates originals sempre que aquestes segueixin formant part del viatge.', 'dashboard.dateShiftAll': 'Mou-ho tot', 'dashboard.dateShiftAllDesc': "Tot l'itinerari es mou amb les noves dates, incloses les reserves i els allotjaments.", 'dashboard.dateShiftHint': diff --git a/shared/src/i18n/cs/dashboard.ts b/shared/src/i18n/cs/dashboard.ts index a08e84c6f..acbe20e9c 100644 --- a/shared/src/i18n/cs/dashboard.ts +++ b/shared/src/i18n/cs/dashboard.ts @@ -115,7 +115,7 @@ const dashboard: TranslationStrings = { 'dashboard.dateShiftIntro': 'Změnili jste začátek této cesty. Jak se mají vaše plány přizpůsobit novým termínům?', 'dashboard.dateShiftKeepBookings': 'Ponechat rezervace v původních termínech', 'dashboard.dateShiftKeepBookingsDesc': - 'Denní plány se posunou podle nových termínů, zatímco rezervace a ubytování zůstanou v původních termínech, pokud jsou stále součástí cesty.', + 'Přidané dny zůstanou prázdné a nic dalšího se neposune. Pokud se cesta posune, denní plány se posunou podle nových termínů, zatímco rezervace a ubytování zůstanou v původních termínech, pokud jsou stále součástí cesty.', 'dashboard.dateShiftAll': 'Posunout vše', 'dashboard.dateShiftAllDesc': 'Celý itinerář se posune podle nových termínů, včetně rezervací a ubytování.', 'dashboard.dateShiftHint': diff --git a/shared/src/i18n/de/dashboard.ts b/shared/src/i18n/de/dashboard.ts index 6400b417c..882f7fbcf 100644 --- a/shared/src/i18n/de/dashboard.ts +++ b/shared/src/i18n/de/dashboard.ts @@ -109,7 +109,7 @@ const dashboard: TranslationStrings = { 'Du hast den Beginn dieser Reise geändert. Wie sollen deine Pläne den neuen Daten folgen?', 'dashboard.dateShiftKeepBookings': 'Buchungen auf ihren Terminen belassen', 'dashboard.dateShiftKeepBookingsDesc': - 'Tagespläne wandern mit den neuen Daten, während Reservierungen und Unterkünfte auf ihren ursprünglichen Terminen bleiben, solange diese noch Teil der Reise sind.', + 'Hinzugefügte Tage bleiben leer, sonst verschiebt sich nichts. Wird die Reise verschoben, wandern Tagespläne mit den neuen Daten, während Reservierungen und Unterkünfte auf ihren ursprünglichen Terminen bleiben, solange diese noch Teil der Reise sind.', 'dashboard.dateShiftAll': 'Alles verschieben', 'dashboard.dateShiftAllDesc': 'Der gesamte Reiseplan wandert mit den neuen Daten, einschließlich Reservierungen und Unterkünften.', diff --git a/shared/src/i18n/en/dashboard.ts b/shared/src/i18n/en/dashboard.ts index 1f99c1bcc..971c09c38 100644 --- a/shared/src/i18n/en/dashboard.ts +++ b/shared/src/i18n/en/dashboard.ts @@ -121,7 +121,7 @@ const dashboard: TranslationStrings = { 'dashboard.dateShiftIntro': 'You changed when this trip starts. How should your plans follow the new dates?', 'dashboard.dateShiftKeepBookings': 'Keep bookings on their dates', 'dashboard.dateShiftKeepBookingsDesc': - 'Day plans move with the new dates, while reservations and accommodations stay on their original dates as long as those are still part of the trip.', + 'Days you add stay empty and nothing else moves. If the trip moves, day plans move with the new dates, while reservations and accommodations stay on their original dates as long as those are still part of the trip.', 'dashboard.dateShiftAll': 'Shift everything', 'dashboard.dateShiftAllDesc': 'The entire itinerary moves with the new dates, including reservations and accommodations.', diff --git a/shared/src/i18n/es/dashboard.ts b/shared/src/i18n/es/dashboard.ts index 48b0845f7..2085761d2 100644 --- a/shared/src/i18n/es/dashboard.ts +++ b/shared/src/i18n/es/dashboard.ts @@ -108,7 +108,7 @@ const dashboard: TranslationStrings = { 'Has cambiado cuándo empieza este viaje. ¿Cómo deben seguir tus planes las nuevas fechas?', 'dashboard.dateShiftKeepBookings': 'Mantener las reservas en sus fechas', 'dashboard.dateShiftKeepBookingsDesc': - 'Los planes de cada día se mueven con las nuevas fechas, mientras que las reservas y los alojamientos permanecen en sus fechas originales siempre que sigan formando parte del viaje.', + 'Los días que añadas quedan vacíos y nada más se mueve. Si el viaje se desplaza, los planes de cada día se mueven con las nuevas fechas, mientras que las reservas y los alojamientos permanecen en sus fechas originales siempre que sigan formando parte del viaje.', 'dashboard.dateShiftAll': 'Mover todo', 'dashboard.dateShiftAllDesc': 'Todo el itinerario se mueve con las nuevas fechas, incluidas las reservas y los alojamientos.', diff --git a/shared/src/i18n/et/dashboard.ts b/shared/src/i18n/et/dashboard.ts index 224781b9e..0b0a93912 100644 --- a/shared/src/i18n/et/dashboard.ts +++ b/shared/src/i18n/et/dashboard.ts @@ -121,7 +121,7 @@ const dashboard: TranslationStrings = { 'dashboard.dateShiftIntro': 'Muutsid reisi algust. Kuidas peaksid plaanid uute kuupäevadega kohanema?', 'dashboard.dateShiftKeepBookings': 'Jäta broneeringud oma kuupäevadele', 'dashboard.dateShiftKeepBookingsDesc': - 'Päevaplaanid liiguvad uutele kuupäevadele, kuid broneeringud ja majutused jäävad algsetele kuupäevadele, kui need jäävad endiselt reisi sisse.', + 'Lisatud päevad jäävad tühjaks ja midagi muud ei liigu. Kui reis nihkub, liiguvad päevaplaanid uutele kuupäevadele, kuid broneeringud ja majutused jäävad algsetele kuupäevadele, kui need jäävad endiselt reisi sisse.', 'dashboard.dateShiftAll': 'Nihuta kõike', 'dashboard.dateShiftAllDesc': 'Kogu reisiplaan, sealhulgas broneeringud ja majutused, liigub uutele kuupäevadele.', 'dashboard.dateShiftHint': 'Vihje: ainult osa reisiplaani nihutamiseks kasuta planeerijas valikut „Lisa päev“.', diff --git a/shared/src/i18n/fr/dashboard.ts b/shared/src/i18n/fr/dashboard.ts index 527e085cd..b9a2e640d 100644 --- a/shared/src/i18n/fr/dashboard.ts +++ b/shared/src/i18n/fr/dashboard.ts @@ -110,7 +110,7 @@ const dashboard: TranslationStrings = { 'Vous avez modifié la date de début de ce voyage. Comment vos plans doivent-ils suivre les nouvelles dates ?', 'dashboard.dateShiftKeepBookings': 'Conserver les réservations à leurs dates', 'dashboard.dateShiftKeepBookingsDesc': - "Les plans journaliers suivent les nouvelles dates, tandis que les réservations et hébergements restent à leurs dates d'origine tant que celles-ci font toujours partie du voyage.", + "Les jours ajoutés restent vides et rien d'autre ne bouge. Si le voyage est décalé, les plans journaliers suivent les nouvelles dates, tandis que les réservations et hébergements restent à leurs dates d'origine tant que celles-ci font toujours partie du voyage.", 'dashboard.dateShiftAll': 'Tout décaler', 'dashboard.dateShiftAllDesc': "L'itinéraire entier suit les nouvelles dates, y compris les réservations et hébergements.", diff --git a/shared/src/i18n/gr/dashboard.ts b/shared/src/i18n/gr/dashboard.ts index 20601fc2d..dca31c376 100644 --- a/shared/src/i18n/gr/dashboard.ts +++ b/shared/src/i18n/gr/dashboard.ts @@ -120,7 +120,7 @@ const dashboard: TranslationStrings = { 'Αλλάξατε την ημερομηνία έναρξης αυτού του ταξιδιού. Πώς θέλετε να ακολουθήσουν τα σχέδιά σας τις νέες ημερομηνίες;', 'dashboard.dateShiftKeepBookings': 'Διατήρηση κρατήσεων στις ημερομηνίες τους', 'dashboard.dateShiftKeepBookingsDesc': - 'Τα σχέδια ημέρας μετακινούνται με τις νέες ημερομηνίες, ενώ οι κρατήσεις και τα καταλύματα παραμένουν στις αρχικές τους ημερομηνίες, εφόσον αυτές εξακολουθούν να ανήκουν στο ταξίδι.', + 'Οι ημέρες που προσθέτετε μένουν κενές και τίποτα άλλο δεν μετακινείται. Αν το ταξίδι μετακινηθεί, τα σχέδια ημέρας μετακινούνται με τις νέες ημερομηνίες, ενώ οι κρατήσεις και τα καταλύματα παραμένουν στις αρχικές τους ημερομηνίες, εφόσον αυτές εξακολουθούν να ανήκουν στο ταξίδι.', 'dashboard.dateShiftAll': 'Μετατόπιση όλων', 'dashboard.dateShiftAllDesc': 'Ολόκληρο το δρομολόγιο μετακινείται με τις νέες ημερομηνίες, συμπεριλαμβανομένων των κρατήσεων και των καταλυμάτων.', diff --git a/shared/src/i18n/he/dashboard.ts b/shared/src/i18n/he/dashboard.ts index c0acfa3e2..d5b6d57ac 100644 --- a/shared/src/i18n/he/dashboard.ts +++ b/shared/src/i18n/he/dashboard.ts @@ -129,7 +129,7 @@ const dashboard: TranslationStrings = { 'dashboard.dateShiftIntro': 'שיניתם את מועד תחילת הטיול. איך התוכניות שלכם צריכות לעבור לתאריכים החדשים?', 'dashboard.dateShiftKeepBookings': 'השארת ההזמנות בתאריכים שלהן', 'dashboard.dateShiftKeepBookingsDesc': - 'התוכניות היומיות עוברות לתאריכים החדשים, וההזמנות והלינות נשארות בתאריכים המקוריים כל עוד הם עדיין חלק מהטיול.', + 'ימים שנוספו נשארים ריקים ושום דבר אחר לא זז. אם הטיול זז, התוכניות היומיות עוברות לתאריכים החדשים, וההזמנות והלינות נשארות בתאריכים המקוריים כל עוד הם עדיין חלק מהטיול.', 'dashboard.dateShiftAll': 'הזזת הכל', 'dashboard.dateShiftAllDesc': 'כל המסלול עובר לתאריכים החדשים, כולל הזמנות ולינות.', 'dashboard.dateShiftHint': diff --git a/shared/src/i18n/hu/dashboard.ts b/shared/src/i18n/hu/dashboard.ts index c841992bd..a52c7a5e3 100644 --- a/shared/src/i18n/hu/dashboard.ts +++ b/shared/src/i18n/hu/dashboard.ts @@ -109,7 +109,7 @@ const dashboard: TranslationStrings = { 'dashboard.dateShiftIntro': 'Megváltoztattad az út kezdetét. Hogyan kövessék a terveid az új dátumokat?', 'dashboard.dateShiftKeepBookings': 'A foglalások maradjanak a saját dátumaikon', 'dashboard.dateShiftKeepBookingsDesc': - 'A napi tervek az új dátumokkal együtt mozognak, míg a foglalások és szállások az eredeti dátumaikon maradnak, amíg azok még az út részei.', + 'A hozzáadott napok üresek maradnak, és semmi más nem mozdul. Ha az út eltolódik, a napi tervek az új dátumokkal együtt mozognak, míg a foglalások és szállások az eredeti dátumaikon maradnak, amíg azok még az út részei.', 'dashboard.dateShiftAll': 'Minden eltolása', 'dashboard.dateShiftAllDesc': 'A teljes útiterv az új dátumokkal együtt mozog, beleértve a foglalásokat és a szállásokat is.', diff --git a/shared/src/i18n/id/dashboard.ts b/shared/src/i18n/id/dashboard.ts index 701ecb418..9fd3d980e 100644 --- a/shared/src/i18n/id/dashboard.ts +++ b/shared/src/i18n/id/dashboard.ts @@ -100,7 +100,7 @@ const dashboard: TranslationStrings = { 'Kamu mengubah tanggal mulai perjalanan ini. Bagaimana rencanamu harus mengikuti tanggal baru?', 'dashboard.dateShiftKeepBookings': 'Pertahankan pesanan pada tanggalnya', 'dashboard.dateShiftKeepBookingsDesc': - 'Rencana harian ikut berpindah ke tanggal baru, sementara reservasi dan akomodasi tetap pada tanggal aslinya selama tanggal tersebut masih termasuk dalam perjalanan.', + 'Hari yang ditambahkan tetap kosong dan tidak ada hal lain yang berpindah. Jika perjalanan bergeser, rencana harian ikut berpindah ke tanggal baru, sementara reservasi dan akomodasi tetap pada tanggal aslinya selama tanggal tersebut masih termasuk dalam perjalanan.', 'dashboard.dateShiftAll': 'Geser semuanya', 'dashboard.dateShiftAllDesc': 'Seluruh rencana perjalanan berpindah ke tanggal baru, termasuk reservasi dan akomodasi.', diff --git a/shared/src/i18n/it/dashboard.ts b/shared/src/i18n/it/dashboard.ts index dc1bbc51a..18bca05d6 100644 --- a/shared/src/i18n/it/dashboard.ts +++ b/shared/src/i18n/it/dashboard.ts @@ -110,7 +110,7 @@ const dashboard: TranslationStrings = { 'Hai modificato la data di inizio di questo viaggio. Come devono adattarsi i tuoi piani alle nuove date?', 'dashboard.dateShiftKeepBookings': 'Mantieni le prenotazioni alle loro date', 'dashboard.dateShiftKeepBookingsDesc': - 'I programmi giornalieri si spostano con le nuove date, mentre prenotazioni e alloggi restano alle date originali, purché queste facciano ancora parte del viaggio.', + "I giorni aggiunti restano vuoti e nient'altro si sposta. Se il viaggio si sposta, i programmi giornalieri si spostano con le nuove date, mentre prenotazioni e alloggi restano alle date originali, purché queste facciano ancora parte del viaggio.", 'dashboard.dateShiftAll': 'Sposta tutto', 'dashboard.dateShiftAllDesc': "L'intero itinerario si sposta con le nuove date, incluse prenotazioni e alloggi.", 'dashboard.dateShiftHint': diff --git a/shared/src/i18n/ja/dashboard.ts b/shared/src/i18n/ja/dashboard.ts index 9d4c0c9cf..d9a1e2a7a 100644 --- a/shared/src/i18n/ja/dashboard.ts +++ b/shared/src/i18n/ja/dashboard.ts @@ -114,7 +114,7 @@ const dashboard: TranslationStrings = { 'dashboard.dateShiftIntro': '旅行の開始日が変更されました。予定を新しい日程にどのように合わせますか?', 'dashboard.dateShiftKeepBookings': '予約を元の日付のままにする', 'dashboard.dateShiftKeepBookingsDesc': - '日別計画は新しい日程に合わせて移動しますが、予約と宿泊先は旅行期間内にある限り元の日付のままになります。', + '追加した日は空のままで、ほかは何も動きません。旅行の日程がずれる場合、日別計画は新しい日程に合わせて移動しますが、予約と宿泊先は旅行期間内にある限り元の日付のままになります。', 'dashboard.dateShiftAll': 'すべてを移動する', 'dashboard.dateShiftAllDesc': '予約や宿泊先を含む旅程全体が新しい日程に合わせて移動します。', 'dashboard.dateShiftHint': diff --git a/shared/src/i18n/ko/dashboard.ts b/shared/src/i18n/ko/dashboard.ts index d38f5d399..0fdcccdec 100644 --- a/shared/src/i18n/ko/dashboard.ts +++ b/shared/src/i18n/ko/dashboard.ts @@ -114,7 +114,7 @@ const dashboard: TranslationStrings = { 'dashboard.dateShiftIntro': '여행 시작일이 변경되었습니다. 계획을 새 날짜에 어떻게 맞출까요?', 'dashboard.dateShiftKeepBookings': '예약은 원래 날짜에 유지', 'dashboard.dateShiftKeepBookingsDesc': - '일별 계획은 새 날짜로 이동하고, 예약과 숙박은 여행 기간에 포함되어 있는 한 원래 날짜에 그대로 유지됩니다.', + '추가한 날은 비어 있고 다른 것은 움직이지 않습니다. 여행 일정이 옮겨지면 일별 계획은 새 날짜로 이동하고, 예약과 숙박은 여행 기간에 포함되어 있는 한 원래 날짜에 그대로 유지됩니다.', 'dashboard.dateShiftAll': '모두 이동', 'dashboard.dateShiftAllDesc': '예약과 숙박을 포함한 전체 일정이 새 날짜로 이동합니다.', 'dashboard.dateShiftHint': diff --git a/shared/src/i18n/nl/dashboard.ts b/shared/src/i18n/nl/dashboard.ts index 95f03c9a5..82e168811 100644 --- a/shared/src/i18n/nl/dashboard.ts +++ b/shared/src/i18n/nl/dashboard.ts @@ -108,7 +108,7 @@ const dashboard: TranslationStrings = { 'Je hebt gewijzigd wanneer deze reis begint. Hoe moeten je plannen de nieuwe datums volgen?', 'dashboard.dateShiftKeepBookings': 'Boekingen op hun datums houden', 'dashboard.dateShiftKeepBookingsDesc': - 'Dagplannen verschuiven mee met de nieuwe datums, terwijl reserveringen en accommodaties op hun oorspronkelijke datums blijven zolang die nog binnen de reis vallen.', + 'Toegevoegde dagen blijven leeg en verder verschuift er niets. Als de reis verschuift, verschuiven dagplannen mee met de nieuwe datums, terwijl reserveringen en accommodaties op hun oorspronkelijke datums blijven zolang die nog binnen de reis vallen.', 'dashboard.dateShiftAll': 'Alles verschuiven', 'dashboard.dateShiftAllDesc': 'De volledige reisplanning verschuift mee met de nieuwe datums, inclusief reserveringen en accommodaties.', diff --git a/shared/src/i18n/pl/dashboard.ts b/shared/src/i18n/pl/dashboard.ts index c049d68d5..ca3c609cf 100644 --- a/shared/src/i18n/pl/dashboard.ts +++ b/shared/src/i18n/pl/dashboard.ts @@ -116,7 +116,7 @@ const dashboard: TranslationStrings = { 'Data rozpoczęcia podróży została zmieniona. Jak plany mają dostosować się do nowych dat?', 'dashboard.dateShiftKeepBookings': 'Zachowaj rezerwacje w ich terminach', 'dashboard.dateShiftKeepBookingsDesc': - 'Plany dnia przesuną się wraz z nowymi datami, a rezerwacje i noclegi pozostaną w swoich pierwotnych terminach, o ile nadal mieszczą się one w ramach podróży.', + 'Dodane dni pozostaną puste i nic więcej się nie przesunie. Jeśli podróż się przesunie, plany dnia przesuną się wraz z nowymi datami, a rezerwacje i noclegi pozostaną w swoich pierwotnych terminach, o ile nadal mieszczą się one w ramach podróży.', 'dashboard.dateShiftAll': 'Przesuń wszystko', 'dashboard.dateShiftAllDesc': 'Cały plan podróży przesunie się wraz z nowymi datami, w tym rezerwacje i noclegi.', 'dashboard.dateShiftHint': diff --git a/shared/src/i18n/ru/dashboard.ts b/shared/src/i18n/ru/dashboard.ts index c8ae67d27..d0a6c779b 100644 --- a/shared/src/i18n/ru/dashboard.ts +++ b/shared/src/i18n/ru/dashboard.ts @@ -123,7 +123,7 @@ const dashboard: TranslationStrings = { 'dashboard.dateShiftIntro': 'Вы изменили дату начала поездки. Как перенести ваши планы на новые даты?', 'dashboard.dateShiftKeepBookings': 'Оставить бронирования на своих датах', 'dashboard.dateShiftKeepBookingsDesc': - 'Планы дней переносятся на новые даты, а бронирования и жильё остаются на исходных датах, пока те входят в поездку.', + 'Добавленные дни остаются пустыми, всё остальное остаётся на месте. Если поездка сдвигается, планы дней переносятся на новые даты, а бронирования и жильё остаются на исходных датах, пока те входят в поездку.', 'dashboard.dateShiftAll': 'Перенести всё', 'dashboard.dateShiftAllDesc': 'Весь маршрут переносится на новые даты, включая бронирования и жильё.', 'dashboard.dateShiftHint': diff --git a/shared/src/i18n/sk/dashboard.ts b/shared/src/i18n/sk/dashboard.ts index 18c472326..941ba235e 100644 --- a/shared/src/i18n/sk/dashboard.ts +++ b/shared/src/i18n/sk/dashboard.ts @@ -129,7 +129,7 @@ const dashboard: TranslationStrings = { 'dashboard.dateShiftIntro': 'Zmenili ste začiatok tejto cesty. Ako sa majú vaše plány prispôsobiť novým termínom?', 'dashboard.dateShiftKeepBookings': 'Ponechať rezervácie v pôvodných termínoch', 'dashboard.dateShiftKeepBookingsDesc': - 'Denné plány sa posunú podľa nových termínov, zatiaľ čo rezervácie a ubytovania zostanú v pôvodných termínoch, pokiaľ sú stále súčasťou cesty.', + 'Pridané dni zostanú prázdne a nič iné sa neposunie. Ak sa cesta posunie, denné plány sa posunú podľa nových termínov, zatiaľ čo rezervácie a ubytovania zostanú v pôvodných termínoch, pokiaľ sú stále súčasťou cesty.', 'dashboard.dateShiftAll': 'Posunúť všetko', 'dashboard.dateShiftAllDesc': 'Celý itinerár sa posunie podľa nových termínov vrátane rezervácií a ubytovaní.', 'dashboard.dateShiftHint': diff --git a/shared/src/i18n/sv/dashboard.ts b/shared/src/i18n/sv/dashboard.ts index 34ce4bcbc..23549d764 100644 --- a/shared/src/i18n/sv/dashboard.ts +++ b/shared/src/i18n/sv/dashboard.ts @@ -121,7 +121,7 @@ const dashboard: TranslationStrings = { 'dashboard.dateShiftIntro': 'Du har ändrat när resan börjar. Hur ska dina planer följa de nya datumen?', 'dashboard.dateShiftKeepBookings': 'Behåll bokningar på sina datum', 'dashboard.dateShiftKeepBookingsDesc': - 'Dagsplanerna flyttas med de nya datumen, medan bokningar och boenden ligger kvar på sina ursprungliga datum så länge dessa fortfarande ingår i resan.', + 'Tillagda dagar förblir tomma och inget annat flyttas. Om resan flyttas, flyttas dagsplanerna med de nya datumen, medan bokningar och boenden ligger kvar på sina ursprungliga datum så länge dessa fortfarande ingår i resan.', 'dashboard.dateShiftAll': 'Flytta allt', 'dashboard.dateShiftAllDesc': 'Hela resplanen flyttas med de nya datumen, inklusive bokningar och boenden.', 'dashboard.dateShiftHint': diff --git a/shared/src/i18n/th/dashboard.ts b/shared/src/i18n/th/dashboard.ts index e4f750468..c3214a0b2 100644 --- a/shared/src/i18n/th/dashboard.ts +++ b/shared/src/i18n/th/dashboard.ts @@ -113,7 +113,7 @@ const dashboard: TranslationStrings = { 'dashboard.dateShiftIntro': 'คุณเปลี่ยนวันที่เริ่มต้นของการเดินทางครั้งนี้ แผนของคุณควรปรับตามวันที่ใหม่อย่างไร', 'dashboard.dateShiftKeepBookings': 'ทำการจองตามวันที่ของพวกเขา', 'dashboard.dateShiftKeepBookingsDesc': - 'แผนรายวันจะเปลี่ยนไปตามวันที่ใหม่ ในขณะที่การจองและที่พักจะยังคงเป็นวันที่เดิม ตราบใดที่ยังเป็นส่วนหนึ่งของการเดินทาง', + 'วันที่เพิ่มเข้ามาจะว่างอยู่และไม่มีสิ่งอื่นเลื่อน หากทริปถูกเลื่อน แผนรายวันจะเปลี่ยนไปตามวันที่ใหม่ ในขณะที่การจองและที่พักจะยังคงเป็นวันที่เดิม ตราบใดที่ยังเป็นส่วนหนึ่งของการเดินทาง', 'dashboard.dateShiftAll': 'เลื่อนทุกอย่างตามวันใหม่', 'dashboard.dateShiftAllDesc': 'แผนการเดินทางทั้งหมดจะย้ายไปพร้อมกับวันที่ใหม่ รวมถึงการจองและที่พัก', 'dashboard.dateShiftHint': 'เคล็ดลับ: หากต้องการเปลี่ยนแผนการเดินทางเพียงบางส่วน ให้ใช้ "เพิ่มวัน" ในเครื่องมือวางแผนแทน', diff --git a/shared/src/i18n/tr/dashboard.ts b/shared/src/i18n/tr/dashboard.ts index f297f4775..16b77cd8b 100644 --- a/shared/src/i18n/tr/dashboard.ts +++ b/shared/src/i18n/tr/dashboard.ts @@ -122,7 +122,7 @@ const dashboard: TranslationStrings = { 'Bu seyahatin başlangıç tarihini değiştirdiniz. Planlarınız yeni tarihlere nasıl uyum sağlasın?', 'dashboard.dateShiftKeepBookings': 'Rezervasyonları kendi tarihlerinde tut', 'dashboard.dateShiftKeepBookingsDesc': - 'Gün planları yeni tarihlerle birlikte taşınır; rezervasyonlar ve konaklamalar ise seyahatin kapsamında kaldıkları sürece orijinal tarihlerinde kalır.', + 'Eklenen günler boş kalır ve başka hiçbir şey yer değiştirmez. Seyahat kaydırılırsa gün planları yeni tarihlerle birlikte taşınır; rezervasyonlar ve konaklamalar ise seyahatin kapsamında kaldıkları sürece orijinal tarihlerinde kalır.', 'dashboard.dateShiftAll': 'Her şeyi kaydır', 'dashboard.dateShiftAllDesc': 'Rezervasyonlar ve konaklamalar dahil tüm plan yeni tarihlerle birlikte taşınır.', 'dashboard.dateShiftHint': diff --git a/shared/src/i18n/uk/dashboard.ts b/shared/src/i18n/uk/dashboard.ts index 9e6448023..c8494dd7c 100644 --- a/shared/src/i18n/uk/dashboard.ts +++ b/shared/src/i18n/uk/dashboard.ts @@ -139,7 +139,7 @@ const dashboard: TranslationStrings = { 'dashboard.dateShiftIntro': 'Ви змінили дату початку поїздки. Як ваші плани мають перейти на нові дати?', 'dashboard.dateShiftKeepBookings': 'Залишити бронювання на своїх датах', 'dashboard.dateShiftKeepBookingsDesc': - 'Плани днів переміщуються разом із новими датами, а бронювання та проживання залишаються на своїх початкових датах, поки ті все ще входять до поїздки.', + 'Додані дні залишаються порожніми, усе інше лишається на місці. Якщо поїздка зсувається, плани днів переміщуються разом із новими датами, а бронювання та проживання залишаються на своїх початкових датах, поки ті все ще входять до поїздки.', 'dashboard.dateShiftAll': 'Перемістити все', 'dashboard.dateShiftAllDesc': 'Весь маршрут переміщується на нові дати, включно з бронюваннями та проживанням.', 'dashboard.dateShiftHint': diff --git a/shared/src/i18n/vi/dashboard.ts b/shared/src/i18n/vi/dashboard.ts index 25cc0854c..31d9ede4b 100644 --- a/shared/src/i18n/vi/dashboard.ts +++ b/shared/src/i18n/vi/dashboard.ts @@ -106,7 +106,7 @@ const dashboard: TranslationStrings = { 'Bạn đã thay đổi thời điểm bắt đầu chuyến đi. Các kế hoạch của bạn nên theo ngày mới như thế nào?', 'dashboard.dateShiftKeepBookings': 'Giữ đặt chỗ theo ngày ban đầu', 'dashboard.dateShiftKeepBookingsDesc': - 'Kế hoạch theo ngày sẽ dời theo ngày mới, trong khi đặt chỗ và chỗ ở vẫn giữ nguyên ngày ban đầu miễn là những ngày đó vẫn nằm trong chuyến đi.', + 'Các ngày được thêm vẫn trống và không có gì khác bị dời. Nếu chuyến đi bị dời, kế hoạch theo ngày sẽ dời theo ngày mới, trong khi đặt chỗ và chỗ ở vẫn giữ nguyên ngày ban đầu miễn là những ngày đó vẫn nằm trong chuyến đi.', 'dashboard.dateShiftAll': 'Dời tất cả', 'dashboard.dateShiftAllDesc': 'Toàn bộ lịch trình sẽ dời theo ngày mới, bao gồm cả đặt chỗ và chỗ ở.', 'dashboard.dateShiftHint': diff --git a/shared/src/i18n/zh-TW/dashboard.ts b/shared/src/i18n/zh-TW/dashboard.ts index 5a6193c74..fd256e60b 100644 --- a/shared/src/i18n/zh-TW/dashboard.ts +++ b/shared/src/i18n/zh-TW/dashboard.ts @@ -99,7 +99,7 @@ const dashboard: TranslationStrings = { 'dashboard.dateShiftIntro': '你變更了旅行的開始時間。你的計劃要如何配合新日期?', 'dashboard.dateShiftKeepBookings': '預訂保留在原日期', 'dashboard.dateShiftKeepBookingsDesc': - '每日計劃會隨新日期移動,而預訂和住宿只要仍在旅行期間內,就會保留在原本的日期。', + '新增的日期會保持空白,其他內容都不會移動。如果旅行日期整體移動,每日計劃會隨新日期移動,而預訂和住宿只要仍在旅行期間內,就會保留在原本的日期。', 'dashboard.dateShiftAll': '全部移動', 'dashboard.dateShiftAllDesc': '整個行程都會隨新日期移動,包括預訂和住宿。', 'dashboard.dateShiftHint': diff --git a/shared/src/i18n/zh/dashboard.ts b/shared/src/i18n/zh/dashboard.ts index b87311ecc..354185909 100644 --- a/shared/src/i18n/zh/dashboard.ts +++ b/shared/src/i18n/zh/dashboard.ts @@ -99,7 +99,7 @@ const dashboard: TranslationStrings = { 'dashboard.dateShiftIntro': '您更改了旅行的开始时间。您的计划应如何适应新的日期?', 'dashboard.dateShiftKeepBookings': '保留预订的原定日期', 'dashboard.dateShiftKeepBookingsDesc': - '日程计划将随新日期移动,而预订和住宿只要仍在旅行日期范围内,就保留其原定日期。', + '新增的日期保持为空,其他内容都不会移动。如果旅行日期整体移动,日程计划将随新日期移动,而预订和住宿只要仍在旅行日期范围内,就保留其原定日期。', 'dashboard.dateShiftAll': '全部顺移', 'dashboard.dateShiftAllDesc': '整个行程将随新日期移动,包括预订和住宿。', 'dashboard.dateShiftHint': diff --git a/shared/src/trip/day-grid.spec.ts b/shared/src/trip/day-grid.spec.ts index a0df2cc32..5451f7899 100644 --- a/shared/src/trip/day-grid.spec.ts +++ b/shared/src/trip/day-grid.spec.ts @@ -200,6 +200,42 @@ describe('planDayGrid', () => { expect(gone(p)).toEqual(['10:overflow', '11:spare']); }); + describe('keeping dates (#3119)', () => { + const keep = (startDate: string, endDate: string, stays: DayGridStay[] = []) => + planDayGrid({ days: tenDays, stays, startDate, endDate, keepDates: true }); + + it('a day before the start is a new first day, every other day keeps its date', () => { + const p = keep('2026-09-30', '2026-10-10'); + expect(p.rows[0]).toEqual({ id: null, date: '2026-09-30' }); + expect(p.rows.slice(1, 11)).toEqual(tenDays.slice(0, 10).map((d) => ({ id: d.id, date: d.date }))); + expect(ids(p).slice(-1)).toEqual([12]); + expect(gone(p)).toEqual(['11:spare']); + }); + + it('days at both ends keep the middle where it was and add the days after the spare ones', () => { + const p = keep('2026-09-28', '2026-10-12'); + expect(ids(p)).toEqual([null, null, null, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]); + expect(p.rows[3]).toEqual({ id: 1, date: '2026-10-01' }); + expect(p.rows[12]).toEqual({ id: 10, date: '2026-10-10' }); + expect(p.removed).toEqual([]); + }); + + it('a later end is laid out as without it', () => { + expect(keep('2026-10-01', '2026-10-14')).toEqual(plan('2026-10-01', '2026-10-14')); + }); + + it('a moved or shorter range does not hold every day, so the days follow their position', () => { + for (const [start, end] of [ + ['2026-10-03', '2026-10-10'], + ['2026-10-01', '2026-10-08'], + ['2026-10-05', '2026-10-14'], + ['2026-09-29', '2026-10-09'], + ] as const) { + expect(keep(start, end)).toEqual(plan(start, end)); + } + }); + }); + describe('without dates', () => { const undated = (n: number, planned: number[] = [], stays: DayGridStay[] = [], dayCount?: number) => planDayGrid({ diff --git a/shared/src/trip/day-grid.ts b/shared/src/trip/day-grid.ts index 048418d24..24a9ebccb 100644 --- a/shared/src/trip/day-grid.ts +++ b/shared/src/trip/day-grid.ts @@ -175,6 +175,19 @@ const removal = (day: DayGridDay, reason: DayGridRemovalReason): DayGridRemoval const isEmptyDay = (day: DayGridDay, stays: readonly DayGridStay[]): boolean => !day.hasPlanItems && !stays.some((s) => s.start_day_id === day.id || s.end_day_id === day.id); +/** + * How many new days go before the first dated day so that every dated day keeps + * its date: the days between the new start and the first day's date. Zero when + * the first day lies before the new start or the dated days would not all fit + * into the range from there, which is when the plans have to move. + */ +function newDaysBefore(dated: readonly DayGridDay[], startDate: string, span: number): number { + const first = dated[0]?.date; + if (!first || first < startDate) return 0; + const lead = tripSpanDays(startDate, first) - 1; + return lead + dated.length <= span ? lead : 0; +} + /** * The day rows a trip gets for a range, the rule the server writes by * (TripsService.generateDays carries this plan out) and the trip dialog warns @@ -188,6 +201,13 @@ const isEmptyDay = (day: DayGridDay, stays: readonly DayGridStay[]): boolean => * not. A stay on a dropped dated day goes with that day, so it no longer keeps a * spare day it touched. * + * With `keepDates` (bookings keep their dates, the trip dialog's default) a + * range that still holds every dated day leaves each of them on its date, and + * the new days go around them: a day added before the start is a new empty + * first day, not a reason to move every plan a day earlier (#3119). A range + * that does not hold them all (the trip moved or got shorter) falls back to + * the positional rule above. + * * Without dates every day loses its date and the trip is held to `dayCount` * days (its current count when none is given): short of it, empty days are * added at the end; over it, empty days go, the highest numbers first. A day @@ -200,8 +220,9 @@ export function planDayGrid(input: { startDate: string | null | undefined; endDate: string | null | undefined; dayCount?: number; + keepDates?: boolean; }): DayGridPlan { - const { days, stays, startDate, endDate, dayCount } = input; + const { days, stays, startDate, endDate, dayCount, keepDates = false } = input; if (!startDate || !endDate) { const ordered = [...days].sort(byDayNumber); @@ -225,11 +246,15 @@ export function planDayGrid(input: { const undated = days.filter((day) => !day.date).sort(byDayNumber); const span = tripSpanDays(startDate, endDate); + const lead = keepDates ? newDaysBefore(dated, startDate, span) : 0; + const rows: DayGridRow[] = []; let used = 0; for (let i = 0; i < span; i++) { const date = addIsoDays(startDate, i); - if (i < dated.length) rows.push({ id: dated[i]!.id, date }); + const slot = i - lead; + if (slot < 0) rows.push({ id: null, date }); + else if (slot < dated.length) rows.push({ id: dated[slot]!.id, date }); else if (used < undated.length) rows.push({ id: undated[used++]!.id, date }); else rows.push({ id: null, date }); }