feat(places): colour tags, tabs for the texts and opening hours on the phone

Tags on the place form are pills in their own colour, with a palette under
the dot that recolours a tag for the whole trip (PUT /trips/:id/tags/:id was
there already, the client now reaches it through repo and store) and a
custom colour field of its own instead of the system picker. A new tag is
made in a colour picked the same way.

Description, notes and the note for one day's visit sit in one card under a
switch, each with a line on where the text shows up; the day tab is named
after its day and is only there with one visit in context. Nothing about the
three fields changes underneath.

Opening hours get a switch for open around the clock next to closed. Google
writes a place open all week as one period on Sunday that never closes; it
read as Sunday open and every other day closed, and now opens every day.

The phone form follows the desktop: category as one field with a list, tags
in one field, the texts switch, and phone, e-mail and opening hours, which it
did not have. The hours and the text tabs are shared hooks (usePlaceHours,
usePlaceTextTabs). Files and costs on the phone sheets are drawn as fields
like the rest, and the paste hint, a keyboard shortcut a phone has no use
for, is gone with its key.
This commit is contained in:
Maurice
2026-11-17 08:44:05 +01:00
parent 33d074c786
commit a3f6635633
100 changed files with 2538 additions and 510 deletions
@@ -1,6 +1,5 @@
import { useState, useEffect, useRef, useMemo, useCallback, useId, type ReactNode } from 'react'
import type { PlaceClientOrigin, RoadtripStopType, TourListItem } from '@trek/shared'
import NoteFormatToolbar from '../shared/NoteFormatToolbar'
import { useAuthStore } from '../../store/authStore'
import { useAddonStore } from '../../store/addonStore'
import { useCanDo } from '../../store/permissionsStore'
@@ -25,6 +24,7 @@ import {
import { useNewCategory, usePlaceForm } from './usePlaceForm'
import { usePlaceTags } from './usePlaceTags'
import { PlaceFormTags } from './PlaceFormTags'
import { PlaceFormTexts } from './PlaceFormTexts'
import { usePlaceSearch } from './usePlaceSearch'
import { guessCategoryId } from '@trek/shared'
import { offersGoogleRetry } from '../../utils/placeSource'
@@ -39,9 +39,9 @@ import { DEFAULT_SERVICE_KIND, serviceStopChoice, type ServiceStopMode } from '.
import { STOP_KIND_BY_KEY } from '../Roadtrip/stopKinds'
import { getCategoryIcon } from '../shared/categoryIcons'
import {
DialogShell, DialogHeader, DialogTile, DialogSection, DialogFooter, FooterSpacer, DialogButton, NEUTRAL_TINT, fs,
DialogShell, DialogHeader, DialogTile, DialogFooter, FooterSpacer, DialogButton, NEUTRAL_TINT, fs,
} from '../shared/DialogShell'
import { EditorField, GRID_2, INPUT, LABEL, PANEL, TEXTAREA } from '../shared/dialogParts'
import { EditorField, GRID_2, INPUT, LABEL, PANEL } from '../shared/dialogParts'
import { SoftPill, tintOf } from './planParts'
import { TimeSection } from './PlaceFormTimeSection'
import { HeaderPills } from './PlaceFormHeaderPills'
@@ -223,6 +223,7 @@ function usePlaceFormModal(props: PlaceFormModalProps) {
}, [place, prefillCoords, isOpen, assignmentId])
const places = useTripStore((s) => s.places)
const tripDays = useTripStore((s) => s.days)
// Where the trip is happening — the hint that tells the search which of a
// thousand identically named places is meant. Autocomplete wants a box, the
// search wants a point; both are derived from the same places.
@@ -406,6 +407,7 @@ function usePlaceFormModal(props: PlaceFormModalProps) {
categories,
assignmentId,
dayAssignments,
dayNumber: dayNumberOf(assignmentId, dayAssignments, tripDays),
isMobile,
collectionsEnabled,
form,
@@ -800,12 +802,11 @@ export default function PlaceFormModal(props: PlaceFormModalProps) {
stop on a drive, which is not an activity anyone looks up by its tags. */}
{!serviceStop && <PlaceFormTags tags={S.tagField} t={t} />}
{/* The day in context: its times and its own note. Both live on the
day-assignment, not on the pool place (#2163), so they are only shown
when a single assignment is in context (itinerary edit, or a
single-assignment pool edit). Hidden when creating, and for unassigned
or multi-day pool edits where a single time is ambiguous and would not
persist. */}
{/* The day in context: its times. They live on the day-assignment, not on
the pool place (#2163), so they are only shown when a single assignment
is in context (itinerary edit, or a single-assignment pool edit). Hidden
when creating, and for unassigned or multi-day pool edits where a single
time is ambiguous and would not persist. */}
{!!(place && S.assignmentId) && (
<div className={PANEL}>
<TimeSection
@@ -818,39 +819,25 @@ export default function PlaceFormModal(props: PlaceFormModalProps) {
tour={props.tour}
t={t}
/>
<EditorField label={t('places.assignmentNotes')} htmlFor={`${fieldId}-day-notes`}>
<textarea
id={`${fieldId}-day-notes`}
value={form.assignment_notes ?? ''}
onChange={e => handleChange('assignment_notes', e.target.value)}
rows={2}
placeholder={t('places.assignmentNotesPlaceholder')}
className={`${TEXTAREA} resize-y`}
/>
</EditorField>
</div>
)}
<MarkdownField
id={`${fieldId}-description`}
label={t('places.formDescription')}
value={form.description}
onChange={v => handleChange('description', v)}
placeholder={t('places.formDescriptionPlaceholder')}
{/* Description, notes and the note for this day, one at a time. The day
note follows the times: only with a single assignment in context. */}
<PlaceFormTexts
fieldId={fieldId}
description={form.description}
notes={form.notes}
dayNotes={place && S.assignmentId ? (form.assignment_notes ?? "") : null}
dayNumber={S.dayNumber}
onChange={(field, value) => handleChange(field, value)}
t={t}
/>
{/* Notes — Markdown, same as the description, and rendered as such in the
inspector. The bar is how anyone finds that out. */}
<MarkdownField
id={`${fieldId}-notes`}
label={t('places.formNotes')}
value={form.notes}
onChange={v => handleChange('notes', v)}
placeholder={t('places.formNotesPlaceholder')}
maxLength={2000}
/>
{!showDetails && <div className={PANEL}><PlaceImageSection image={S.image} onPickUrl={S.pickImage} t={t} /></div>}
{!showDetails && <PlaceImageSection image={S.image} onPickUrl={S.pickImage} t={t} />}
{/* Link, files and how to reach the place, in one card. */}
<div className={PANEL}>
{/* The link and the files side by side, as on a booking. */}
<div className={canUploadFiles ? GRID_2 : ''}>
<EditorField label={t('places.formWebsite')} htmlFor={`${fieldId}-website`}>
@@ -884,6 +871,7 @@ export default function PlaceFormModal(props: PlaceFormModalProps) {
suggestedHours={S.detailsHours}
onChange={(field, value, origin) => handleChange(field, value, origin)}
/>
</div>
{/* Costs — create / view the expense linked to this place (#1298).
Same block, same flow as a booking: save first, then the editor.
@@ -891,6 +879,7 @@ export default function PlaceFormModal(props: PlaceFormModalProps) {
Never for a stop on a drive: a petrol stop is not an activity with a budget
line, and the fuel it buys is an expense of the trip rather than of a place. */}
{S.isBudgetEnabled && !serviceStop && (
<div className={PANEL}>
<BookingCostsSection
placeId={place?.id ?? null}
reservationId={null}
@@ -902,6 +891,7 @@ export default function PlaceFormModal(props: PlaceFormModalProps) {
customTooltips
whiteButtons
/>
</div>
)}
</form>
{twoColumn && (
@@ -912,32 +902,9 @@ export default function PlaceFormModal(props: PlaceFormModalProps) {
)
}
/** A Markdown field: its label, the formatting bar on the same line, the text under both. */
function MarkdownField({ id, label, value, onChange, placeholder, maxLength }: {
id: string
label: string
value: string
onChange: (value: string) => void
placeholder: string
maxLength?: number
}) {
const ref = useRef<HTMLTextAreaElement | null>(null)
return (
<DialogSection
className="min-w-0"
label={<label htmlFor={id}>{label}</label>}
action={<NoteFormatToolbar textareaRef={ref} onChange={onChange} compact customTooltips />}
>
<textarea
id={id}
ref={ref}
value={value}
onChange={e => onChange(e.target.value)}
rows={3}
maxLength={maxLength}
placeholder={placeholder}
className={`${TEXTAREA} resize-y`}
/>
</DialogSection>
)
/** The number of the day the edited visit is on, for the day note's tab; null when it is not known. */
function dayNumberOf(assignmentId: number | null, visits: Assignment[], days: { id: number; day_number?: number | null }[]): number | null {
if (!assignmentId) return null
const dayId = visits.find(visit => visit.id === assignmentId)?.day_id
return days.find(day => day.id === dayId)?.day_number ?? null
}