From 59b8d0037336eea030ebbdd640c9c8d20dbf1450 Mon Sep 17 00:00:00 2001 From: Maurice Date: Fri, 27 Nov 2026 23:10:00 +0100 Subject: [PATCH] feat(mobile): open journal entries to read them, with a pencil into the editor On the phone everyone who may edit a journey got every entry straight in the editor, so reading the journal meant scrolling a form and risking a stray edit. An existing entry now opens as its read view: its date and time head it, the story, place, the chosen mood and weather follow, and the entry's settings (draft, route) and locked fields stay out of the way. A pencil in the header switches to the editor without closing the sheet. New entries and suggestions open in the editor as before, and a viewer's sheet is unchanged. Addresses discussion #3007. --- .../mobile/screens/journey/MJourneyDetail.tsx | 16 +++- .../screens/journey/MJourneyEntrySheet.tsx | 79 ++++++++++++++----- .../mobile/journey/MJourneyDetail.test.tsx | 18 ++++- .../journey/MJourneyEntrySheet.test.tsx | 40 ++++++++++ 4 files changed, 127 insertions(+), 26 deletions(-) diff --git a/client/src/mobile/screens/journey/MJourneyDetail.tsx b/client/src/mobile/screens/journey/MJourneyDetail.tsx index 0366f5297..cf13ce631 100644 --- a/client/src/mobile/screens/journey/MJourneyDetail.tsx +++ b/client/src/mobile/screens/journey/MJourneyDetail.tsx @@ -138,6 +138,13 @@ export default function MJourneyDetail({ journeyId, embedded = false }: JourneyD [current?.entries, hideSkeletons], ) + // An existing entry opens to be read, also for those who may edit it (#3007); + // the pencil in its sheet switches to the editor. New entries and suggestions + // open in the editor straight away. + const [editEntryId, setEditEntryId] = useState(null) + const readingEntry = !!editingEntry && canEditEntries && editingEntry.id !== 0 + && editingEntry.type !== 'skeleton' && editEntryId !== editingEntry.id + const { mapRef, carouselRef, cardRefs, activeIndex, focusIndex, setActiveIndex, scrubberDays, syncMapToCard, handleMarkerClick, handleCardTap, openEntryById, jumpToDay, @@ -698,7 +705,8 @@ export default function MJourneyDetail({ journeyId, embedded = false }: JourneyD entry={editingEntry} galleryPhotos={gallery} quickCapture={editingEntry.id === 0} - readOnly={!canEditEntries} + readOnly={!canEditEntries || readingEntry} + onEdit={readingEntry ? () => setEditEntryId(editingEntry.id) : undefined} showVerdict={current.show_verdict !== 0} showMood={current.show_mood !== 0} showWeather={current.show_weather !== 0} @@ -706,12 +714,12 @@ export default function MJourneyDetail({ journeyId, embedded = false }: JourneyD trips={current.trips} photoProviders={availableProviders} onMoveEarlier={ - canEditEntries && editingEntry.id !== 0 && editingEntry.type !== 'skeleton' && dayNeighbours(editingEntry).canMoveUp + canEditEntries && !readingEntry && editingEntry.id !== 0 && editingEntry.type !== 'skeleton' && dayNeighbours(editingEntry).canMoveUp ? () => { void moveWithinDay(editingEntry, -1) } : undefined } onMoveLater={ - canEditEntries && editingEntry.id !== 0 && editingEntry.type !== 'skeleton' && dayNeighbours(editingEntry).canMoveDown + canEditEntries && !readingEntry && editingEntry.id !== 0 && editingEntry.type !== 'skeleton' && dayNeighbours(editingEntry).canMoveDown ? () => { void moveWithinDay(editingEntry, 1) } : undefined } @@ -720,7 +728,7 @@ export default function MJourneyDetail({ journeyId, embedded = false }: JourneyD ? () => { setEditingEntry(null); void dismissSuggestion(editingEntry) } : undefined } - onClose={() => setEditingEntry(null)} + onClose={() => { setEditingEntry(null); setEditEntryId(null) }} onSave={async (data, existingEntryId) => { // existingEntryId is what the sheet already persisted in an earlier // save attempt — without it a retry would create a second entry. diff --git a/client/src/mobile/screens/journey/MJourneyEntrySheet.tsx b/client/src/mobile/screens/journey/MJourneyEntrySheet.tsx index d9e753a0c..b3d6e9ddf 100644 --- a/client/src/mobile/screens/journey/MJourneyEntrySheet.tsx +++ b/client/src/mobile/screens/journey/MJourneyEntrySheet.tsx @@ -1,5 +1,7 @@ import { useRef, useState, type CSSProperties } from 'react' -import { Briefcase, Camera, Plus, Image, Images, X, MapPin, Locate, Trash2, CheckCircle2, MinusCircle, ChevronUp, ChevronDown, EyeOff, Play, NotebookPen } from 'lucide-react' +import { Briefcase, Camera, Plus, Image, Images, X, MapPin, Locate, Trash2, CheckCircle2, MinusCircle, ChevronUp, ChevronDown, EyeOff, Play, NotebookPen, Pencil } from 'lucide-react' +import { useSettingsStore } from '../../../store/settingsStore' +import { formatClockTime } from '../../../utils/formatters' import MSheet from '../../components/MSheet' import MIconBtn from '../../components/MIconBtn' import MToggle from '../../components/MToggle' @@ -48,6 +50,11 @@ interface MJourneyEntrySheetProps { galleryPhotos: GalleryPhoto[] quickCapture?: boolean readOnly?: boolean + /** + * Given to an editor reading an entry (#3007): the sheet opens as the read view + * and a pencil in its header switches to the editor, without closing it. + */ + onEdit?: () => void userId?: number trips?: JourneyTrip[] /** @@ -87,10 +94,10 @@ interface MJourneyEntrySheetProps { */ export default function MJourneyEntrySheet({ entry, galleryPhotos, quickCapture = false, readOnly = false, userId = 0, trips = [], photoProviders: providers = NO_PROVIDERS, - showVerdict = true, showMood = true, showWeather = true, onMoveEarlier, onMoveLater, onDismiss, + showVerdict = true, showMood = true, showWeather = true, onEdit, onMoveEarlier, onMoveLater, onDismiss, onClose, onSave, onUploadPhotos, onAddProviderPhotos, onDelete, onDone, }: MJourneyEntrySheetProps) { - const { t } = useTranslation() + const { t, language } = useTranslation() const { title, setTitle, story, setStory, entryDate, setEntryDate, entryTime, setEntryTime, locationName, locationLat, locationQuery, locationResults, showLocationResults, setShowLocationResults, @@ -121,6 +128,20 @@ export default function MJourneyEntrySheet({ onClose() } + // An editor reading the entry: the read view, with the way into the editor. + const reading = readOnly && !!onEdit + const is12h = useSettingsStore(s => s.settings.time_format === '12h') + // Read, the date and time head the entry instead of standing in locked fields. + const readingWhen = reading && entryDate + ? [ + new Date(`${entryDate}T00:00:00Z`).toLocaleDateString(language, { weekday: 'short', day: 'numeric', month: 'long', timeZone: 'UTC' }), + entryTime ? formatClockTime(entryTime, is12h) : '', + ].filter(Boolean).join(', ') + : '' + const heading = entry.id === 0 + ? t('journey.detail.newEntry') + : readingWhen || t('journey.detail.editEntry') + const eyebrow = 'font-geist text-[0.625rem] font-bold uppercase tracking-[.09em] text-m-faint' const fieldShell = 'rounded-xl border border-[color:var(--m-rowbr)] bg-[color:var(--m-ic)]' @@ -130,7 +151,7 @@ export default function MJourneyEntrySheet({ onClose={handleClose} variant="card" form - ariaLabel={entry.id === 0 ? t('journey.detail.newEntry') : t('journey.detail.editEntry')} + ariaLabel={heading} > {/* FormSheetHeader's shape, with the move buttons between the title and the close. */}
@@ -138,8 +159,13 @@ export default function MJourneyEntrySheet({ - {entry.id === 0 ? t('journey.detail.newEntry') : t('journey.detail.editEntry')} + {heading} + {reading && ( + + + + )} {(onMoveEarlier || onMoveLater) && ( onMoveEarlier?.()} disabled={!onMoveEarlier} ariaLabel={t('dayplan.moveUp')}> @@ -514,7 +540,7 @@ export default function MJourneyEntrySheet({ {/* Date + Time. Split in the date's favour: a localized date needs the room ("10. Sept. 2026"), a clock never does. */} -
+ {!reading &&
{t('journey.editor.date')}
{/* TREK's own picker, like the time field beside it: a native @@ -529,9 +555,9 @@ export default function MJourneyEntrySheet({ brings its own shell, so fieldShell goes with the input. */}
-
+
} - {tripSuggestion.trip && ( + {!reading && tripSuggestion.trip && (
@@ -545,7 +571,13 @@ export default function MJourneyEntrySheet({
)} - {/* Location */} + {/* Location: read, a line under the story rather than a locked field. */} + {reading ? (locationName && ( +
+ + {locationName} +
+ )) : (
{t('journey.editor.location')}
@@ -594,11 +626,13 @@ export default function MJourneyEntrySheet({ {locating &&
{t('common.loading')}
} {locationError &&
{locationError}
}
+ )} {/* Off the route: the same switch the desktop editor and the Studio travel panel offer (#2064). Read-only keeps it visible but locked, like the date and the mood above and below it. */} - {offersStatsToggle && ( + {/* Settings of the entry, not its content: an editor reading it does not need them locked in view. */} + {offersStatsToggle && !reading && (
{t('journey.editor.statsExcluded')}
@@ -609,19 +643,22 @@ export default function MJourneyEntrySheet({ )} {/* Kept among the contributors until it is ready (#696). */} -
-
-
{t('journey.editor.draft')}
-
{t('journey.editor.draftHint')}
+ {!reading && ( +
+
+
{t('journey.editor.draft')}
+
{t('journey.editor.draftHint')}
+
+
- -
+ )} {/* Mood */} - {showMood && !captureOnly && <> + {/* Read, only what was chosen shows, and nothing when nothing was. */} + {showMood && !captureOnly && (!reading || MOBILE_MOODS.some(m => m.id === mood)) && <>
{t('journey.editor.mood')}
- {MOBILE_MOODS.map(m => { + {(reading ? MOBILE_MOODS.filter(m => m.id === mood) : MOBILE_MOODS).map(m => { const active = mood === m.id return ( {!readOnly && (