fix(mobile): a booking opens its detail sheet first, as a transport and the desktop do; Wallet and Map buttons read short

Bookings in the Bookings tab, the day sheet, a place's sheet and the road trip
opened their editor straight away, while a transport showed its details with
a pencil to edit. Every booking now opens the same detail sheet; its edit and
delete follow the booking's own permission (reservation_edit for a stay, a
table or a ticket, day_edit for a transport). Notes keep opening for editing,
as on the desktop.

The wallet button reads "Wallet" (its accessible name still says which one),
and "On map" reads "Map" in every language.
This commit is contained in:
Maurice
2026-11-09 12:56:50 +01:00
parent ed0142be7d
commit f03bb97d50
68 changed files with 121 additions and 111 deletions
@@ -61,12 +61,14 @@ describe('MWalletButton', () => {
await waitFor(() => expect(onError).toHaveBeenLastCalledWith(expect.stringMatching(/could not be made/i)));
});
it('on Android adds the booking to Google Wallet, under its own name', async () => {
it('on Android adds the booking to Google Wallet, under its own name for screen readers', async () => {
wallet.kind = 'google';
wallet.addGoogle.mockResolvedValue('added');
const onError = vi.fn();
render(<MWalletButton tripId={42} reservationId={7} onError={onError} />);
expect(screen.getByRole('button')).toHaveTextContent(/Google Wallet/);
// The label is short, the accessible name says which wallet.
expect(screen.getByRole('button')).toHaveTextContent(/^Wallet$/);
expect(screen.getByRole('button', { name: /Google Wallet/ })).toBeInTheDocument();
fireEvent.click(screen.getByRole('button'));
await waitFor(() => expect(wallet.addGoogle).toHaveBeenCalledWith(42, 7, expect.any(String)));
expect(wallet.add).not.toHaveBeenCalled();
@@ -57,10 +57,11 @@ export default function MWalletButton({ tripId, reservationId, onError, classNam
onClick={() => void add()}
disabled={busy}
aria-busy={busy}
aria-label={t(wallet === 'google' ? 'reservations.wallet.addGoogle' : 'reservations.wallet.add')}
className="flex items-center gap-[6px] rounded-full bg-black px-3 py-[7px] text-[length:calc(12px*var(--fs-scale-body,1))] font-semibold text-white transition-transform active:scale-[.97] disabled:opacity-70" // theme-lint-disable: the wallets' badges are black in either theme
>
{busy ? <Loader2 size={13} className="animate-spin" /> : <Wallet size={13} strokeWidth={2} />}
{t(wallet === 'google' ? 'reservations.wallet.addGoogle' : 'reservations.wallet.add')}
{t('reservations.wallet.short')}
</button>
);
return className ? <div className={className}>{button}</div> : button;
@@ -180,14 +180,8 @@ function RoadtripStagePage({ planner, shell, dayId: pageDayId, alts, chrome }: O
// A chip that may not be opened is not a button in the first place (`bookingOpens`),
// so nothing is turned away silently here.
const canEditBookings = planner.can('reservation_edit', planner.trip)
const openBooking = (res: Reservation) => {
if (planner.TRANSPORT_TYPES.has(res.type)) {
shell.openSheet('transport', { reservationId: res.id })
return
}
planner.setEditingReservation(res)
planner.setShowReservationModal(true)
}
// Every booking opens its detail sheet, as on the desktop; its pencil edits it there.
const openBooking = (res: Reservation) => shell.openSheet('transport', { reservationId: res.id })
// A booked night at the edge of the stage is no stop, and has no stop sheet: it opens the
// booking behind the night, else the stay for somebody who may edit days, else the
// hotel's place, the way a stay chip in the day timeline does (#2210).
@@ -111,19 +111,11 @@ export default function MDaySheet({ planner, shell }: MTripSheetsProps) {
}
}
// A booking opens its detail sheet, as on the desktop; its pencil edits it there.
const openReservation = (r: Reservation) => {
const isTransport = planner.TRANSPORT_TYPES.has(r.type)
if (isTransport && canEditDays) {
planner.setEditingTransport(r)
planner.setTransportModalDayId(r.day_id ?? null)
planner.setShowTransportModal(true)
} else if (!isTransport && canEditReservations) {
planner.setEditingReservation(r)
planner.setShowReservationModal(true)
} else {
return
}
shell.closeSheet()
if (isTransport ? !canEditDays : !canEditReservations) return
shell.openSheet('transport', { reservationId: r.id })
}
const planTransit = () => {
@@ -112,18 +112,11 @@ export default function MPlaceSheet({ planner, shell }: MTripSheetsProps) {
)
const openRes = (res: Reservation) => {
if (!canOpenRes(res)) return
if (planner.TRANSPORT_TYPES.has(res.type)) {
planner.setEditingTransport(res)
planner.setTransportModalDayId(res.day_id ?? null)
planner.setTransportModalAutomated(false)
planner.setShowTransportModal(true)
} else {
planner.setEditingReservation(res)
planner.setShowReservationModal(true)
}
// This sheet hangs off the place selection, not the sheet stack, so its own
// close() is what dismisses it — otherwise the editor opens on top of it.
// close() is what dismisses it; the booking's detail sheet then opens alone,
// with its pencil for editing, as on the desktop.
close()
shell.openSheet('transport', { reservationId: res.id })
}
const participants = assignmentInDay?.participants || []
@@ -413,7 +406,6 @@ export default function MPlaceSheet({ planner, shell }: MTripSheetsProps) {
type="button"
onClick={() => openRes(res)}
disabled={!canOpenRes(res)}
aria-label={canOpenRes(res) ? t('inspector.editRes') : undefined}
className={`flex w-full items-center gap-2 rounded-[14px] px-3 py-[10px] text-start ${INNER_CLS}`}
>
<span
@@ -103,6 +103,7 @@ export default function MTransportSheet({ planner, shell }: MTripSheetsProps) {
})
const canEditDays = planner.can('day_edit', planner.trip)
const canEditBookings = planner.can('reservation_edit', planner.trip)
const timeFormat = useSettingsStore(s => s.settings.time_format) || '24h'
const blurCodes = useSettingsStore(s => s.settings.blur_booking_codes)
const [codeRevealed, setCodeRevealed] = useState(false)
@@ -118,6 +119,9 @@ export default function MTransportSheet({ planner, shell }: MTripSheetsProps) {
}
const meta = parseMetadata(res)
// A transport is part of the day plan, a stay, a table or a ticket a booking:
// each is edited under its own permission, as in the tab it belongs to.
const canEdit = isTransportReservationType(res.type) ? canEditDays : canEditBookings
const ResIcon = RES_ICONS[res.type as keyof typeof RES_ICONS] || RES_ICONS.other
const from = (res.endpoints || []).find(e => e.role === 'from')
@@ -362,7 +366,7 @@ export default function MTransportSheet({ planner, shell }: MTripSheetsProps) {
<span dir="auto" className="truncate">{f.original_name}</span>
</button>
))}
{canEditDays && (
{canEdit && (
<button
type="button"
onClick={editTransport}
@@ -372,7 +376,7 @@ export default function MTransportSheet({ planner, shell }: MTripSheetsProps) {
{t('common.edit')}
</button>
)}
{canEditDays && (
{canEdit && (
<button
type="button"
onClick={deleteTransport}
@@ -69,6 +69,7 @@ export default function MBookingsTab({ planner, shell }: MTabScreenProps) {
planner={planner}
canEdit={canEdit}
compact={shell.bookingsCompact}
onView={() => shell.openSheet('transport', { reservationId: res.id })}
/>
))}
</CardGrid>
@@ -79,10 +80,12 @@ export default function MBookingsTab({ planner, shell }: MTabScreenProps) {
)
}
function BookingCard({ res, planner, canEdit, compact }: {
function BookingCard({ res, planner, canEdit, compact, onView }: {
res: Reservation
planner: MTabScreenProps['planner']
canEdit: boolean
/** A tap on the card: the booking's detail sheet, as a transport opens, and as on the desktop. */
onView: () => void
compact: boolean
}) {
const { t, days } = planner
@@ -139,7 +142,7 @@ function BookingCard({ res, planner, canEdit, compact }: {
{/* Header */}
<div className="flex items-center gap-[7px] border-b border-[color:var(--m-rowbr)] px-3 py-[10px]" style={{ background: tint }}>
<StatusDot color={dotColor} />
<CardTitleButton res={res} TypeIcon={TypeIcon} typeColor={typeColor} onOpen={openEdit} t={t} />
<CardTitleButton res={res} TypeIcon={TypeIcon} typeColor={typeColor} onOpen={onView} t={t} />
{canEdit && <CardActions onEdit={openEdit} onDelete={card.askDelete} t={t} />}
</div>
@@ -154,11 +157,11 @@ function BookingCard({ res, planner, canEdit, compact }: {
timeValue={timeValue}
code={res.confirmation_number}
card={card}
onOpen={openEdit}
onOpen={onView}
t={t}
/>
<button type="button" onClick={openEdit} className="block w-full text-start">
<button type="button" onClick={onView} className="block w-full text-start">
{metaCells.length > 0 && (
<div className="mt-2 flex gap-2">
{metaCells.slice(0, 3).map((c, i) => (
@@ -201,13 +201,12 @@ describe('MBookingsTab', () => {
expect(within(card).getAllByText('—')).toHaveLength(2)
})
it('FE-MOB-BKTAB-012: opens the reservation editor from the row', () => {
it('FE-MOB-BKTAB-012: a tap on the card shows the booking first, as a transport and the desktop do', () => {
const p = planner()
renderTab(p)
const { shell } = renderTab(p)
fireEvent.click(screen.getByText('Sushi Saito'))
expect(p.can).toHaveBeenCalledWith('reservation_edit', p.trip)
expect(p.setEditingReservation).toHaveBeenCalledWith(expect.objectContaining({ id: 202 }))
expect(p.setShowReservationModal).toHaveBeenCalledWith(true)
expect(shell.openSheet).toHaveBeenCalledWith('transport', { reservationId: 202 })
expect(p.setShowReservationModal).not.toHaveBeenCalled()
})
it('FE-MOB-BKTAB-013: opens the same editor from the pencil', () => {
@@ -217,10 +216,11 @@ describe('MBookingsTab', () => {
expect(p.setEditingReservation).toHaveBeenCalledWith(expect.objectContaining({ id: 201 }))
})
it('FE-MOB-BKTAB-014: a read-only member gets no editor and no actions', () => {
it('FE-MOB-BKTAB-014: a read-only member may look at a booking but gets no editor and no actions', () => {
const p = planner({ can: vi.fn(() => false) as unknown as TripPlanner['can'] })
renderTab(p)
const { shell } = renderTab(p)
fireEvent.click(screen.getByText('Sushi Saito'))
expect(shell.openSheet).toHaveBeenCalledWith('transport', { reservationId: 202 })
expect(p.setShowReservationModal).not.toHaveBeenCalled()
expect(screen.queryByRole('button', { name: 'common.edit' })).not.toBeInTheDocument()
expect(screen.queryByRole('button', { name: 'common.delete' })).not.toBeInTheDocument()
@@ -315,14 +315,14 @@ describe('MDaySheet', () => {
expect(screen.queryByText('Opera (other day)')).not.toBeInTheDocument()
expect(screen.queryByText('Hotel Sacher booking')).not.toBeInTheDocument()
// Each booking opens its detail sheet first, with the pencil there, as on the desktop.
fireEvent.click(screen.getByText('Train to Salzburg'))
expect(planner.setEditingTransport).toHaveBeenCalledWith(expect.objectContaining({ id: 22 }))
expect(planner.setShowTransportModal).toHaveBeenCalledWith(true)
expect(shell.openSheet).toHaveBeenCalledWith('transport', { reservationId: 22 })
fireEvent.click(screen.getByText('Dinner at Figlmueller'))
expect(planner.setEditingReservation).toHaveBeenCalledWith(expect.objectContaining({ id: 21 }))
expect(planner.setShowReservationModal).toHaveBeenCalledWith(true)
expect(shell.closeSheet).toHaveBeenCalledTimes(2)
expect(shell.openSheet).toHaveBeenCalledWith('transport', { reservationId: 21 })
expect(planner.setShowTransportModal).not.toHaveBeenCalled()
expect(planner.setShowReservationModal).not.toHaveBeenCalled()
})
it('FE-MOB-DAYSH-021: a booking row does nothing without the matching permission', async () => {
@@ -332,7 +332,7 @@ describe('MDaySheet', () => {
fireEvent.click(screen.getByText('Train to Salzburg'))
expect(planner.setShowReservationModal).not.toHaveBeenCalled()
expect(planner.setShowTransportModal).not.toHaveBeenCalled()
expect(shell.closeSheet).not.toHaveBeenCalled()
expect(shell.openSheet).not.toHaveBeenCalled()
})
it('FE-MOB-DAYSH-022: renders notes sorted, splits a leading time off the detail line, and routes taps', async () => {
@@ -494,29 +494,26 @@ describe('MPlaceSheet', () => {
expect(screen.getByText('Ferry to Corfu')).toBeInTheDocument()
})
it('FE-MOB-PLSH-028: a transport booking opens the transport editor, not the reservation modal', () => {
it('FE-MOB-PLSH-028: a transport booking opens its detail sheet, not an editor', () => {
const planner = bookingPlanner({ id: 7, assignment_id: 11, title: 'Ferry to Corfu', status: 'pending', type: 'ferry', day_id: 2 })
renderSheet(planner)
const { shell } = renderSheet(planner)
fireEvent.click(screen.getByRole('button', { name: 'Edit Reservation' }))
fireEvent.click(screen.getByText('Ferry to Corfu').closest('button') as HTMLButtonElement)
expect(planner.setEditingTransport).toHaveBeenCalledWith(expect.objectContaining({ id: 7 }))
expect(planner.setTransportModalDayId).toHaveBeenCalledWith(2)
expect(planner.setShowTransportModal).toHaveBeenCalledWith(true)
expect(planner.setShowReservationModal).not.toHaveBeenCalled()
expect(shell.openSheet).toHaveBeenCalledWith('transport', { reservationId: 7 })
expect(planner.setShowTransportModal).not.toHaveBeenCalled()
// and the place sheet gets out of the way
expect(planner.setSelectedPlaceId).toHaveBeenCalledWith(null)
})
it('FE-MOB-PLSH-029: a non-transport booking opens the reservation modal', () => {
it('FE-MOB-PLSH-029: a non-transport booking opens the same detail sheet first, as on the desktop', () => {
const planner = bookingPlanner({ id: 8, assignment_id: 11, title: 'Museum tour', status: 'confirmed', type: 'activity' })
renderSheet(planner)
const { shell } = renderSheet(planner)
fireEvent.click(screen.getByRole('button', { name: 'Edit Reservation' }))
fireEvent.click(screen.getByText('Museum tour').closest('button') as HTMLButtonElement)
expect(planner.setEditingReservation).toHaveBeenCalledWith(expect.objectContaining({ id: 8 }))
expect(planner.setShowReservationModal).toHaveBeenCalledWith(true)
expect(planner.setShowTransportModal).not.toHaveBeenCalled()
expect(shell.openSheet).toHaveBeenCalledWith('transport', { reservationId: 8 })
expect(planner.setShowReservationModal).not.toHaveBeenCalled()
})
it('FE-MOB-PLSH-030: a viewer without edit rights sees the booking but gets no live button', () => {
@@ -529,7 +526,6 @@ describe('MPlaceSheet', () => {
// Still readable — just not a control that would do nothing when pressed.
expect(screen.getByText('Ferry to Corfu')).toBeInTheDocument()
expect(screen.queryByRole('button', { name: 'Edit Reservation' })).not.toBeInTheDocument()
const row = screen.getByText('Ferry to Corfu').closest('button') as HTMLButtonElement
expect(row.disabled).toBe(true)
})
@@ -899,11 +899,10 @@ describe('MRoadtripTab', () => {
// The chips are the stop's, not stops: the count stays at two.
expect(screen.getByText('roadtrip.day.stopCount:2')).toBeInTheDocument()
// A chip opens its booking in the editor, the way the place sheet opens a linked one.
// A chip opens its booking's detail sheet, the way the place sheet opens a linked one.
fireEvent.click(screen.getByText('Tisch Bullerei'))
expect(p.setEditingReservation).toHaveBeenCalledWith(reservations[0])
expect(p.setShowReservationModal).toHaveBeenCalledWith(true)
expect(shell.openSheet).not.toHaveBeenCalled()
expect(shell.openSheet).toHaveBeenCalledWith('transport', { reservationId: reservations[0].id })
expect(p.setShowReservationModal).not.toHaveBeenCalled()
})
it('FE-MOB-RTTAB-057: a transport chip goes to the transport sheet, and a table is not even a button for a member who may not edit bookings', () => {
@@ -992,9 +991,8 @@ describe('MRoadtripTab', () => {
const editor = planner({ roadtripRoutes: routes({ days: [hotelStage()] }), reservations: [hotelBooking] })
const first = renderTab(editor)
fireEvent.click(screen.getByText('roadtrip.bookend.back'))
expect(editor.setEditingReservation).toHaveBeenCalledWith(hotelBooking)
expect(editor.setShowReservationModal).toHaveBeenCalledWith(true)
expect(first.shell.openSheet).not.toHaveBeenCalled()
expect(first.shell.openSheet).toHaveBeenCalledWith('transport', { reservationId: hotelBooking.id })
expect(editor.setShowReservationModal).not.toHaveBeenCalled()
first.unmount()
const dayEditor = planner({
@@ -181,7 +181,7 @@ describe('MTransportSheet', () => {
const planner = makePlanner()
const shell = makeShell({ trTab: 'transports', view: 'plan' })
render(<MTransportSheet planner={planner} shell={shell} />)
const btn = screen.getByRole('button', { name: 'On map' })
const btn = screen.getByRole('button', { name: 'Map' })
expect(btn).toHaveAttribute('aria-pressed', 'false')
fireEvent.click(btn)
expect(planner.toggleConnection).toHaveBeenCalledWith(7)
@@ -194,7 +194,7 @@ describe('MTransportSheet', () => {
const planner = makePlanner({ visibleConnections: [7] })
const shell = makeShell({ trTab: 'plan', view: 'map' })
render(<MTransportSheet planner={planner} shell={shell} />)
const btn = screen.getByRole('button', { name: 'On map' })
const btn = screen.getByRole('button', { name: 'Map' })
expect(btn).toHaveAttribute('aria-pressed', 'true')
fireEvent.click(btn)
expect(planner.toggleConnection).toHaveBeenCalledWith(7)
@@ -253,7 +253,7 @@ describe('MTransportSheet', () => {
render(<MTransportSheet planner={planner} shell={makeShell()} />)
expect(screen.queryByRole('button', { name: 'Edit' })).not.toBeInTheDocument()
expect(screen.queryByRole('button', { name: 'Delete' })).not.toBeInTheDocument()
expect(screen.getByRole('button', { name: 'On map' })).toBeInTheDocument()
expect(screen.getByRole('button', { name: 'Map' })).toBeInTheDocument()
})
it('FE-MOB-TRSH-021: keeps the last booking on screen while the sheet animates out', () => {
@@ -323,7 +323,7 @@ describe('MTransportSheet', () => {
const shell = makeShell({ trTab: 'transports', view: 'plan' })
render(<MTransportSheet planner={planner} shell={shell} />)
fireEvent.click(screen.getByRole('button', { name: 'On map' }))
fireEvent.click(screen.getByRole('button', { name: 'Map' }))
expect(planner.toggleConnection).toHaveBeenCalledWith(7)
expect(planner.handleSelectDay).toHaveBeenCalledWith(3, false)
@@ -338,7 +338,7 @@ describe('MTransportSheet', () => {
const shell = makeShell({ trTab: 'transports', view: 'map' })
render(<MTransportSheet planner={planner} shell={shell} />)
fireEvent.click(screen.getByRole('button', { name: 'On map' }))
fireEvent.click(screen.getByRole('button', { name: 'Map' }))
expect(shell.toggleView).not.toHaveBeenCalled()
expect(planner.handleSelectDay).toHaveBeenCalledWith(3, false)
@@ -351,7 +351,7 @@ describe('MTransportSheet', () => {
const planner = makePlanner({ days: DAYS, selectedDayId: 4, reservations: [overnight] })
render(<MTransportSheet planner={planner} shell={makeShell({ trTab: 'plan', view: 'plan' })} />)
fireEvent.click(screen.getByRole('button', { name: 'On map' }))
fireEvent.click(screen.getByRole('button', { name: 'Map' }))
expect(planner.toggleConnection).toHaveBeenCalledWith(7)
expect(planner.handleSelectDay).not.toHaveBeenCalled()
@@ -362,13 +362,13 @@ describe('MTransportSheet', () => {
const unbound = { ...FLIGHT, day_id: null, end_day_id: null } as unknown as Reservation
const allDays = makePlanner({ days: DAYS, selectedDayId: null })
const { unmount } = render(<MTransportSheet planner={allDays} shell={makeShell({ trTab: 'transports', view: 'map' })} />)
fireEvent.click(screen.getByRole('button', { name: 'On map' }))
fireEvent.click(screen.getByRole('button', { name: 'Map' }))
expect(allDays.handleSelectDay).not.toHaveBeenCalled()
unmount()
const noDay = makePlanner({ days: DAYS, selectedDayId: 5, reservations: [unbound] })
render(<MTransportSheet planner={noDay} shell={makeShell({ trTab: 'transports', view: 'plan' })} />)
fireEvent.click(screen.getByRole('button', { name: 'On map' }))
fireEvent.click(screen.getByRole('button', { name: 'Map' }))
expect(noDay.toggleConnection).toHaveBeenCalledWith(7)
expect(noDay.handleSelectDay).not.toHaveBeenCalled()
})
@@ -381,7 +381,7 @@ describe('MTransportSheet', () => {
const shell = makeShell({ trTab: 'transports', view: 'plan' })
render(<MTransportSheet planner={planner} shell={shell} />)
const btn = screen.getByRole('button', { name: 'On map' })
const btn = screen.getByRole('button', { name: 'Map' })
expect(btn).toHaveAttribute('aria-pressed', 'false')
fireEvent.click(btn)
@@ -398,7 +398,7 @@ describe('MTransportSheet', () => {
const shell = makeShell({ trTab: 'plan', view: 'map' })
render(<MTransportSheet planner={planner} shell={shell} />)
const btn = screen.getByRole('button', { name: 'On map' })
const btn = screen.getByRole('button', { name: 'Map' })
expect(btn).toHaveAttribute('aria-pressed', 'true')
fireEvent.click(btn)