From 01d327b50299f786c5e0dcbd9e016ed41a987e1e Mon Sep 17 00:00:00 2001
From: Maurice
Date: Sun, 29 Nov 2026 15:49:35 +0100
Subject: [PATCH] feat(places): Places replaces Collections, with All places,
place sheets and a calmer list
- Collections is Places now: /places opens "All places", every place of the
trips and lists with where it comes from, the same filter row (where from,
status, category, order), map bar (search, lock, list toggle) and place sheet
as a list; /places/saved and /places/:id are the lists, and the old
/collections links still land there. On the phone the same, with its own
sheet. A place sheet shows each trip (planned day or trip dates, stay,
booking, notes) and each list (status, labels, rating, notes) as one row
that opens it.
- The rail: a calm "New list" with its plus tile, All places and All saved as
views, a "My lists" heading, every name on one edge. Lists can carry one of
24 symbols, shown in their colour in the rail and the editor.
- A saved place's row keeps to two lines: its category as an icon before the
name, its average vote as a star on the picture. Map pins wear the same star.
- The place forms put the category in front of the name as a tile that opens
the category list, instead of a row of chips.
- All saved gets a subtitle; the import dialog opens centred.
- Fixes: a pasted coordinate pair splits from either field of the place form;
"more" in All places frees itself when a filter changes mid-load; place
names on the trip map and the rating badge follow the reading direction.
---
client/scripts/feature-pairs.json | 13 +
client/scripts/rtl-baseline.json | 4 +-
client/src/App.tsx | 31 +-
client/src/App.viewport.test.tsx | 4 +
client/src/api/collections.test.ts | 10 +-
.../Assistant/AssistantAskButton.test.tsx | 2 +-
.../collection/CollectionCardBlocks.test.tsx | 6 +-
.../collection/CollectionChangeSlots.test.tsx | 2 +-
.../cards/collection/collectionCardModel.ts | 5 +-
.../cards/collection/collectionLook.test.ts | 8 +-
.../AddPlaceToCollectionModal.test.tsx | 13 +-
.../Collections/AddPlaceToCollectionModal.tsx | 44 +-
.../components/Collections/CategoryBadge.tsx | 24 +
.../Collections/CategoryTileMenu.test.tsx | 102 +++++
.../Collections/CategoryTileMenu.tsx | 103 +++++
.../Collections/CollectionFilterBar.tsx | 69 +--
.../components/Collections/CollectionList.tsx | 23 +-
.../CollectionPlaceDetail.test.tsx | 28 +-
.../Collections/CollectionPlaceDetail.tsx | 29 +-
.../Collections/CollectionPlaceTags.tsx | 5 +-
.../Collections/FilterDropdown.test.tsx | 93 ++++
.../components/Collections/FilterDropdown.tsx | 80 ++++
.../Collections/ImportCollectionModal.tsx | 2 -
.../Collections/LegacyCollectionsRedirect.tsx | 8 +
.../Collections/LibraryFilterBar.test.tsx | 95 ++++
.../Collections/LibraryFilterBar.tsx | 99 ++++
.../Collections/LibraryOrigins.test.tsx | 54 +++
.../components/Collections/LibraryOrigins.tsx | 51 +++
.../Collections/LibraryPlaceDetail.test.tsx | 245 ++++++++++
.../Collections/LibraryPlaceDetail.tsx | 362 +++++++++++++++
.../Collections/ListEditorModal.test.tsx | 1 +
.../Collections/ListEditorModal.tsx | 31 +-
.../src/components/Collections/ListsRail.tsx | 51 ++-
.../MSaveToCollectionSheet.test.tsx | 4 +-
.../Collections/MapImportPreview.tsx | 5 +-
.../Collections/PlacesLibraryView.test.tsx | 360 +++++++++++++++
.../Collections/PlacesLibraryView.tsx | 305 +++++++++++++
.../SaveToCollectionModal.test.tsx | 4 +-
.../Collections/libraryDates.test.ts | 42 ++
.../components/Collections/libraryDates.ts | 49 ++
.../components/Collections/listIcons.test.ts | 14 +
.../src/components/Collections/listIcons.ts | 67 +++
.../Collections/useListEditor.test.ts | 14 +-
.../components/Collections/useListEditor.ts | 6 +
.../Collections/usePlacesLibrary.test.ts | 431 ++++++++++++++++++
.../Collections/usePlacesLibrary.ts | 249 ++++++++++
.../Collections/useSaveToCollection.test.ts | 2 +-
.../Collections/useSaveToCollection.ts | 3 +-
.../Dashboard/CollectionsWidget.tsx | 3 +-
client/src/components/Layout/BottomNav.tsx | 3 +-
client/src/components/Layout/Navbar.tsx | 3 +-
client/src/components/Layout/navItems.ts | 7 +-
.../Layout/useCreateAction.test.tsx | 10 +-
.../src/components/Layout/useCreateAction.ts | 8 +-
.../components/Map/placeNameLabels.test.ts | 45 +-
client/src/components/Map/placeNameLabels.ts | 36 +-
client/src/components/Map/placeNames.css | 3 +-
client/src/components/Map/ratingBadge.test.ts | 6 +-
client/src/components/Map/ratingBadge.ts | 31 +-
.../src/components/Map/usePlaceNameLayout.ts | 2 +-
.../components/Planner/PlaceFormLocation.tsx | 21 +-
.../collection/useSaveTourToCollection.ts | 3 +-
client/src/help/contexts/collections.ts | 2 +-
client/src/index.css | 3 +
.../src/mobile/components/MBottomNav.test.tsx | 12 +-
.../screens/collections/MCollAddSheet.tsx | 7 +-
.../collections/MCollCategoryPicker.tsx | 30 +-
.../screens/collections/MCollEditSheet.tsx | 24 +-
.../screens/collections/MCollFilterKit.tsx | 57 +++
.../screens/collections/MCollListNav.tsx | 38 +-
.../screens/collections/MCollPlaceSheet.tsx | 6 +-
.../screens/collections/MCollections.tsx | 63 +--
.../collections/MLibraryPlaceSheet.tsx | 338 ++++++++++++++
.../screens/collections/MPlacesLibrary.tsx | 400 ++++++++++++++++
.../mobile/screens/dashboard/MDashWidgets.tsx | 5 +-
client/src/pages/CollectionsPage.tsx | 56 ++-
client/src/pages/DashboardPage.tsx | 3 +-
.../pages/collections/useCollections.test.tsx | 41 +-
.../src/pages/collections/useCollections.ts | 37 +-
client/src/repo/placesLibraryRepo.test.ts | 26 +-
client/src/repo/placesLibraryRepo.ts | 12 +
client/src/styles/collections.css | 61 ++-
client/src/types.ts | 2 -
client/src/utils/placesRoutes.test.ts | 20 +
client/src/utils/placesRoutes.ts | 21 +
client/src/utils/resumeRoute.ts | 2 +-
client/tests/helpers/placesLibrary.ts | 192 ++++++++
client/tests/unit/mobile/MBottomNav.test.tsx | 4 +-
.../mobile/collections/MCollAddSheet.test.tsx | 2 +-
.../collections/MCollCategoryPicker.test.tsx | 17 +-
.../collections/MCollFilterKit.test.tsx | 40 ++
.../mobile/collections/MCollections.test.tsx | 10 +-
.../collections/MLibraryPlaceSheet.test.tsx | 243 ++++++++++
.../collections/MPlacesLibrary.test.tsx | 339 ++++++++++++++
.../mobile/dashboard/MDashWidgets.test.tsx | 4 +-
shared/src/i18n/ar/admin.ts | 5 +-
shared/src/i18n/ar/collection.ts | 47 +-
shared/src/i18n/ar/mobileNav.ts | 2 +-
shared/src/i18n/az/admin.ts | 4 +-
shared/src/i18n/az/collection.ts | 35 +-
shared/src/i18n/az/mobileNav.ts | 2 +-
shared/src/i18n/br/admin.ts | 5 +-
shared/src/i18n/br/collection.ts | 35 +-
shared/src/i18n/br/mobileNav.ts | 2 +-
shared/src/i18n/ca/admin.ts | 5 +-
shared/src/i18n/ca/collection.ts | 35 +-
shared/src/i18n/ca/mobileNav.ts | 2 +-
shared/src/i18n/cs/admin.ts | 4 +-
shared/src/i18n/cs/collection.ts | 38 +-
shared/src/i18n/cs/mobileNav.ts | 2 +-
shared/src/i18n/de/admin.ts | 4 +-
shared/src/i18n/de/collection.ts | 47 +-
shared/src/i18n/de/mobileNav.ts | 2 +-
shared/src/i18n/en/admin.ts | 5 +-
shared/src/i18n/en/collection.ts | 42 +-
shared/src/i18n/en/mobileNav.ts | 2 +-
shared/src/i18n/es/admin.ts | 4 +-
shared/src/i18n/es/collection.ts | 35 +-
shared/src/i18n/es/mobileNav.ts | 2 +-
shared/src/i18n/et/admin.ts | 4 +-
shared/src/i18n/et/collection.ts | 35 +-
shared/src/i18n/et/mobileNav.ts | 2 +-
shared/src/i18n/fr/admin.ts | 4 +-
shared/src/i18n/fr/collection.ts | 35 +-
shared/src/i18n/fr/mobileNav.ts | 2 +-
shared/src/i18n/gr/admin.ts | 4 +-
shared/src/i18n/gr/collection.ts | 35 +-
shared/src/i18n/gr/mobileNav.ts | 2 +-
shared/src/i18n/he/admin.ts | 5 +-
shared/src/i18n/he/collection.ts | 38 +-
shared/src/i18n/he/mobileNav.ts | 2 +-
shared/src/i18n/hu/admin.ts | 4 +-
shared/src/i18n/hu/collection.ts | 35 +-
shared/src/i18n/hu/mobileNav.ts | 2 +-
shared/src/i18n/id/admin.ts | 4 +-
shared/src/i18n/id/collection.ts | 32 +-
shared/src/i18n/id/mobileNav.ts | 2 +-
shared/src/i18n/it/admin.ts | 4 +-
shared/src/i18n/it/collection.ts | 35 +-
shared/src/i18n/it/mobileNav.ts | 2 +-
shared/src/i18n/ja/admin.ts | 5 +-
shared/src/i18n/ja/collection.ts | 32 +-
shared/src/i18n/ja/mobileNav.ts | 2 +-
shared/src/i18n/ko/admin.ts | 5 +-
shared/src/i18n/ko/collection.ts | 32 +-
shared/src/i18n/ko/mobileNav.ts | 2 +-
shared/src/i18n/nl/admin.ts | 4 +-
shared/src/i18n/nl/collection.ts | 35 +-
shared/src/i18n/nl/mobileNav.ts | 2 +-
shared/src/i18n/pl/admin.ts | 4 +-
shared/src/i18n/pl/collection.ts | 41 +-
shared/src/i18n/pl/mobileNav.ts | 2 +-
shared/src/i18n/ru/admin.ts | 4 +-
shared/src/i18n/ru/collection.ts | 41 +-
shared/src/i18n/ru/mobileNav.ts | 2 +-
shared/src/i18n/sk/admin.ts | 4 +-
shared/src/i18n/sk/collection.ts | 38 +-
shared/src/i18n/sk/mobileNav.ts | 2 +-
shared/src/i18n/sv/admin.ts | 5 +-
shared/src/i18n/sv/collection.ts | 35 +-
shared/src/i18n/sv/mobileNav.ts | 2 +-
shared/src/i18n/th/admin.ts | 5 +-
shared/src/i18n/th/collection.ts | 32 +-
shared/src/i18n/th/mobileNav.ts | 2 +-
shared/src/i18n/tr/admin.ts | 4 +-
shared/src/i18n/tr/collection.ts | 35 +-
shared/src/i18n/tr/mobileNav.ts | 2 +-
shared/src/i18n/uk/admin.ts | 4 +-
shared/src/i18n/uk/collection.ts | 41 +-
shared/src/i18n/uk/mobileNav.ts | 2 +-
shared/src/i18n/vi/admin.ts | 5 +-
shared/src/i18n/vi/collection.ts | 32 +-
shared/src/i18n/vi/mobileNav.ts | 2 +-
shared/src/i18n/zh-TW/admin.ts | 5 +-
shared/src/i18n/zh-TW/collection.ts | 32 +-
shared/src/i18n/zh-TW/mobileNav.ts | 2 +-
shared/src/i18n/zh/admin.ts | 5 +-
shared/src/i18n/zh/collection.ts | 32 +-
shared/src/i18n/zh/mobileNav.ts | 2 +-
179 files changed, 6206 insertions(+), 541 deletions(-)
create mode 100644 client/src/components/Collections/CategoryBadge.tsx
create mode 100644 client/src/components/Collections/CategoryTileMenu.test.tsx
create mode 100644 client/src/components/Collections/CategoryTileMenu.tsx
create mode 100644 client/src/components/Collections/FilterDropdown.test.tsx
create mode 100644 client/src/components/Collections/FilterDropdown.tsx
create mode 100644 client/src/components/Collections/LegacyCollectionsRedirect.tsx
create mode 100644 client/src/components/Collections/LibraryFilterBar.test.tsx
create mode 100644 client/src/components/Collections/LibraryFilterBar.tsx
create mode 100644 client/src/components/Collections/LibraryOrigins.test.tsx
create mode 100644 client/src/components/Collections/LibraryOrigins.tsx
create mode 100644 client/src/components/Collections/LibraryPlaceDetail.test.tsx
create mode 100644 client/src/components/Collections/LibraryPlaceDetail.tsx
create mode 100644 client/src/components/Collections/PlacesLibraryView.test.tsx
create mode 100644 client/src/components/Collections/PlacesLibraryView.tsx
create mode 100644 client/src/components/Collections/libraryDates.test.ts
create mode 100644 client/src/components/Collections/libraryDates.ts
create mode 100644 client/src/components/Collections/listIcons.test.ts
create mode 100644 client/src/components/Collections/listIcons.ts
create mode 100644 client/src/components/Collections/usePlacesLibrary.test.ts
create mode 100644 client/src/components/Collections/usePlacesLibrary.ts
create mode 100644 client/src/mobile/screens/collections/MCollFilterKit.tsx
create mode 100644 client/src/mobile/screens/collections/MLibraryPlaceSheet.tsx
create mode 100644 client/src/mobile/screens/collections/MPlacesLibrary.tsx
create mode 100644 client/src/utils/placesRoutes.test.ts
create mode 100644 client/src/utils/placesRoutes.ts
create mode 100644 client/tests/helpers/placesLibrary.ts
create mode 100644 client/tests/unit/mobile/collections/MCollFilterKit.test.tsx
create mode 100644 client/tests/unit/mobile/collections/MLibraryPlaceSheet.test.tsx
create mode 100644 client/tests/unit/mobile/collections/MPlacesLibrary.test.tsx
diff --git a/client/scripts/feature-pairs.json b/client/scripts/feature-pairs.json
index d5a6c160e..19fe7a7f7 100644
--- a/client/scripts/feature-pairs.json
+++ b/client/scripts/feature-pairs.json
@@ -303,6 +303,18 @@
"desktop": ["src/components/Collections/CollectionLocationSearch.tsx"],
"mobile": ["src/mobile/screens/collections/MCollLocationSearch.tsx"]
},
+ {
+ "feature": "Places: a place of all places",
+ "hooks": ["src/components/Collections/libraryDates.ts"],
+ "desktop": ["src/components/Collections/LibraryPlaceDetail.tsx"],
+ "mobile": ["src/mobile/screens/collections/MLibraryPlaceSheet.tsx"]
+ },
+ {
+ "feature": "Places: all places",
+ "hooks": ["src/components/Collections/usePlacesLibrary.ts"],
+ "desktop": ["src/components/Collections/PlacesLibraryView.tsx"],
+ "mobile": ["src/mobile/screens/collections/MPlacesLibrary.tsx"]
+ },
{
"feature": "Collection sharing",
"hooks": ["src/components/Collections/useCollectionSharing.ts"],
@@ -1132,6 +1144,7 @@
}
],
"mobileOnly": {
+ "src/mobile/screens/collections/MCollFilterKit.tsx": "Markup only: the filter chips, dropdown rows and empty note the phone's lists and all-places screens share; the desktop draws its own filter row (FilterDropdown).",
"src/mobile/screens/trip/sheets/MReviewNotice.tsx": "The transport sheet's row asking for a look at an imported booking; the desktop dialog folds the same \"looks right\" action into its review pill (ReviewPill in bookingParts.tsx), so there is no separate twin.",
"src/mobile/screens/mail/MMailInboxHost.tsx": "Mounts the phone shell's one inbox sheet and reads the person's import settings; the desktop mounts its dialog from the Navbar, so there is no twin.",
"src/mobile/screens/admin/MAdminOidcCard.tsx": "Markup only; the OIDC card of MAdminSettingsSection, with the form state from useAdmin and the save from its useAdminSettingsActions handed in through props.",
diff --git a/client/scripts/rtl-baseline.json b/client/scripts/rtl-baseline.json
index 62b7815b6..c32868824 100644
--- a/client/scripts/rtl-baseline.json
+++ b/client/scripts/rtl-baseline.json
@@ -24,8 +24,8 @@
"components/Map/DawarichTrailPill.tsx": 1,
"components/Map/LocationButton.tsx": 1,
"components/Map/MapTogglePill.tsx": 1,
- "components/Map/MapView.tsx": 5,
- "components/Map/MapViewGL.tsx": 7,
+ "components/Map/MapView.tsx": 4,
+ "components/Map/MapViewGL.tsx": 6,
"components/Map/NightPauseTooltip.tsx": 1,
"components/Map/PlaceHoverCard.tsx": 1,
"components/Map/PoiCategoryPill.tsx": 1,
diff --git a/client/src/App.tsx b/client/src/App.tsx
index d7f64da73..f4f474b23 100644
--- a/client/src/App.tsx
+++ b/client/src/App.tsx
@@ -1,5 +1,6 @@
import React, { useEffect, useLayoutEffect, useState, useRef, ReactNode, Suspense } from 'react'
import { Routes, Route, Navigate, useLocation, useNavigationType } from 'react-router'
+import LegacyCollectionsRedirect from './components/Collections/LegacyCollectionsRedirect'
import { useAuthStore } from './store/authStore'
import { useSettingsStore } from './store/settingsStore'
import { applyAppearance } from './theme/applyAppearance'
@@ -637,22 +638,20 @@ export default function App() {
journey, not navigated away to. */}
} />
-
-
-
- }
- />
-
-
-
- }
- />
+ {['/places', '/places/saved', '/places/:id'].map(path => (
+
+
+
+ }
+ />
+ ))}
+ {/* Collections became Places (PLC-07); the old links keep working. */}
+ } />
+ } />
{
folders: ['Views'],
skipped: [{ name: 'Tram 28', folder: null, reason: 'line' }],
}
- let upload: File | null = null
+ let contentType: string | null = null
server.use(
- http.post(`${BASE}/map/read`, async ({ request }) => {
- upload = (await request.formData()).get('file') as File | null
+ // jsdom cannot read a multipart body back, so the header says what was sent.
+ http.post(`${BASE}/map/read`, ({ request }) => {
+ contentType = request.headers.get('content-type')
return HttpResponse.json(read)
}),
)
const res = await collectionsApi.readMap(new File([''], 'lisbon.kml'))
- expect(upload).not.toBeNull()
- expect((upload as unknown as File).name).toBe('lisbon.kml')
+ expect(contentType).toMatch(/^multipart\/form-data/)
expect(res).toEqual(read)
})
})
diff --git a/client/src/components/Assistant/AssistantAskButton.test.tsx b/client/src/components/Assistant/AssistantAskButton.test.tsx
index b094e2365..862f4deae 100644
--- a/client/src/components/Assistant/AssistantAskButton.test.tsx
+++ b/client/src/components/Assistant/AssistantAskButton.test.tsx
@@ -50,7 +50,7 @@ describe('AssistantAskButton', () => {
expect(screen.queryByRole('button')).not.toBeInTheDocument();
unmount();
- renderAt('/collections/3');
+ renderAt('/places/3');
expect(screen.queryByRole('button')).not.toBeInTheDocument();
});
});
diff --git a/client/src/components/Assistant/cards/collection/CollectionCardBlocks.test.tsx b/client/src/components/Assistant/cards/collection/CollectionCardBlocks.test.tsx
index 0188a6a32..7140a1c40 100644
--- a/client/src/components/Assistant/cards/collection/CollectionCardBlocks.test.tsx
+++ b/client/src/components/Assistant/cards/collection/CollectionCardBlocks.test.tsx
@@ -54,7 +54,7 @@ describe('collection answer cards', () => {
expect(within(card).getByText('Idea')).toBeInTheDocument();
expect(within(card).getByText('3')).toBeInTheDocument();
fireEvent.click(within(card).getByRole('button', { name: /Open list/ }));
- expect(view.onOpen).toHaveBeenCalledWith({ kind: 'page', path: '/collections/12' });
+ expect(view.onOpen).toHaveBeenCalledWith({ kind: 'page', path: '/places/12' });
});
it('FE-AI-COLL-040: the places to revisit have a pill of their own in the head, in the visited tone (#2567)', () => {
@@ -86,7 +86,7 @@ describe('collection answer cards', () => {
expect(screen.getByText('Spot 4')).toBeInTheDocument();
expect(screen.queryByText('Spot 5')).toBeNull();
fireEvent.click(screen.getByRole('button', { name: '7 more in this list' }));
- expect(view.onOpen).toHaveBeenCalledWith({ kind: 'page', path: '/collections/12' });
+ expect(view.onOpen).toHaveBeenCalledWith({ kind: 'page', path: '/places/12' });
});
it('FE-AI-COLL-013: a roomy chat shows eight rows', () => {
@@ -144,7 +144,7 @@ describe('collection answer cards', () => {
expect(screen.queryByText('Paris food')).toBeNull();
expect(screen.getByText('Invite from Maya')).toBeInTheDocument();
fireEvent.click(screen.getByRole('button', { name: /Rome/ }));
- expect(view.onOpen).toHaveBeenCalledWith({ kind: 'page', path: '/collections/40' });
+ expect(view.onOpen).toHaveBeenCalledWith({ kind: 'page', path: '/places/40' });
});
it('FE-AI-COLL-018: where a place is saved reads as its lists with its status in each', () => {
diff --git a/client/src/components/Assistant/cards/collection/CollectionChangeSlots.test.tsx b/client/src/components/Assistant/cards/collection/CollectionChangeSlots.test.tsx
index aa83c4d2b..c42d21630 100644
--- a/client/src/components/Assistant/cards/collection/CollectionChangeSlots.test.tsx
+++ b/client/src/components/Assistant/cards/collection/CollectionChangeSlots.test.tsx
@@ -94,7 +94,7 @@ describe('collection change cards', () => {
const view = draw([applied(pending('save_place_to_collection', 'Septime', card), 'collection_place', [77])]);
expect(screen.queryByRole('button', { name: 'Show on map' })).toBeNull();
fireEvent.click(screen.getByRole('button', { name: 'Open in Collections' }));
- expect(view.onOpen).toHaveBeenCalledWith({ kind: 'page', path: '/collections/12?place=77' });
+ expect(view.onOpen).toHaveBeenCalledWith({ kind: 'page', path: '/places/12?place=77' });
});
it('FE-AI-COLL-023: a save the place matched already says where it is saved', () => {
diff --git a/client/src/components/Assistant/cards/collection/collectionCardModel.ts b/client/src/components/Assistant/cards/collection/collectionCardModel.ts
index 1f02961da..e0ede3662 100644
--- a/client/src/components/Assistant/cards/collection/collectionCardModel.ts
+++ b/client/src/components/Assistant/cards/collection/collectionCardModel.ts
@@ -8,6 +8,7 @@ import type {
TrekCard,
} from '@trek/shared';
+import { placesPath } from '../../../../utils/placesRoutes';
import type { EntityTarget } from '../cardTypes';
/**
@@ -26,12 +27,12 @@ export const MAX_FACTS = 4;
/** Where a list opens in Collections. */
export function listTarget(listId: number | null): EntityTarget {
- return { kind: 'page', path: listId === null ? '/collections' : `/collections/${listId}` };
+ return { kind: 'page', path: placesPath(listId === null ? 'saved' : listId) };
}
/** Where a saved place opens: its list, with the place selected. */
function placeTarget(listId: number, placeId: number | null): EntityTarget {
- const path = `/collections/${listId}`;
+ const path = placesPath(listId);
return { kind: 'page', path: placeId === null ? path : `${path}?place=${placeId}` };
}
diff --git a/client/src/components/Assistant/cards/collection/collectionLook.test.ts b/client/src/components/Assistant/cards/collection/collectionLook.test.ts
index b0fe99c63..3d2e43260 100644
--- a/client/src/components/Assistant/cards/collection/collectionLook.test.ts
+++ b/client/src/components/Assistant/cards/collection/collectionLook.test.ts
@@ -62,9 +62,9 @@ describe('collection look', () => {
it('FE-AI-COLL-002: an applied list opens in Collections, unless the change deleted it or declined its invite', () => {
const look = ENTITY_LOOK.collection;
expect(look.openLabelKey).toBe('assistant.card.collection.openList');
- expect(look.open?.(applied('collection', [12]), null)).toEqual({ kind: 'page', path: '/collections/12' });
+ expect(look.open?.(applied('collection', [12]), null)).toEqual({ kind: 'page', path: '/places/12' });
const card = listsCard({ lists: [listRow({ id: 13 })] });
- expect(look.open?.(applied('collection', []), card)).toEqual({ kind: 'page', path: '/collections/13' });
+ expect(look.open?.(applied('collection', []), card)).toEqual({ kind: 'page', path: '/places/13' });
for (const change of ['remove', 'decline'] as const) {
expect(look.open?.(applied('collection', [12]), listsCard({ lists: [listRow({ change })] }))).toBeNull();
}
@@ -76,10 +76,10 @@ describe('collection look', () => {
const card = placesCard();
expect(look.open?.(applied('collection_place', [34]), card)).toEqual({
kind: 'page',
- path: '/collections/12?place=34',
+ path: '/places/12?place=34',
});
const removed = placesCard({ places: [savedPlace({ delta: emptyDelta({ removed: true }) })] });
- expect(look.open?.(applied('collection_place', [34]), removed)).toEqual({ kind: 'page', path: '/collections/12' });
+ expect(look.open?.(applied('collection_place', [34]), removed)).toEqual({ kind: 'page', path: '/places/12' });
expect(look.open?.(applied('collection_place', [34]), null)).toBeNull();
});
diff --git a/client/src/components/Collections/AddPlaceToCollectionModal.test.tsx b/client/src/components/Collections/AddPlaceToCollectionModal.test.tsx
index 161521f80..ea2bf3370 100644
--- a/client/src/components/Collections/AddPlaceToCollectionModal.test.tsx
+++ b/client/src/components/Collections/AddPlaceToCollectionModal.test.tsx
@@ -308,13 +308,17 @@ describe('AddPlaceToCollectionModal', () => {
it('FE-COMP-ADDPLACECOL-018: a category can be picked and cleared again', async () => {
setup()
typeName('Manual spot')
- fireEvent.click(screen.getByRole('button', { name: /Food/ }))
- fireEvent.click(screen.getByRole('button', { name: /Museum/ }))
+ // The category is the tile in front of the name; it opens the list to pick from.
+ fireEvent.click(screen.getByRole('button', { name: 'Category: No category' }))
+ fireEvent.click(screen.getByRole('option', { name: 'Food' }))
+ fireEvent.click(screen.getByRole('button', { name: 'Category: Food' }))
+ fireEvent.click(screen.getByRole('option', { name: 'Museum' }))
fireEvent.click(screen.getByRole('button', { name: /Add$/ }))
await waitFor(() => expect(savedBodies).toHaveLength(1))
expect(savedBodies[0]).toMatchObject({ category_id: 4 })
- fireEvent.click(screen.getByRole('button', { name: 'No category' }))
+ fireEvent.click(screen.getByRole('button', { name: /^Category: / }))
+ fireEvent.click(screen.getByRole('option', { name: 'No category' }))
typeName('Second spot')
fireEvent.click(screen.getByRole('button', { name: /Add$/ }))
await waitFor(() => expect(savedBodies).toHaveLength(2))
@@ -323,8 +327,7 @@ describe('AddPlaceToCollectionModal', () => {
it('FE-COMP-ADDPLACECOL-019: without categories the category row is not rendered', () => {
setup({ categories: [] })
- expect(screen.queryByText('Category')).not.toBeInTheDocument()
- expect(screen.queryByRole('button', { name: 'No category' })).not.toBeInTheDocument()
+ expect(screen.queryByRole('button', { name: /^Category: / })).not.toBeInTheDocument()
})
it('FE-COMP-ADDPLACECOL-020: links are normalised and blank rows dropped', async () => {
diff --git a/client/src/components/Collections/AddPlaceToCollectionModal.tsx b/client/src/components/Collections/AddPlaceToCollectionModal.tsx
index 661489cb5..562c5689c 100644
--- a/client/src/components/Collections/AddPlaceToCollectionModal.tsx
+++ b/client/src/components/Collections/AddPlaceToCollectionModal.tsx
@@ -7,13 +7,13 @@ import { DialogButton, DialogFooter, DialogHeader, DialogSection, DialogShell, D
import { AddRowButton, EditorField, INPUT, Segmented, TEXTAREA } from '../shared/dialogParts'
import NoteFormatToolbar from '../shared/NoteFormatToolbar'
import { Tooltip } from '../shared/Tooltip'
-import { getCategoryIcon } from '../shared/categoryIcons'
import { normalizeLinkUrl, STATUS_META, STATUS_ORDER } from '../../pages/collections/collectionsModel'
import type { Category, TranslationFn } from '../../types'
import type { CollectionStatus } from '@trek/shared'
import { str } from './addPlaceModel'
import { useAddPlaceToCollection } from './useAddPlaceToCollection'
import { PlaceFormLocation } from '../Planner/PlaceFormLocation'
+import CategoryTileMenu from './CategoryTileMenu'
/**
* The search row, pinned to the top of the scrolling body. The dialog stays open
@@ -22,10 +22,6 @@ import { PlaceFormLocation } from '../Planner/PlaceFormLocation'
* margins let its background cover the body's padding while it is stuck.
*/
const STICKY_SEARCH = 'sticky top-0 z-20 -mx-6 -mt-5 bg-surface-card px-6 pb-4 pt-5'
-/** A chip of the category row; the picked one wears the category's own colour. */
-const CHIP = 'inline-flex items-center gap-1.5 rounded-full border px-3 py-1 font-semibold'
-const CHIP_OFF = 'border-edge-faint bg-surface-card text-content-muted hover:text-content'
-const CHIP_NONE_ON = 'border-content bg-surface-card text-content'
const ROW_ACTION = 'grid h-8 w-8 flex-none place-items-center rounded-[9px] text-content-faint hover:bg-surface-secondary'
interface AddPlaceToCollectionModalProps {
@@ -65,7 +61,10 @@ export default function AddPlaceToCollectionModal({ isOpen, collectionId, collec
const header = (
}
+ // The category is the tile in front of the name: one tap picks it, no chip row below.
+ tile={categories.length > 0
+ ?
+ : }
tint={NEUTRAL_TINT}
labelId={labelId}
onClose={onClose}
@@ -178,39 +177,6 @@ export default function AddPlaceToCollectionModal({ isOpen, collectionId, collec
/>
- {categories.length > 0 && (
-
-
-
- {categories.map(cat => {
- const Icon = getCategoryIcon(cat.icon ?? undefined)
- const on = categoryId === cat.id
- const col = cat.color || '#6366f1' // theme-lint-disable: the category's own colour, and the default one without a colour is drawn in
- return (
-
- )
- })}
-
-
- )}
-
{t('collections.description')}}
action={}
diff --git a/client/src/components/Collections/CategoryBadge.tsx b/client/src/components/Collections/CategoryBadge.tsx
new file mode 100644
index 000000000..386daca09
--- /dev/null
+++ b/client/src/components/Collections/CategoryBadge.tsx
@@ -0,0 +1,24 @@
+import React from 'react';
+import { getCategoryIcon } from '../shared/categoryIcons';
+import { Tooltip } from '../shared/Tooltip';
+
+/** A place's category as its icon in its colour, in front of the name; the tooltip names it. */
+export default function CategoryBadge({
+ category,
+}: {
+ category: { name?: string | null; color?: string | null; icon?: string | null };
+}): React.ReactElement {
+ const Icon = getCategoryIcon(category.icon ?? undefined);
+ return (
+
+
+
+
+
+ );
+}
diff --git a/client/src/components/Collections/CategoryTileMenu.test.tsx b/client/src/components/Collections/CategoryTileMenu.test.tsx
new file mode 100644
index 000000000..7c7010096
--- /dev/null
+++ b/client/src/components/Collections/CategoryTileMenu.test.tsx
@@ -0,0 +1,102 @@
+// FE-COMP-CATTILEMENU-001 to FE-COMP-CATTILEMENU-007
+import userEvent from '@testing-library/user-event';
+import React from 'react';
+
+import { fireEvent, render, screen, within } from '../../../tests/helpers/render';
+import { useTranslation } from '../../i18n/TranslationContext';
+import type { Category } from '../../types';
+import CategoryTileMenu from './CategoryTileMenu';
+
+const CATEGORIES = [
+ { id: 3, name: 'Restaurant', color: '#E8843D', icon: 'Utensils' },
+ { id: 5, name: 'Museum', color: null, icon: null },
+] as unknown as Category[];
+
+type Props = Omit, 't' | 'categories' | 'onChange'>;
+
+function Harness(props: Props & { onChange: (id: number | null) => void }): React.ReactElement {
+ const { t } = useTranslation();
+ return ;
+}
+
+function setup(props: Partial = {}) {
+ const onChange = vi.fn<(id: number | null) => void>();
+ render();
+ return { onChange };
+}
+
+describe('CategoryTileMenu', () => {
+ it('FE-COMP-CATTILEMENU-001: without a category the tile says so and is closed', () => {
+ setup();
+ const tile = screen.getByRole('button', { name: 'Category: No category' });
+ expect(tile).toHaveAttribute('aria-expanded', 'false');
+ expect(tile).toHaveAttribute('title', 'Category: No category');
+ expect(tile).toHaveStyle({ width: '46px', height: '46px' });
+ expect(screen.queryByRole('listbox')).not.toBeInTheDocument();
+ });
+
+ it('FE-COMP-CATTILEMENU-002: a category names itself on the tile in the size asked for', () => {
+ setup({ value: 3, size: 40 });
+ const tile = screen.getByRole('button', { name: 'Category: Restaurant' });
+ expect(tile).toHaveStyle({ width: '40px', height: '40px' });
+ expect(tile).not.toHaveClass('bg-surface-card');
+ });
+
+ it('FE-COMP-CATTILEMENU-003: a value with no category behind it reads as none', () => {
+ setup({ value: 99 });
+ expect(screen.getByRole('button', { name: 'Category: No category' })).toHaveClass('bg-surface-card');
+ });
+
+ it('FE-COMP-CATTILEMENU-004: the list offers "No category" and every category, the current one selected', async () => {
+ const user = userEvent.setup();
+ setup({ value: 5 });
+ await user.click(screen.getByRole('button', { name: 'Category: Museum' }));
+ const list = screen.getByRole('listbox', { name: 'Category' });
+ const options = within(list).getAllByRole('option');
+ expect(options.map((o) => o.textContent)).toEqual(['No category', 'Restaurant', 'Museum']);
+ expect(options[2]).toHaveAttribute('aria-selected', 'true');
+ expect(options[0]).toHaveAttribute('aria-selected', 'false');
+ });
+
+ it('FE-COMP-CATTILEMENU-005: picking a category or none reports it and closes the list', async () => {
+ const user = userEvent.setup();
+ const { onChange } = setup({ value: 3 });
+ const tile = screen.getByRole('button', { name: 'Category: Restaurant' });
+
+ await user.click(tile);
+ await user.click(screen.getByRole('option', { name: 'Museum' }));
+ expect(onChange).toHaveBeenLastCalledWith(5);
+ expect(screen.queryByRole('listbox')).not.toBeInTheDocument();
+
+ await user.click(tile);
+ await user.click(screen.getByRole('option', { name: 'No category' }));
+ expect(onChange).toHaveBeenLastCalledWith(null);
+ });
+
+ it('FE-COMP-CATTILEMENU-006: Escape closes the list and goes no further, so the dialog around it stays', async () => {
+ const user = userEvent.setup();
+ setup();
+ await user.click(screen.getByRole('button', { name: 'Category: No category' }));
+ const outer = vi.fn();
+ document.body.addEventListener('keydown', outer);
+
+ fireEvent.keyDown(screen.getByRole('listbox'), { key: 'Escape' });
+ expect(screen.queryByRole('listbox')).not.toBeInTheDocument();
+ expect(outer).not.toHaveBeenCalled();
+ document.body.removeEventListener('keydown', outer);
+ });
+
+ it('FE-COMP-CATTILEMENU-007: a press outside closes it, a press inside and other keys do not', async () => {
+ const user = userEvent.setup();
+ setup();
+ const tile = screen.getByRole('button', { name: 'Category: No category' });
+ await user.click(tile);
+ fireEvent.mouseDown(screen.getByRole('listbox'));
+ fireEvent.keyDown(document, { key: 'ArrowDown' });
+ expect(screen.getByRole('listbox')).toBeInTheDocument();
+
+ fireEvent.mouseDown(document.body);
+ expect(screen.queryByRole('listbox')).not.toBeInTheDocument();
+ expect(tile).toHaveAttribute('aria-expanded', 'false');
+ });
+});
diff --git a/client/src/components/Collections/CategoryTileMenu.tsx b/client/src/components/Collections/CategoryTileMenu.tsx
new file mode 100644
index 000000000..3734ed5d1
--- /dev/null
+++ b/client/src/components/Collections/CategoryTileMenu.tsx
@@ -0,0 +1,103 @@
+import { Check, Shapes } from 'lucide-react';
+import React, { useEffect, useRef, useState } from 'react';
+import type { Category, TranslationFn } from '../../types';
+import { getCategoryIcon } from '../shared/categoryIcons';
+
+interface CategoryTileMenuProps {
+ categories: Category[];
+ value: number | null;
+ onChange: (id: number | null) => void;
+ /** The tile's side in pixels: 46 in a dialog's head band, 40 beside the sheet's name field. */
+ size?: number;
+ t: TranslationFn;
+}
+
+/**
+ * The place's category as the tile in front of its name: its icon in its colour,
+ * and a tap opens the list to pick another. It replaces the row of category chips
+ * the forms had, so the category reads as part of the place and the form loses a row.
+ */
+export default function CategoryTileMenu({
+ categories,
+ value,
+ onChange,
+ size = 46,
+ t,
+}: CategoryTileMenuProps): React.ReactElement {
+ const [open, setOpen] = useState(false);
+ const ref = useRef(null);
+ useEffect(() => {
+ if (!open) return;
+ const onDoc = (e: MouseEvent) => {
+ if (ref.current && !ref.current.contains(e.target as Node)) setOpen(false);
+ };
+ const onKey = (e: KeyboardEvent) => {
+ if (e.key === 'Escape') {
+ e.stopPropagation();
+ setOpen(false);
+ }
+ };
+ document.addEventListener('mousedown', onDoc);
+ document.addEventListener('keydown', onKey, true);
+ return () => {
+ document.removeEventListener('mousedown', onDoc);
+ document.removeEventListener('keydown', onKey, true);
+ };
+ }, [open]);
+
+ const current = value != null ? (categories.find((c) => c.id === value) ?? null) : null;
+ const Icon = current ? getCategoryIcon(current.icon ?? undefined) : Shapes;
+ const tone = current?.color || null;
+ const label = `${t('collections.category')}: ${current?.name ?? t('collections.noCategory')}`;
+
+ return (
+
- )
-}
+import FilterDropdown, { type FilterOption as Opt } from './FilterDropdown'
interface CollectionFilterBarProps {
statusFilter: StatusFilter
@@ -146,12 +91,12 @@ export default function CollectionFilterBar({
)}
- onStatusFilter(k as StatusFilter)} lead={} />
+ onStatusFilter(k as StatusFilter)} lead={} />
{categoryOptions.length > 0 && (
- onCategoryFilter(k as number | 'all')} lead={} />
+ onCategoryFilter(k as number | 'all')} lead={} />
)}
- onRatingFilter(k as number | 'all')} lead={} />
- onSortMode(k as CollectionSortMode)} lead={} />
+ onRatingFilter(k as number | 'all')} lead={} />
+ onSortMode(k as CollectionSortMode)} lead={} />
{showSelect && (
)}
- {t('collections.category').toUpperCase()}
- {t('mobileCollections.status').toUpperCase()}
{/* Two by two on a phone, so every status label keeps its room */}
diff --git a/client/src/mobile/screens/collections/MCollCategoryPicker.tsx b/client/src/mobile/screens/collections/MCollCategoryPicker.tsx
index f36c500e1..3804383c0 100644
--- a/client/src/mobile/screens/collections/MCollCategoryPicker.tsx
+++ b/client/src/mobile/screens/collections/MCollCategoryPicker.tsx
@@ -1,4 +1,4 @@
-import { useState } from 'react'
+import { useState, type ReactNode } from 'react'
import { Check, ChevronDown, ChevronUp } from 'lucide-react'
import type { Category, TranslationFn } from '../../../types'
import { categoryMeta, NO_CATEGORY_META, tint } from './collectionsMobileModel'
@@ -7,6 +7,13 @@ interface MCollCategoryPickerProps {
categories: Category[]
value: number | null
onChange: (id: number | null) => void
+ /**
+ * `tile` puts the category in front of the place's name as a tinted tile, with the
+ * name field (the children) beside it: the category belongs to the place, and the
+ * form loses a whole row. `row` is the full-width trigger.
+ */
+ variant?: 'row' | 'tile'
+ children?: ReactNode
t: TranslationFn
}
@@ -14,7 +21,7 @@ interface MCollCategoryPickerProps {
* Category dropdown of the add/edit-place sheets: a trigger row with the tinted
* 26px icon chip and an overlay list of "No category" + the admin categories.
*/
-export default function MCollCategoryPicker({ categories, value, onChange, t }: MCollCategoryPickerProps) {
+export default function MCollCategoryPicker({ categories, value, onChange, variant = 'row', children, t }: MCollCategoryPickerProps) {
const [open, setOpen] = useState(false)
const selected = value != null ? categories.find(c => c.id === value) ?? null : null
@@ -27,8 +34,18 @@ export default function MCollCategoryPicker({ categories, value, onChange, t }:
...categories.map(c => ({ id: c.id, name: c.name })),
]
- return (
-