From d008331e5ffc61f55dca9650d271583e3eaf6a3f Mon Sep 17 00:00:00 2001 From: Maurice Date: Sun, 29 Nov 2026 21:16:38 +0100 Subject: [PATCH] feat(places): notes, visits, tours, history, tags and location in the place sheet, saved lists on the trip map Both the desktop sheet and the phone sheet of All places show the place's location as a badge, its notes per list, its visits from trips (hidden without any), linked tours and bookings, its change history and the reader's own tags with a tag filter. A trip map can show the places of linked lists and add one to the trip. All places reloads after a list is added or removed. --- client/scripts/feature-pairs.json | 36 ++++ client/scripts/theme-baseline.json | 2 +- client/src/api/placeActivities.ts | 41 ++++ client/src/api/placeHistory.ts | 15 ++ client/src/api/placeTags.ts | 32 +++ client/src/api/placeVisits.ts | 25 +++ client/src/api/placesLibrary.ts | 10 +- client/src/api/wsEventPolicy.ts | 3 + .../Collections/CategoryTileMenu.tsx | 36 ++-- .../Collections/CollectionExportMenu.tsx | 1 - .../Collections/CollectionFilterBar.tsx | 49 +++-- .../components/Collections/CollectionHero.tsx | 3 +- .../Collections/CollectionLabelFilter.tsx | 9 +- .../Collections/CollectionMapPanel.tsx | 20 +- .../Collections/CollectionPlaceDetail.tsx | 17 +- .../components/Collections/CopyCarryPanel.tsx | 97 ++++++--- .../Collections/CopyToTripModal.tsx | 4 +- .../components/Collections/EntryTagDots.tsx | 25 +++ .../Collections/EntryTagsSection.tsx | 202 ++++++++++++++++++ .../components/Collections/FilterDropdown.tsx | 1 - .../Collections/LibraryFilterBar.tsx | 18 +- .../components/Collections/LibraryOrigins.tsx | 10 +- .../Collections/LibraryPlaceDetail.tsx | 166 +++++++------- .../Collections/OriginNotesSection.tsx | 92 ++++++++ .../Collections/PlaceActivitiesSection.tsx | 116 ++++++++++ .../Collections/PlaceHistorySection.tsx | 74 +++++++ .../Collections/PlaceLocationBadge.tsx | 35 +++ .../Collections/PlaceMediaSection.tsx | 93 ++++++++ .../Collections/PlacesLibraryView.tsx | 22 +- .../components/Collections/StatusBadge.tsx | 14 +- .../Collections/TagFilterDropdown.tsx | 85 ++++++++ .../components/Collections/TripListsPill.tsx | 186 ++++++++++++++++ .../Collections/TripPlaceVisits.tsx | 36 ++++ .../components/Collections/VisitedMark.tsx | 31 +++ .../components/Collections/VisitsSection.tsx | 69 ++++++ .../components/Collections/libraryDates.ts | 12 ++ .../components/Collections/libraryPairs.ts | 15 ++ .../components/Collections/placeExtrasText.ts | 58 +++++ .../components/Collections/placeLocation.css | 28 +++ .../components/Collections/useEntryTags.ts | 112 ++++++++++ .../components/Collections/useOriginNotes.ts | 105 +++++++++ .../Collections/usePlaceActivities.ts | 134 ++++++++++++ .../components/Collections/usePlaceHistory.ts | 70 ++++++ .../components/Collections/usePlaceMedia.ts | 85 ++++++++ .../components/Collections/usePlaceVisits.ts | 80 +++++++ .../Collections/usePlacesLibrary.ts | 20 +- .../Collections/useTripCopyPicker.ts | 15 +- .../components/Collections/useTripLists.ts | 199 +++++++++++++++++ client/src/components/Map/poiCategories.ts | 11 + client/src/components/Map/poiMarker.ts | 4 +- .../src/components/Planner/PlaceInspector.tsx | 2 + .../Planner/PlacesSidebarHeader.tsx | 2 +- .../src/components/Planner/TravelerPicker.tsx | 2 +- .../src/components/Planner/usePlacesPool.ts | 9 +- .../components/Planner/usePlacesSidebar.ts | 11 +- client/src/hooks/useTripVisitedIds.ts | 26 +++ .../screens/collections/MCollPlaceSheet.tsx | 7 +- .../collections/MCollTripPickerSheet.tsx | 4 +- .../screens/collections/MCollections.tsx | 1 - .../screens/collections/MEntryTagsSection.tsx | 159 ++++++++++++++ .../collections/MLibraryPlaceSheet.tsx | 88 ++++---- .../collections/MOriginNotesSection.tsx | 94 ++++++++ .../collections/MPlaceActivitiesSection.tsx | 103 +++++++++ .../collections/MPlaceHistorySection.tsx | 62 ++++++ .../collections/MPlaceMediaSection.tsx | 88 ++++++++ .../screens/collections/MPlacesLibrary.tsx | 77 ++++++- .../screens/collections/MVisitsSection.tsx | 89 ++++++++ .../src/mobile/screens/trip/map/MMapArea.tsx | 22 +- .../screens/trip/places/MPlacesBrowser.tsx | 13 +- .../screens/trip/places/placesBrowserModel.ts | 6 +- .../screens/trip/sheets/MPlaceSheet.tsx | 2 + client/src/pages/tripPlanner/PlanMapStage.tsx | 19 +- client/src/pages/tripPlanner/useMapPlaces.ts | 6 +- client/src/repo/placeActivitiesRepo.ts | 86 ++++++++ client/src/repo/placeHistoryRepo.ts | 21 ++ client/src/repo/placeTagsRepo.ts | 49 +++++ client/src/repo/placeVisitsRepo.ts | 39 ++++ client/src/repo/placesLibraryRepo.ts | 17 +- client/src/store/collectionStore.ts | 3 +- client/src/store/placeActivitiesStore.ts | 200 +++++++++++++++++ client/src/store/placeTagsStore.ts | 90 ++++++++ client/src/store/placeVisitsStore.ts | 124 +++++++++++ client/src/styles/collections.css | 11 + client/src/utils/placesFilter.ts | 7 +- 84 files changed, 3874 insertions(+), 288 deletions(-) create mode 100644 client/src/api/placeActivities.ts create mode 100644 client/src/api/placeHistory.ts create mode 100644 client/src/api/placeTags.ts create mode 100644 client/src/api/placeVisits.ts create mode 100644 client/src/components/Collections/EntryTagDots.tsx create mode 100644 client/src/components/Collections/EntryTagsSection.tsx create mode 100644 client/src/components/Collections/OriginNotesSection.tsx create mode 100644 client/src/components/Collections/PlaceActivitiesSection.tsx create mode 100644 client/src/components/Collections/PlaceHistorySection.tsx create mode 100644 client/src/components/Collections/PlaceLocationBadge.tsx create mode 100644 client/src/components/Collections/PlaceMediaSection.tsx create mode 100644 client/src/components/Collections/TagFilterDropdown.tsx create mode 100644 client/src/components/Collections/TripListsPill.tsx create mode 100644 client/src/components/Collections/TripPlaceVisits.tsx create mode 100644 client/src/components/Collections/VisitedMark.tsx create mode 100644 client/src/components/Collections/VisitsSection.tsx create mode 100644 client/src/components/Collections/placeExtrasText.ts create mode 100644 client/src/components/Collections/placeLocation.css create mode 100644 client/src/components/Collections/useEntryTags.ts create mode 100644 client/src/components/Collections/useOriginNotes.ts create mode 100644 client/src/components/Collections/usePlaceActivities.ts create mode 100644 client/src/components/Collections/usePlaceHistory.ts create mode 100644 client/src/components/Collections/usePlaceMedia.ts create mode 100644 client/src/components/Collections/usePlaceVisits.ts create mode 100644 client/src/components/Collections/useTripLists.ts create mode 100644 client/src/hooks/useTripVisitedIds.ts create mode 100644 client/src/mobile/screens/collections/MEntryTagsSection.tsx create mode 100644 client/src/mobile/screens/collections/MOriginNotesSection.tsx create mode 100644 client/src/mobile/screens/collections/MPlaceActivitiesSection.tsx create mode 100644 client/src/mobile/screens/collections/MPlaceHistorySection.tsx create mode 100644 client/src/mobile/screens/collections/MPlaceMediaSection.tsx create mode 100644 client/src/mobile/screens/collections/MVisitsSection.tsx create mode 100644 client/src/repo/placeActivitiesRepo.ts create mode 100644 client/src/repo/placeHistoryRepo.ts create mode 100644 client/src/repo/placeTagsRepo.ts create mode 100644 client/src/repo/placeVisitsRepo.ts create mode 100644 client/src/store/placeActivitiesStore.ts create mode 100644 client/src/store/placeTagsStore.ts create mode 100644 client/src/store/placeVisitsStore.ts diff --git a/client/scripts/feature-pairs.json b/client/scripts/feature-pairs.json index ff04a4d81..7861ccf9c 100644 --- a/client/scripts/feature-pairs.json +++ b/client/scripts/feature-pairs.json @@ -309,6 +309,42 @@ "desktop": ["src/components/Collections/LibraryPlaceDetail.tsx"], "mobile": ["src/mobile/screens/collections/MLibraryPlaceSheet.tsx"] }, + { + "feature": "Places: tours and bookings of a place", + "hooks": ["src/components/Collections/usePlaceActivities.ts", "src/components/Collections/placeExtrasText.ts"], + "desktop": ["src/components/Collections/PlaceActivitiesSection.tsx"], + "mobile": ["src/mobile/screens/collections/MPlaceActivitiesSection.tsx"] + }, + { + "feature": "Places: changes of a place", + "hooks": ["src/components/Collections/usePlaceHistory.ts", "src/components/Collections/placeExtrasText.ts"], + "desktop": ["src/components/Collections/PlaceHistorySection.tsx"], + "mobile": ["src/mobile/screens/collections/MPlaceHistorySection.tsx"] + }, + { + "feature": "Places: personal tags of a place", + "hooks": ["src/components/Collections/useEntryTags.ts"], + "desktop": ["src/components/Collections/EntryTagsSection.tsx", "src/components/Collections/PlacesLibraryView.tsx"], + "mobile": ["src/mobile/screens/collections/MEntryTagsSection.tsx", "src/mobile/screens/collections/MPlacesLibrary.tsx"] + }, + { + "feature": "Places: notes of a place", + "hooks": ["src/components/Collections/useOriginNotes.ts"], + "desktop": ["src/components/Collections/OriginNotesSection.tsx"], + "mobile": ["src/mobile/screens/collections/MOriginNotesSection.tsx"] + }, + { + "feature": "Places: pictures and files of a place", + "hooks": ["src/components/Collections/usePlaceMedia.ts"], + "desktop": ["src/components/Collections/PlaceMediaSection.tsx"], + "mobile": ["src/mobile/screens/collections/MPlaceMediaSection.tsx"] + }, + { + "feature": "Places: visits of a place", + "hooks": ["src/components/Collections/usePlaceVisits.ts"], + "desktop": ["src/components/Collections/VisitsSection.tsx", "src/components/Collections/TripPlaceVisits.tsx"], + "mobile": ["src/mobile/screens/collections/MVisitsSection.tsx"] + }, { "feature": "Places: possible duplicates", "hooks": ["src/components/Collections/DuplicatePairCard.tsx"], diff --git a/client/scripts/theme-baseline.json b/client/scripts/theme-baseline.json index bed5ff3cb..c95da0641 100644 --- a/client/scripts/theme-baseline.json +++ b/client/scripts/theme-baseline.json @@ -171,7 +171,7 @@ "mobile/screens/collections/MCollLinksEditor.tsx": 2, "mobile/screens/collections/MCollListPickerSheet.tsx": 3, "mobile/screens/collections/MCollPlaceRow.tsx": 3, - "mobile/screens/collections/MCollPlaceSheet.tsx": 11, + "mobile/screens/collections/MCollPlaceSheet.tsx": 10, "mobile/screens/collections/MCollShareSheet.tsx": 14, "mobile/screens/collections/MCollSheetKit.tsx": 5, "mobile/screens/collections/MCollTripPickerSheet.tsx": 4, diff --git a/client/src/api/placeActivities.ts b/client/src/api/placeActivities.ts new file mode 100644 index 000000000..235c8230e --- /dev/null +++ b/client/src/api/placeActivities.ts @@ -0,0 +1,41 @@ +import type { + PlaceActivitiesResponse, + PlaceActivityCandidatesResponse, + PlaceLibraryActivitiesResponse, + PlacesLibraryKind, + TripPlaceActivityLinkRequest, +} from '@trek/shared'; +import apiClient from './client'; + +const tripBase = (tripId: number, placeId: number) => `/trips/${tripId}/places/${placeId}/activities`; +const savedBase = (collectionPlaceId: number) => `/addons/collections/places/${collectionPlaceId}/activities`; + +/** + * PLC-18: the bookings and tours a place is about. A trip place links bookings + * and tours of its trip, a saved place tours kept in its list; an entry of All + * places reads them over every origin it has. Unlinking takes only the link off. + */ +export const placeActivitiesApi = { + tripPlace: (tripId: number, placeId: number, signal?: AbortSignal): Promise => + apiClient.get(tripBase(tripId, placeId), { signal }).then((r) => r.data), + tripCandidates: (tripId: number, placeId: number, signal?: AbortSignal): Promise => + apiClient.get(`${tripBase(tripId, placeId)}/candidates`, { signal }).then((r) => r.data), + linkTrip: (tripId: number, placeId: number, body: TripPlaceActivityLinkRequest): Promise => + apiClient.post(tripBase(tripId, placeId), body).then((r) => r.data), + unlinkTripBooking: (tripId: number, placeId: number, reservationId: number): Promise => + apiClient.delete(`${tripBase(tripId, placeId)}/reservations/${reservationId}`).then((r) => r.data), + unlinkTripTour: (tripId: number, placeId: number, tourId: number): Promise => + apiClient.delete(`${tripBase(tripId, placeId)}/tours/${tourId}`).then((r) => r.data), + + savedPlace: (collectionPlaceId: number, signal?: AbortSignal): Promise => + apiClient.get(savedBase(collectionPlaceId), { signal }).then((r) => r.data), + savedCandidates: (collectionPlaceId: number, signal?: AbortSignal): Promise => + apiClient.get(`${savedBase(collectionPlaceId)}/candidates`, { signal }).then((r) => r.data), + linkSaved: (collectionPlaceId: number, collectionTourId: number): Promise => + apiClient.post(savedBase(collectionPlaceId), { collection_tour_id: collectionTourId }).then((r) => r.data), + unlinkSaved: (collectionPlaceId: number, collectionTourId: number): Promise => + apiClient.delete(`${savedBase(collectionPlaceId)}/tours/${collectionTourId}`).then((r) => r.data), + + libraryEntry: (kind: PlacesLibraryKind, id: number, signal?: AbortSignal): Promise => + apiClient.get(`/addons/collections/library/places/${kind}/${id}/activities`, { signal }).then((r) => r.data), +}; diff --git a/client/src/api/placeHistory.ts b/client/src/api/placeHistory.ts new file mode 100644 index 000000000..ac4927968 --- /dev/null +++ b/client/src/api/placeHistory.ts @@ -0,0 +1,15 @@ +import type { PlaceHistoryPageResponse, PlaceHistoryQueryInput, PlacesLibraryKind } from '@trek/shared'; +import apiClient from './client'; + +const base = '/addons/collections/library/places'; + +/** PLC-14: what changed in the details of an entry of All places, opened from a trip place or a saved place. */ +export const placeHistoryApi = { + history: ( + kind: PlacesLibraryKind, + id: number, + query: PlaceHistoryQueryInput = {}, + signal?: AbortSignal + ): Promise => + apiClient.get(`${base}/${kind}/${id}/history`, { params: query, signal }).then((r) => r.data), +}; diff --git a/client/src/api/placeTags.ts b/client/src/api/placeTags.ts new file mode 100644 index 000000000..25d91e010 --- /dev/null +++ b/client/src/api/placeTags.ts @@ -0,0 +1,32 @@ +import type { + CreateTagRequest, + PlacesLibraryBulkTagsRequest, + PlacesLibraryBulkTagsResponse, + PlacesLibraryEntryTagsRequest, + PlacesLibraryEntryTagsResponse, + Tag, + TagListResponse, + UpdateTagRequest, +} from '@trek/shared'; +import apiClient from './client'; + +const base = '/addons/collections/library/places/tags'; + +/** + * PLC-21: the user's personal tags (the ones /tags keeps) and which entries + * of All places carry them. Everything here is the user's own and private. + */ +export const placeTagsApi = { + list: (): Promise => apiClient.get('/tags').then((r) => r.data), + create: (body: CreateTagRequest): Promise<{ tag: Tag }> => + apiClient.post('/tags', body satisfies CreateTagRequest).then((r) => r.data), + update: (id: number, body: UpdateTagRequest): Promise<{ tag: Tag }> => + apiClient.put(`/tags/${id}`, body satisfies UpdateTagRequest).then((r) => r.data), + remove: (id: number): Promise<{ success: boolean }> => apiClient.delete(`/tags/${id}`).then((r) => r.data), + /** The entry carries exactly these tags from now on. */ + setForEntry: (body: PlacesLibraryEntryTagsRequest): Promise => + apiClient.put(base, body satisfies PlacesLibraryEntryTagsRequest).then((r) => r.data), + /** Puts tags on several entries and takes others off them. */ + bulk: (body: PlacesLibraryBulkTagsRequest): Promise => + apiClient.post(`${base}/bulk`, body satisfies PlacesLibraryBulkTagsRequest).then((r) => r.data), +}; diff --git a/client/src/api/placeVisits.ts b/client/src/api/placeVisits.ts new file mode 100644 index 000000000..753722d50 --- /dev/null +++ b/client/src/api/placeVisits.ts @@ -0,0 +1,25 @@ +import type { + PlaceMediaResponse, + PlacesLibraryKind, + PlaceVisitsForPlaceResponse, + PlaceVisitsListQuery, + PlaceVisitsListResponse, + PlaceVisitTripVisitedResponse, +} from '@trek/shared'; +import apiClient from './client'; + +/** + * D7/PLC-10, PLC-19, PLC-20, PLC-23: the visits the server reads from the + * trips (nothing to write: a visit comes from the trip's plan), the trip + * places visited, and the photos and files of an entry of All places. + */ +export const placeVisitsApi = { + list: (query: PlaceVisitsListQuery = {}, signal?: AbortSignal): Promise => + apiClient.get('/place-visits', { params: query, signal }).then((r) => r.data), + forPlace: (kind: PlacesLibraryKind, id: number, signal?: AbortSignal): Promise => + apiClient.get('/place-visits/place', { params: { kind, id }, signal }).then((r) => r.data), + tripVisited: (tripId: number, signal?: AbortSignal): Promise => + apiClient.get(`/trips/${tripId}/place-visits/mine`, { signal }).then((r) => r.data), + media: (kind: PlacesLibraryKind, id: number, signal?: AbortSignal): Promise => + apiClient.get(`/addons/collections/library/places/${kind}/${id}/media`, { signal }).then((r) => r.data), +}; diff --git a/client/src/api/placesLibrary.ts b/client/src/api/placesLibrary.ts index 3fb36ce3f..fd7e58775 100644 --- a/client/src/api/placesLibrary.ts +++ b/client/src/api/placesLibrary.ts @@ -8,10 +8,18 @@ import apiClient from './client'; const base = '/addons/collections/library/places'; +/** The query as the server reads it: a tag filter (PLC-21) as its ids joined by commas, not `tag_ids[]=`. */ +function queryParams(query: PlacesLibraryQueryInput): Record { + const { tag_ids: tagIds, ...rest } = query; + if (tagIds === undefined) return rest; + const joined = Array.isArray(tagIds) ? tagIds.join(',') : tagIds; + return joined === '' ? rest : { ...rest, tag_ids: joined }; +} + /** PLC-07/PLC-08 "All places": one page of entries, and one entry by the trip place or saved place it was opened from. */ export const placesLibraryApi = { list: (query: PlacesLibraryQueryInput = {}, signal?: AbortSignal): Promise => - apiClient.get(base, { params: query, signal }).then((r) => r.data), + apiClient.get(base, { params: queryParams(query), signal }).then((r) => r.data), detail: (kind: PlacesLibraryKind, id: number, signal?: AbortSignal): Promise => apiClient.get(`${base}/${kind}/${id}`, { signal }).then((r) => r.data), }; diff --git a/client/src/api/wsEventPolicy.ts b/client/src/api/wsEventPolicy.ts index 6715020ad..9a98352ed 100644 --- a/client/src/api/wsEventPolicy.ts +++ b/client/src/api/wsEventPolicy.ts @@ -53,6 +53,9 @@ export const HANDLED_OUTSIDE_TRIP_STORE = [ // Linked lists (PLC-15/PLC-16): store/tripCollectionsStore (watchTripCollections) reads the // trip's linked lists and map layer again; content-free because each member's answer differs. 'tripCollections:changed', + // Place activities (PLC-18): store/placeActivitiesStore (watchPlaceActivities) reads the + // bookings and tours of the held trip place, and the All places entries it is an origin of, again. + 'placeActivities:changed', // components/Roadtrip/useDayBoundaries reloads the shared boundaries. 'roadtripBoundary:changed', // In-app notifications: hooks/useInAppNotificationListener, which also keeps diff --git a/client/src/components/Collections/CategoryTileMenu.tsx b/client/src/components/Collections/CategoryTileMenu.tsx index fd9ef0844..86bdaaa3e 100644 --- a/client/src/components/Collections/CategoryTileMenu.tsx +++ b/client/src/components/Collections/CategoryTileMenu.tsx @@ -2,6 +2,7 @@ import { Check, Shapes } from 'lucide-react'; import React, { createElement, useEffect, useRef, useState } from 'react'; import type { Category, TranslationFn } from '../../types'; import { getCategoryIcon } from '../shared/categoryIcons'; +import { Tooltip } from '../shared/Tooltip'; interface CategoryTileMenuProps { categories: Category[]; @@ -52,23 +53,24 @@ export default function CategoryTileMenu({ return (
- + + + {open && (
{exporting ? : } diff --git a/client/src/components/Collections/CollectionFilterBar.tsx b/client/src/components/Collections/CollectionFilterBar.tsx index 9aa684219..d8a03cb31 100644 --- a/client/src/components/Collections/CollectionFilterBar.tsx +++ b/client/src/components/Collections/CollectionFilterBar.tsx @@ -3,6 +3,7 @@ import { Layers, Tag, CheckSquare, Star, Plus, ArrowDownUp, DownloadCloud } from import type { StatusFilter, CollectionSortMode } from '../../store/collectionStore' import type { TranslationFn } from '../../types' import { getCategoryIcon } from '../shared/categoryIcons' +import { Tooltip } from '../shared/Tooltip' import { STATUS_META, STATUS_ORDER } from '../../pages/collections/collectionsModel' import type { CategoryOption, LabelOption } from '../../pages/collections/collectionsModel' import CollectionLabelFilter from './CollectionLabelFilter' @@ -87,9 +88,11 @@ export default function CollectionFilterBar({ return (
{canAddPlace && ( - + + + )} onStatusFilter(k as StatusFilter)} lead={} /> {categoryOptions.length > 0 && ( @@ -98,27 +101,29 @@ export default function CollectionFilterBar({ onRatingFilter(k as number | 'all')} lead={} /> onSortMode(k as CollectionSortMode)} lead={} /> {showSelect && ( - + + + )} {canImport && ( - + + + )} {showLabels && (labelOptions.length > 0 || canManageLabels) && ( {title}
{canEdit && ( - @@ -106,7 +106,6 @@ export default function CollectionHero({ type="button" onClick={onShare} aria-label={isOwner ? t('collections.share.button') : t('collections.shared')} - title={isOwner ? t('collections.share.button') : t('collections.shared')} className={`col-glass-btn${isOwner && shareMemberCount > 0 ? ' has-count' : ''}`} > {isOwner ? : } diff --git a/client/src/components/Collections/CollectionLabelFilter.tsx b/client/src/components/Collections/CollectionLabelFilter.tsx index 702f30f1e..37de602ed 100644 --- a/client/src/components/Collections/CollectionLabelFilter.tsx +++ b/client/src/components/Collections/CollectionLabelFilter.tsx @@ -1,5 +1,6 @@ import React, { useEffect, useLayoutEffect, useRef, useState } from 'react' import { Check, ChevronDown, Plus, Settings2, Tags } from 'lucide-react' +import { Tooltip } from '../shared/Tooltip' import type { LabelOption } from '../../pages/collections/collectionsModel' import type { TranslationFn } from '../../types' @@ -108,9 +109,11 @@ export default function CollectionLabelFilter({ const toggle = (id: number) => onLabelFilter(labelFilter.includes(id) ? labelFilter.filter(x => x !== id) : [...labelFilter, id]) const manageLabel = labelOptions.length ? t('collections.labels.manage') : t('collections.labels.add') const manage = canManageLabels && onManageLabels && ( - + + + ) const tray = ( diff --git a/client/src/components/Collections/CollectionMapPanel.tsx b/client/src/components/Collections/CollectionMapPanel.tsx index 146e7d13f..8567f8fdc 100644 --- a/client/src/components/Collections/CollectionMapPanel.tsx +++ b/client/src/components/Collections/CollectionMapPanel.tsx @@ -1,5 +1,6 @@ import React from 'react' import { PanelLeftClose, PanelLeftOpen, Search } from 'lucide-react' +import { Tooltip } from '../shared/Tooltip' import type { CollectionPlace } from '@trek/shared' import type { TranslationFn } from '../../types' import CollectionMap from './CollectionMap' @@ -60,15 +61,16 @@ export default function CollectionMapPanel({ {overlay && (
- + + + {showLabels && ( 0 && } setName(e.target.value)} className="col-detail-name-input min-w-0 flex-1" autoFocus aria-label={t('common.name')} />
- ) :

{place.name}

} + ) : ( + <> +

{place.name}

+ + + )}
- {/* Meta (view only) */} - {!editing && place.address && ( -
- {place.address && {place.address}} - {/* Same picker as inside a trip (#1455). A saved place is somewhere - you intend to go, and until now the only way to get directions - was to add it to a trip first. */} -
- )} {/* Status — live for editors, read-only for viewers */} {}} t={t} /> diff --git a/client/src/components/Collections/CopyCarryPanel.tsx b/client/src/components/Collections/CopyCarryPanel.tsx index 66f2cdc6c..b94f72935 100644 --- a/client/src/components/Collections/CopyCarryPanel.tsx +++ b/client/src/components/Collections/CopyCarryPanel.tsx @@ -10,6 +10,8 @@ interface CopyCarryPanelProps { onIncludeNotes: (on: boolean) => void; tagIds: number[]; onToggleTag: (id: number) => void; + personalTagIds?: number[]; + onTogglePersonalTag?: (id: number) => void; /** The phone sheet wears the mobile tokens, the desktop dialog the app's. */ variant: 'dialog' | 'sheet'; t: TranslationFn; @@ -34,6 +36,53 @@ const LOOK = { }, } as const; +type Look = (typeof LOOK)[keyof typeof LOOK]; + +/** One group of tags to take along, each a chip in its own colour that turns on when picked. */ +function TagChoice({ + title, + hint, + tags, + picked, + onToggle, + look, +}: { + title: string; + hint: string; + tags: { id: number; name: string; color?: string | null }[]; + picked: number[]; + onToggle: (id: number) => void; + look: Look; +}) { + return ( +
+
+ ); +} + /** * What goes along when saved places are copied into a trip (#3168). Notes and tags * are the reader's own, so neither leaves the list unless it is switched on here; a @@ -45,6 +94,8 @@ export default function CopyCarryPanel({ onIncludeNotes, tagIds, onToggleTag, + personalTagIds, + onTogglePersonalTag, variant, t, }: CopyCarryPanelProps): React.ReactElement { @@ -67,34 +118,24 @@ export default function CopyCarryPanel({
)} {options.tags.length > 0 && ( -
-
+ + )} + {!!options.personalTags?.length && onTogglePersonalTag && ( + )} ); diff --git a/client/src/components/Collections/CopyToTripModal.tsx b/client/src/components/Collections/CopyToTripModal.tsx index 35cd4a81d..50e7a0e9a 100644 --- a/client/src/components/Collections/CopyToTripModal.tsx +++ b/client/src/components/Collections/CopyToTripModal.tsx @@ -26,7 +26,7 @@ interface CopyToTripModalProps { */ export default function CopyToTripModal({ isOpen, onClose, placeIds, onCopy, carryOptions, t }: CopyToTripModalProps): React.ReactElement | null { const labelId = useId() - const { loading, search, setSearch, filtered, busyTripId, dateRange, handleCopy, offersCarry, includeNotes, setIncludeNotes, tagIds, toggleTag } = + const { loading, search, setSearch, filtered, busyTripId, dateRange, handleCopy, offersCarry, includeNotes, setIncludeNotes, tagIds, toggleTag, personalTagIds, togglePersonalTag } = useTripCopyPicker({ open: isOpen, onCopy, onClose, t, emptySelection: placeIds.length === 0, carryOptions }) if (!isOpen) return null @@ -66,7 +66,7 @@ export default function CopyToTripModal({ isOpen, onClose, placeIds, onCopy, car />
{offersCarry && carryOptions && ( - + )} {loading ? (
diff --git a/client/src/components/Collections/EntryTagDots.tsx b/client/src/components/Collections/EntryTagDots.tsx new file mode 100644 index 000000000..c318b9e9e --- /dev/null +++ b/client/src/components/Collections/EntryTagDots.tsx @@ -0,0 +1,25 @@ +import type { PlacesLibraryTag } from '@trek/shared'; +import React from 'react'; +import { Tooltip } from '../shared/Tooltip'; + +/** + * The reader's own tags on a row of All places (PLC-21): one dot per tag in its + * colour behind the name, the names in the tooltip, so the row keeps its two lines. + */ +export default function EntryTagDots({ tags }: { tags: PlacesLibraryTag[] | undefined }): React.ReactElement | null { + if (!tags?.length) return null; + return ( + tag.name).join(', ')}> + tag.name).join(', ')} + > + {tags.slice(0, 4).map((tag) => ( + // The tag's own colour, the one data-driven value of the dot. + + ))} + + + ); +} diff --git a/client/src/components/Collections/EntryTagsSection.tsx b/client/src/components/Collections/EntryTagsSection.tsx new file mode 100644 index 000000000..e14e0749e --- /dev/null +++ b/client/src/components/Collections/EntryTagsSection.tsx @@ -0,0 +1,202 @@ +import type { PlacesLibraryDetailResponse, Tag as TagRow } from '@trek/shared'; +import { Check, Pencil, Plus, Tag, Trash2, X } from 'lucide-react'; +import React, { useEffect, useRef, useState } from 'react'; +import type { TranslationFn } from '../../types'; +import ConfirmDialog from '../shared/ConfirmDialog'; +import { Tooltip } from '../shared/Tooltip'; +import { useEntryTags } from './useEntryTags'; + +type EntryTags = ReturnType; + +/** A tag's colour as a dot, the one data-driven value of the chip. */ +function Dot({ color }: { color: string | null | undefined }) { + return ; +} + +const ROW = 'flex w-full items-center gap-2 rounded-lg px-2 py-1.5 text-start text-body hover:bg-surface-secondary'; +const ICON_BTN = + 'grid h-6 w-6 flex-none place-items-center rounded-md text-content-muted hover:bg-surface-tertiary hover:text-content'; + +/** One tag in the picker: ticked when the place carries it, renamed or deleted in place. */ +function TagRowItem({ tag, on, tags, t }: { tag: TagRow; on: boolean; tags: EntryTags; t: TranslationFn }) { + const [editing, setEditing] = useState(false); + const [name, setName] = useState(String(tag.name)); + const [confirm, setConfirm] = useState(false); + if (editing) { + return ( +
{ + e.preventDefault(); + void tags.rename(tag.id, name); + setEditing(false); + }} + > + setName(e.target.value)} + aria-label={t('placeTags.rename')} + className="min-w-0 flex-1 rounded-md border border-edge bg-surface-input px-2 py-1 text-body text-content outline-none" + /> + + +
+ ); + } + return ( +
+ + + + + + + + setConfirm(false)} + onConfirm={() => void tags.destroy(tag.id)} + title={t('placeTags.deleteTitle', { name: String(tag.name) })} + message={t('placeTags.deleteMessage')} + confirmLabel={t('placeTags.delete')} + danger + /> +
+ ); +} + +/** + * The reader's own tags on a place of All places in the desktop sheet (PLC-21): + * the ones it carries as chips, and a picker to tick others, make a new one from + * the search, rename or delete a tag. Only the reader sees them. + */ +export default function EntryTagsSection({ + data, + onChanged, + t, +}: { + data: PlacesLibraryDetailResponse | null; + onChanged: () => void; + t: TranslationFn; +}): React.ReactElement { + const tags = useEntryTags({ entry: data?.entry ?? null, onChanged, t }); + const [open, setOpen] = useState(false); + const ref = useRef(null); + + useEffect(() => { + if (!open) return; + const onDown = (e: PointerEvent) => { + // A dialog over the picker (delete) is outside it but belongs to it. + if ( + ref.current && + !ref.current.contains(e.target as Node) && + !(e.target as Element).closest?.('[role="dialog"]') + ) { + setOpen(false); + } + }; + document.addEventListener('pointerdown', onDown); + return () => document.removeEventListener('pointerdown', onDown); + }, [open]); + + return ( +
+
+ + {t('placeTags.title')} + + + {open && ( +
+
{ + e.preventDefault(); + if (tags.canCreate) void tags.createAndAdd(); + }} + > + tags.setQuery(e.target.value)} + placeholder={t('placeTags.search')} + aria-label={t('placeTags.search')} + className="mb-1 w-full rounded-lg border border-edge bg-surface-input px-2.5 py-1.5 text-body text-content outline-none placeholder:text-content-faint" + /> +
+
+ {tags.matches.map((tag) => ( + + ))} + {tags.matches.length === 0 && !tags.canCreate && ( +

{t('placeTags.none')}

+ )} +
+ {tags.canCreate && ( + + )} +
+ )} +
+ {tags.assigned.length > 0 ? ( +
+ {tags.assigned.map((tag) => ( + + + {tag.name} + + + ))} +
+ ) : ( +

{t('placeTags.private')}

+ )} +
+ ); +} diff --git a/client/src/components/Collections/FilterDropdown.tsx b/client/src/components/Collections/FilterDropdown.tsx index aa3886361..e3ab07a32 100644 --- a/client/src/components/Collections/FilterDropdown.tsx +++ b/client/src/components/Collections/FilterDropdown.tsx @@ -49,7 +49,6 @@ export default function FilterDropdown({ onClick={() => setOpen((o) => !o)} aria-haspopup="listbox" aria-expanded={open} - title={cur.label} > {cur.icon ?? lead} {cur.label} diff --git a/client/src/components/Collections/LibraryFilterBar.tsx b/client/src/components/Collections/LibraryFilterBar.tsx index c0178ebb8..0bc913c42 100644 --- a/client/src/components/Collections/LibraryFilterBar.tsx +++ b/client/src/components/Collections/LibraryFilterBar.tsx @@ -1,10 +1,11 @@ -import type { CollectionStatus, PlacesLibraryCounts, PlacesLibrarySort } from '@trek/shared'; +import type { CollectionStatus, PlacesLibraryCounts, PlacesLibrarySort, Tag as TagRow } from '@trek/shared'; import { ArrowDownUp, Bookmark, CopyCheck, Globe2, Layers, Luggage, Tag } from 'lucide-react'; import React from 'react'; import type { Category, TranslationFn } from '../../types'; import { getCategoryIcon } from '../shared/categoryIcons'; import { STATUS_META, STATUS_ORDER } from './collectionStatus'; import FilterDropdown, { type FilterOption } from './FilterDropdown'; +import TagFilterDropdown from './TagFilterDropdown'; import type { LibraryKindFilter } from './usePlacesLibrary'; interface LibraryFilterBarProps { @@ -22,6 +23,10 @@ interface LibraryFilterBarProps { duplicates?: number; duplicatesMore?: boolean; onDuplicates?: () => void; + /** The reader's own tags (PLC-21) and the ones the list is narrowed to. */ + tags?: readonly TagRow[]; + tagIds?: readonly number[]; + onToggleTag?: (id: number) => void; t: TranslationFn; } @@ -44,6 +49,9 @@ export default function LibraryFilterBar({ duplicates = 0, duplicatesMore = false, onDuplicates, + tags = [], + tagIds = [], + onToggleTag, t, }: LibraryFilterBarProps): React.ReactElement { const kindOpts: FilterOption[] = [ @@ -95,6 +103,7 @@ export default function LibraryFilterBar({ lead={} /> )} + {onToggleTag && } } /> {duplicates > 0 && onDuplicates && ( -
); diff --git a/client/src/components/Collections/LibraryPlaceDetail.tsx b/client/src/components/Collections/LibraryPlaceDetail.tsx index e37eaf617..ccdf8a298 100644 --- a/client/src/components/Collections/LibraryPlaceDetail.tsx +++ b/client/src/components/Collections/LibraryPlaceDetail.tsx @@ -7,10 +7,7 @@ import { Hotel, Loader2, Luggage, - MapPin, - MapPinOff, Navigation, - NotebookPen, Star, Ticket, X, @@ -21,7 +18,9 @@ import { entityGradient } from '../../utils/gradients'; import { getNavigationTargets, navigationTargetLabel, openNavigationTarget } from '../Planner/placeNavigation'; import { getCategoryIcon } from '../shared/categoryIcons'; import { NavigationMenu } from '../shared/NavigationMenu'; +import { STATUS_META } from './collectionStatus'; import { dockStyle, type DockRect } from './detailDock'; +import EntryTagsSection from './EntryTagsSection'; import { tripLine } from './libraryDates'; import { originPairs, @@ -32,8 +31,15 @@ import { type TripOrigin, type TripPair, } from './libraryPairs'; +import { listIcon } from './listIcons'; import { originName } from './originName'; +import OriginNotesSection from './OriginNotesSection'; +import PlaceActivitiesSection from './PlaceActivitiesSection'; +import PlaceHistorySection from './PlaceHistorySection'; +import PlaceLocationBadge from './PlaceLocationBadge'; +import PlaceMediaSection from './PlaceMediaSection'; import StatusBadge from './StatusBadge'; +import VisitsSection from './VisitsSection'; interface LibraryPlaceDetailProps { data: PlacesLibraryDetailResponse | null; @@ -50,21 +56,11 @@ interface LibraryPlaceDetailProps { onSaveToList: (origin: TripOrigin, detail: TripDetail) => void; /** Copies a saved place into a trip (the list's own copy flow). */ onCopyToTrip: (collectionPlaceId: number) => void; + /** A note was saved: read the place again. */ + onNotesSaved: () => void; t: TranslationFn; } -function Notes({ text, t }: { text: string | null; t: TranslationFn }) { - if (!text?.trim()) return null; - return ( - - - {t('collections.notes')} - - {text} - - ); -} - function TripCard({ origin, detail, @@ -91,7 +87,11 @@ function TripCard({ > - + {origin.trip_cover ? ( + + ) : ( + + )} {originName(origin)} @@ -117,7 +117,6 @@ function TripCard({ )} )} - ); } @@ -126,12 +125,15 @@ function ListCard({ origin, detail, entryName, + compact, onOpen, t, }: { origin: ListOrigin; detail: ListDetail; entryName: string; + /** Beside the trips: the status under the name. */ + compact: boolean; onOpen: () => void; t: TranslationFn; }) { @@ -144,13 +146,26 @@ function ListCard({ aria-label={`${t('collections.library.openList')}: ${originName(origin)}`} > - - + + {createElement(listIcon(origin.collection_icon), { size: 15 })} {originName(origin)} + {compact && ( + + {createElement(STATUS_META[origin.status].icon, { + size: 12, + strokeWidth: 2.4, + style: { color: STATUS_META[origin.status].color }, + })} + {t(STATUS_META[origin.status].labelKey)} + + )} - + {!compact && } {extras && ( @@ -178,7 +193,6 @@ function ListCard({ )} )} - ); } @@ -219,34 +233,17 @@ function DetailCover({ {entry && (

{entry.name}

+
)}
); } -/** Where the place is, or that it has no position yet. */ -function DetailMeta({ entry, t }: { entry: Entry; t: TranslationFn }) { - const unplaced = entry.lat == null || entry.lng == null; - if (!entry.address && !unplaced) return null; - return ( -
- {entry.address && ( - - {entry.address} - - )} - {unplaced && ( - - {t('places.noCoordinates')} - - )} -
- ); -} - /** The body: where it is, its description, then every trip and every list it sits in. */ function DetailBody({ + data, + onNotesSaved, entry, trips, lists, @@ -256,6 +253,8 @@ function DetailBody({ onOpenList, t, }: { + data: PlacesLibraryDetailResponse | null; + onNotesSaved: () => void; entry: Entry; trips: TripPair[]; lists: ListPair[]; @@ -265,45 +264,55 @@ function DetailBody({ onOpenList: (collectionId: number, collectionPlaceId: number) => void; t: TranslationFn; }) { + const paired = trips.length > 0 && lists.length > 0; return ( <> - {description &&
{description}
} - {trips.length > 0 && ( -
-
- {t('collections.library.inTrips')} -
- {trips.map(({ origin, detail }) => ( - onOpenTrip(origin.trip_id, origin.place_id)} - t={t} - /> - ))} -
- )} - {lists.length > 0 && ( -
-
- {t('collections.library.inLists')} -
- {lists.map(({ origin, detail }) => ( - onOpenList(origin.collection_id, origin.collection_place_id)} - t={t} - /> - ))} -
- )} + {/* Trips and lists side by side when the place is in both, so neither is pushed below the fold. */} +
+ {trips.length > 0 && ( +
+
+ {t('collections.library.inTrips')} +
+ {trips.map(({ origin, detail }) => ( + onOpenTrip(origin.trip_id, origin.place_id)} + t={t} + /> + ))} +
+ )} + {lists.length > 0 && ( +
+
+ {t('collections.library.inLists')} +
+ {lists.map(({ origin, detail }) => ( + onOpenList(origin.collection_id, origin.collection_place_id)} + t={t} + /> + ))} +
+ )} +
+ + + + + + ); } @@ -375,6 +384,7 @@ export default function LibraryPlaceDetail({ onOpenTrip, onSaveToList, onCopyToTrip, + onNotesSaved, t, }: LibraryPlaceDetailProps): React.ReactElement { const entry = data?.entry ?? null; @@ -396,6 +406,8 @@ export default function LibraryPlaceDetail({ )} {entry && ( void; + t: TranslationFn; +}): React.ReactElement | null { + const n = useOriginNotes({ data, onSaved, t }); + if (n.notes.length === 0 && n.targets.length === 0) return null; + return ( +
+
+ + {t('collections.notes')} + + {n.targets.length > 0 && ( + + )} +
+ {n.choosing && ( +
+ {n.targets.map((target) => ( + + ))} +
+ )} + {n.notes.map((note) => ( +
+ + {note.kind === 'trip' ? : } + {note.source} + {note.canEdit && n.editing !== note.key && ( + + + + )} + + {n.editing === note.key ? ( + <> +