From 9ea489ac970d147444da0febc2e54c96faf1a664 Mon Sep 17 00:00:00 2001 From: Maurice Date: Fri, 27 Nov 2026 23:05:02 +0100 Subject: [PATCH] feat(mobile): move a stop to another day from its day in the place sheet On the phone a stop could only be removed from a day and added to another, which lost its time and notes. A tap on the day in the place sheet now opens the same short day list as adding, headed 'Move to another day', and moves the stop there through the planner's move, so its time, notes and road trip waypoints come along and a timed stop lands where its time belongs. No new control in the plan's rows. Addresses discussion #2583. --- .../screens/trip/sheets/MPlaceSheet.tsx | 46 +++++++++++++++---- .../unit/mobile/trip/MPlaceSheet.test.tsx | 13 ++++++ shared/src/i18n/ar/mobileTrip.ts | 1 + shared/src/i18n/az/mobileTrip.ts | 1 + shared/src/i18n/br/mobileTrip.ts | 1 + shared/src/i18n/ca/mobileTrip.ts | 1 + shared/src/i18n/cs/mobileTrip.ts | 1 + shared/src/i18n/de/mobileTrip.ts | 1 + shared/src/i18n/en/mobileTrip.ts | 1 + shared/src/i18n/es/mobileTrip.ts | 1 + shared/src/i18n/et/mobileTrip.ts | 1 + shared/src/i18n/fr/mobileTrip.ts | 1 + shared/src/i18n/gr/mobileTrip.ts | 1 + shared/src/i18n/he/mobileTrip.ts | 1 + shared/src/i18n/hu/mobileTrip.ts | 1 + shared/src/i18n/id/mobileTrip.ts | 1 + shared/src/i18n/it/mobileTrip.ts | 1 + shared/src/i18n/ja/mobileTrip.ts | 1 + shared/src/i18n/ko/mobileTrip.ts | 1 + shared/src/i18n/nl/mobileTrip.ts | 1 + shared/src/i18n/pl/mobileTrip.ts | 1 + shared/src/i18n/ru/mobileTrip.ts | 1 + shared/src/i18n/sk/mobileTrip.ts | 1 + shared/src/i18n/sv/mobileTrip.ts | 1 + shared/src/i18n/th/mobileTrip.ts | 1 + shared/src/i18n/tr/mobileTrip.ts | 1 + shared/src/i18n/uk/mobileTrip.ts | 1 + shared/src/i18n/vi/mobileTrip.ts | 1 + shared/src/i18n/zh-TW/mobileTrip.ts | 1 + shared/src/i18n/zh/mobileTrip.ts | 1 + 30 files changed, 78 insertions(+), 9 deletions(-) diff --git a/client/src/mobile/screens/trip/sheets/MPlaceSheet.tsx b/client/src/mobile/screens/trip/sheets/MPlaceSheet.tsx index 91417db58..a7cf1ed2e 100644 --- a/client/src/mobile/screens/trip/sheets/MPlaceSheet.tsx +++ b/client/src/mobile/screens/trip/sheets/MPlaceSheet.tsx @@ -1,7 +1,7 @@ import { useMemo, useRef, useState, type KeyboardEvent } from 'react' import DawarichIcon from '../../../../components/shared/DawarichIcon' import { - Bookmark, ChevronRight, ExternalLink, Map as MapIcon, MapPinOff, Navigation, Paperclip, + ArrowLeftRight, Bookmark, ChevronRight, ExternalLink, Map as MapIcon, MapPinOff, Navigation, Paperclip, Pencil, Phone, Plus, Route, RouteOff, Sparkles, Trash2, Upload, X, } from 'lucide-react' import MSheet from '../../../components/MSheet' @@ -26,7 +26,7 @@ import { filesForPlace } from '../../../../utils/placeFiles' import { navigationTargetLabel, getNavigationTargets, openNavigationTarget } from '../../../../components/Planner/placeNavigation' import { addressWithoutCoordinates } from '../../../../components/Planner/placeCoordinates' import { NavigationMenu } from '../../../../components/shared/NavigationMenu' -import { getPlaceBookings } from '../../../../utils/dayMerge' +import { getPlaceBookings, timedSlot } from '../../../../utils/dayMerge' import type { Assignment, Day, Reservation, TripMember } from '../../../../types' import PlacePhotoGallery from '../../../../components/Planner/PlacePhotoGallery' import { ActionCircle, Eyebrow, INNER_CLS } from './MTripSheetUi' @@ -61,6 +61,8 @@ export default function MPlaceSheet({ planner, shell }: MTripSheetsProps) { uploading, filesExpanded, setFilesExpanded, fileInputRef, handleUpload, } = usePlaceFileUpload(place && !isTourPlace ? place.id : null, fd => planner.tripActions.addFile(planner.tripId, fd), planner.toast) const [dayPickerOpen, setDayPickerOpen] = useState(false) + // A day of this place picked to move from (#2583): the day list then moves it there instead of adding it. + const [moving, setMoving] = useState<{ assignment: Assignment; fromDayId: number } | null>(null) const [participantPickerOpen, setParticipantPickerOpen] = useState(false) const [navOpen, setNavOpen] = useState(false) const navBtnRef = useRef(null) @@ -70,6 +72,7 @@ export default function MPlaceSheet({ planner, shell }: MTripSheetsProps) { planner.setSelectedPlaceId(null) setFilesExpanded(false) setDayPickerOpen(false) + setMoving(null) setParticipantPickerOpen(false) setColorPickerOpen(false) } @@ -92,6 +95,14 @@ export default function MPlaceSheet({ planner, shell }: MTripSheetsProps) { }, [place, planner.days, planner.assignments]) const unassignedDays = planner.days.filter(d => !placeAssignments.some(r => r.day.id === d.id)) + const dayLabel = (d: Day) => d.title || t('planner.dayN', { n: (d.day_number ?? planner.days.indexOf(d) + 1) || '?' }) + // Lands where its time belongs on the new day, as a move on the desktop does; + // without a time it goes to the end. + const moveToDay = ({ assignment, fromDayId }: { assignment: Assignment; fromDayId: number }, toDayId: number) => { + const slot = timedSlot(planner.assignments[String(toDayId)] || [], planner.tripAccommodations, assignment.place?.place_time) ?? undefined + planner.handleMoveToDay(assignment.id, fromDayId, toDayId, slot) + .catch((err: unknown) => planner.toast.error(err instanceof Error ? err.message : t('common.unknownError'))) + } // Participants belong to the assignment in the selected day (desktop parity). const dayAssignments = planner.selectedDayId ? (planner.assignments[String(planner.selectedDayId)] || []) : [] @@ -348,7 +359,20 @@ export default function MPlaceSheet({ planner, shell }: MTripSheetsProps) { key={assignment.id} className={`flex items-center gap-1 rounded-full py-1 ps-[10px] text-[0.75rem] font-semibold ${INNER_CLS} ${canEditDays ? 'pe-1' : 'pe-[10px]'}`} > - {day.title || t('planner.dayN', { n: (day.day_number ?? planner.days.indexOf(day) + 1) || '?' })} + {canEditDays && unassignedDays.length > 0 ? ( + // The day itself moves the stop to another one, keeping its time + // and notes, where removing and adding it again would lose them. + + ) : dayLabel(day)} {canEditDays && !isTourPlace && place.lat != null && place.lng != null && ( // In or out of that day's route (#2532); the icon says which it is. )} - {dayPickerOpen && ( + {(dayPickerOpen || moving) && (
+ {moving && {t('mobileTrip.moveToDay')}} {unassignedDays.map(d => (