feat(collections): add places by coordinates + sort A–Z (#1647)

* feat(collections): add places by coordinates and sort the list

Raised in #1640: collections behaved differently from trips — you
couldn't add a place by typing coordinates, and the list had no order
control.

The add-place modal and the place detail sheet now take an editable
address plus latitude/longitude, with a "lat, lng" paste shortcut, so a
place can be saved by GPS without searching. The place update path
learned to persist coordinates, so an existing one can be corrected
later.

A sort control in the filter row toggles between the saved order and
alphabetical by name. The add-place button moved into that row to match
the other controls, and the add-label button dropped its dashed one-off
styling. New strings land across all 23 locales.

* feat(collections): make the add-place button icon-only

Keep the filter row compact — the button carries just the plus icon (with
an aria-label/title), squared off to match the dropdown height.
This commit is contained in:
Maurice
2026-07-21 22:10:41 +02:00
committed by GitHub
parent 399e3573c1
commit ac723744ab
35 changed files with 212 additions and 38 deletions
@@ -4,6 +4,7 @@ import remarkGfm from 'remark-gfm'
import remarkBreaks from 'remark-breaks'
import { Search, MapPin, Plus, Loader2, Link2, Trash2, Check, X } from 'lucide-react'
import Modal from '../shared/Modal'
import { NumericInput } from '../shared/NumericInput'
import MarkdownToolbar from '../Journey/MarkdownToolbar'
import { mapsApi } from '../../api/client'
import { collectionsApi } from '../../api/collections'
@@ -44,6 +45,11 @@ export default function AddPlaceToCollectionModal({ isOpen, collectionId, collec
// The picked location (address/coords/ids) plus the editable fields.
const [picked, setPicked] = useState<MapsPlace | null>(null)
const [name, setName] = useState('')
// Address + coordinates: prefilled from a picked result, but also directly
// typeable so a place can be added by GPS without searching (#1435).
const [address, setAddress] = useState('')
const [lat, setLat] = useState('')
const [lng, setLng] = useState('')
const [categoryId, setCategoryId] = useState<number | null>(null)
const [description, setDescription] = useState('')
const [links, setLinks] = useState<CollectionLink[]>([])
@@ -51,7 +57,7 @@ export default function AddPlaceToCollectionModal({ isOpen, collectionId, collec
const [saving, setSaving] = useState(false)
const descRef = useRef<HTMLTextAreaElement>(null)
const reset = () => { setQuery(''); setResults([]); setPicked(null); setName(''); setCategoryId(null); setDescription(''); setLinks([]); setStatus('idea') }
const reset = () => { setQuery(''); setResults([]); setPicked(null); setName(''); setAddress(''); setLat(''); setLng(''); setCategoryId(null); setDescription(''); setLinks([]); setStatus('idea') }
useEffect(() => { if (!isOpen) reset() }, [isOpen])
const search = async () => {
@@ -67,21 +73,31 @@ export default function AddPlaceToCollectionModal({ isOpen, collectionId, collec
}
}
const pick = (r: MapsPlace) => { setPicked(r); setName(str(r.name) ?? ''); setResults([]); setQuery(str(r.name) ?? query) }
const pick = (r: MapsPlace) => {
setPicked(r)
setName(str(r.name) ?? '')
setAddress(str(r.address) ?? '')
const la = num(r.lat); const lo = num(r.lng)
setLat(la != null ? String(la) : '')
setLng(lo != null ? String(lo) : '')
setResults([]); setQuery(str(r.name) ?? query)
}
const setLink = (i: number, patch: Partial<CollectionLink>) => setLinks(links.map((l, idx) => (idx === i ? { ...l, ...patch } : l)))
const save = async () => {
const cleanName = name.trim()
if (!cleanName) return
const cleanLinks = links.map(l => ({ label: l.label?.trim() || undefined, url: normalizeLinkUrl(l.url) })).filter(l => l.url)
const latNum = lat.trim() ? Number(lat) : NaN
const lngNum = lng.trim() ? Number(lng) : NaN
setSaving(true)
try {
const res = await collectionsApi.savePlace({
collection_id: collectionId,
name: cleanName,
address: (picked && str(picked.address)) ?? null,
lat: (picked && num(picked.lat)) ?? null,
lng: (picked && num(picked.lng)) ?? null,
address: address.trim() || null,
lat: Number.isFinite(latNum) ? latNum : null,
lng: Number.isFinite(lngNum) ? lngNum : null,
google_place_id: (picked && str(picked.google_place_id)) ?? null,
google_ftid: (picked && str(picked.google_ftid)) ?? null,
osm_id: (picked && str(picked.osm_id)) ?? null,
@@ -103,7 +119,12 @@ export default function AddPlaceToCollectionModal({ isOpen, collectionId, collec
}
}
const address = picked ? str(picked.address) : undefined
const coordPaste = (e: React.ClipboardEvent<HTMLInputElement>) => {
const text = e.clipboardData.getData('text').trim()
const match = text.match(/^(-?\d+\.?\d*)\s*[,;\s]\s*(-?\d+\.?\d*)$/)
if (match) { e.preventDefault(); setLat(match[1]); setLng(match[2]) }
}
const coordInputClass = 'w-full px-3 py-2 rounded-lg border border-edge bg-surface-input text-content text-[14px] outline-none focus:border-accent'
return (
<Modal
@@ -163,7 +184,16 @@ export default function AddPlaceToCollectionModal({ isOpen, collectionId, collec
<div>
<label className="block text-[12px] font-medium text-content-secondary mb-1.5">{t('common.name')}</label>
<input value={name} onChange={e => setName(e.target.value)} placeholder={t('common.name')} className="w-full px-3 py-2 rounded-lg border border-edge bg-surface-input text-content text-[14px] outline-none focus:border-accent" />
{address && <div className="flex items-center gap-1.5 mt-1.5 text-[12px] text-content-faint"><MapPin size={12} /> {address}</div>}
</div>
{/* Address + coordinates — editable so a place can be added by GPS alone */}
<div>
<label className="block text-[12px] font-medium text-content-secondary mb-1.5">{t('places.formAddress')}</label>
<input value={address} onChange={e => setAddress(e.target.value)} placeholder={t('places.formAddressPlaceholder')} className={coordInputClass} />
<div className="grid grid-cols-2 gap-2 mt-2">
<NumericInput mode="signed" value={lat} onValueChange={setLat} onPaste={coordPaste} placeholder={t('places.formLat')} className={coordInputClass} />
<NumericInput mode="signed" value={lng} onValueChange={setLng} placeholder={t('places.formLng')} className={coordInputClass} />
</div>
</div>
{/* Status */}
@@ -28,9 +28,13 @@ function makeProps(overrides: Partial<HarnessProps> = {}): HarnessProps {
categoryFilter: 'all',
categoryOptions: CATEGORY_OPTIONS,
ratingFilter: 'all',
sortMode: 'default',
onStatusFilter: vi.fn(),
onCategoryFilter: vi.fn(),
onRatingFilter: vi.fn(),
onSortMode: vi.fn(),
canAddPlace: false,
onAddPlace: vi.fn(),
showLabels: false,
labelOptions: [],
labelFilter: [],
@@ -1,6 +1,6 @@
import React, { useEffect, useRef, useState } from 'react'
import { ChevronDown, Check, Layers, Tag, Tags, CheckSquare, Star } from 'lucide-react'
import type { StatusFilter } from '../../store/collectionStore'
import { ChevronDown, Check, Layers, Tag, Tags, CheckSquare, Star, Plus, ArrowDownUp } from 'lucide-react'
import type { StatusFilter, CollectionSortMode } from '../../store/collectionStore'
import type { TranslationFn } from '../../types'
import { getCategoryIcon } from '../shared/categoryIcons'
import { STATUS_META, STATUS_ORDER } from '../../pages/collections/collectionsModel'
@@ -68,9 +68,14 @@ interface CollectionFilterBarProps {
categoryFilter: number | 'all'
categoryOptions: CategoryOption[]
ratingFilter: number | 'all'
sortMode: CollectionSortMode
onStatusFilter: (f: StatusFilter) => void
onCategoryFilter: (f: number | 'all') => void
onRatingFilter: (f: number | 'all') => void
onSortMode: (m: CollectionSortMode) => void
// Add a place to the current list — leads the row when the list is editable.
canAddPlace: boolean
onAddPlace: () => void
// Per-collection labels (hidden on the "All saved" union).
showLabels: boolean
labelOptions: LabelOption[]
@@ -90,7 +95,9 @@ interface CollectionFilterBarProps {
* Custom compact dropdowns so they barely take any space.
*/
export default function CollectionFilterBar({
statusFilter, counts, categoryFilter, categoryOptions, ratingFilter, onStatusFilter, onCategoryFilter, onRatingFilter,
statusFilter, counts, categoryFilter, categoryOptions, ratingFilter, sortMode,
onStatusFilter, onCategoryFilter, onRatingFilter, onSortMode,
canAddPlace, onAddPlace,
showLabels, labelOptions, labelFilter, onLabelFilter, canManageLabels, onManageLabels,
showSelect, selectMode, onToggleSelect, t,
}: CollectionFilterBarProps): React.ReactElement {
@@ -121,13 +128,25 @@ export default function CollectionFilterBar({
})),
]
// Display order: the saved order, or alphabetical by name.
const sortOpts: Opt[] = [
{ key: 'default', label: t('collections.sort.default') },
{ key: 'name_asc', label: t('collections.sort.nameAsc') },
]
return (
<div className="col-filterbar">
{canAddPlace && (
<button type="button" onClick={onAddPlace} className="col-filter-btn col-filter-add" aria-label={t('collections.addPlace')} title={t('collections.addPlace')}>
<Plus size={15} />
</button>
)}
<Dropdown current={statusFilter} options={statusOpts} onSelect={k => onStatusFilter(k as StatusFilter)} lead={<Layers size={13} />} />
{categoryOptions.length > 0 && (
<Dropdown current={categoryFilter} options={catOpts} onSelect={k => onCategoryFilter(k as number | 'all')} lead={<Tag size={13} />} />
)}
<Dropdown current={ratingFilter} options={ratingOpts} onSelect={k => onRatingFilter(k as number | 'all')} lead={<Star size={13} />} />
<Dropdown current={sortMode} options={sortOpts} onSelect={k => onSortMode(k as CollectionSortMode)} lead={<ArrowDownUp size={13} />} />
{showSelect && (
<button type="button" onClick={onToggleSelect} className={`col-filter-btn col-filter-select${selectMode ? ' open' : ''}`} aria-pressed={selectMode}>
<CheckSquare size={14} /> <span className="col-filter-lbl">{t('collections.select')}</span>
@@ -153,7 +172,7 @@ export default function CollectionFilterBar({
)
})}
{canManageLabels && (
<button type="button" className="col-labelchip col-labelchip-manage" onClick={onManageLabels} title={t('collections.labels.manage')}>
<button type="button" className="col-filter-btn col-filter-addlabel" onClick={onManageLabels} title={t('collections.labels.manage')}>
<Tags size={13} />
<span className="col-filter-lbl">{labelOptions.length ? t('collections.labels.manage') : t('collections.labels.add')}</span>
</button>
@@ -6,6 +6,7 @@ import { X, Pencil, Copy, Trash2, MapPin, Link2, Plus, ExternalLink, Check, Tag,
import type { CollectionPlace, CollectionStatus, CollectionLink, CollectionLabel } from '@trek/shared'
import type { Category, TranslationFn } from '../../types'
import MarkdownToolbar from '../Journey/MarkdownToolbar'
import { NumericInput } from '../shared/NumericInput'
import { mapsApi } from '../../api/client'
import { entityGradient } from '../../utils/gradients'
import { getCategoryIcon } from '../shared/categoryIcons'
@@ -31,7 +32,7 @@ interface CollectionPlaceDetailProps {
anchorRect?: { left: number; width: number } | null
onClose: () => void
onSetStatus: (status: CollectionStatus) => void
onSave: (patch: { name?: string; description?: string | null; links?: CollectionLink[]; category_id?: number | null; label_ids?: number[]; image_url?: string | null }) => Promise<void>
onSave: (patch: { name?: string; description?: string | null; links?: CollectionLink[]; category_id?: number | null; label_ids?: number[]; image_url?: string | null; lat?: number | null; lng?: number | null }) => Promise<void>
/** Upload a custom cover image (#1136); enables the cover change/remove controls. */
onUploadImage?: (file: File) => Promise<void>
onCopyToTrip: () => void
@@ -76,6 +77,8 @@ export default function CollectionPlaceDetail({
const [description, setDescription] = useState(place.description ?? '')
const [links, setLinks] = useState<CollectionLink[]>(place.links ?? [])
const [labelIds, setLabelIds] = useState<number[]>(place.label_ids ?? [])
const [lat, setLat] = useState(place.lat != null ? String(place.lat) : '')
const [lng, setLng] = useState(place.lng != null ? String(place.lng) : '')
const [saving, setSaving] = useState(false)
// A higher-res photo pulled from the maps provider when the place has none of
// its own — the list avatar's little thumbnail is too low-res for the cover.
@@ -90,6 +93,8 @@ export default function CollectionPlaceDetail({
setDescription(place.description ?? '')
setLinks(place.links ?? [])
setLabelIds(place.label_ids ?? [])
setLat(place.lat != null ? String(place.lat) : '')
setLng(place.lng != null ? String(place.lng) : '')
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [place.id])
@@ -136,14 +141,21 @@ export default function CollectionPlaceDetail({
const setLink = (i: number, patch: Partial<CollectionLink>) => setLinks(links.map((l, idx) => (idx === i ? { ...l, ...patch } : l)))
const toggleLabel = (id: number) => setLabelIds(labelIds.includes(id) ? labelIds.filter(x => x !== id) : [...labelIds, id])
const resetForm = () => { setEditing(false); setName(place.name); setCategoryId(place.category_id ?? null); setDescription(place.description ?? ''); setLinks(place.links ?? []); setLabelIds(place.label_ids ?? []) }
const resetForm = () => { setEditing(false); setName(place.name); setCategoryId(place.category_id ?? null); setDescription(place.description ?? ''); setLinks(place.links ?? []); setLabelIds(place.label_ids ?? []); setLat(place.lat != null ? String(place.lat) : ''); setLng(place.lng != null ? String(place.lng) : '') }
const coordPaste = (e: React.ClipboardEvent<HTMLInputElement>) => {
const text = e.clipboardData.getData('text').trim()
const match = text.match(/^(-?\d+\.?\d*)\s*[,;\s]\s*(-?\d+\.?\d*)$/)
if (match) { e.preventDefault(); setLat(match[1]); setLng(match[2]) }
}
const assignedLabels = labels.filter(l => (place.label_ids ?? []).includes(l.id))
const save = async () => {
const cleanLinks = links.map(l => ({ label: l.label?.trim() || undefined, url: normalizeLinkUrl(l.url) })).filter(l => l.url)
const latNum = lat.trim() ? Number(lat) : NaN
const lngNum = lng.trim() ? Number(lng) : NaN
setSaving(true)
try {
await onSave({ name: name.trim() || place.name, description: description.trim() || null, links: cleanLinks, category_id: categoryId, label_ids: labelIds })
await onSave({ name: name.trim() || place.name, description: description.trim() || null, links: cleanLinks, category_id: categoryId, label_ids: labelIds, lat: Number.isFinite(latNum) ? latNum : null, lng: Number.isFinite(lngNum) ? lngNum : null })
setEditing(false)
} catch (err) {
toast.error(getApiErrorMessage(err, t('common.error')))
@@ -236,6 +248,14 @@ export default function CollectionPlaceDetail({
})}
</div>
</div>
{/* Coordinates */}
<div className="col-detail-field">
<div className="col-detail-label"><MapPin size={12} /> {t('collections.coordinates')}</div>
<div className="col-detail-link-row">
<NumericInput mode="signed" value={lat} onValueChange={setLat} onPaste={coordPaste} placeholder={t('places.formLat')} className="col-detail-input flex-1" />
<NumericInput mode="signed" value={lng} onValueChange={setLng} placeholder={t('places.formLng')} className="col-detail-input flex-1" />
</div>
</div>
{/* Labels */}
{labels.length > 0 && (
<div className="col-detail-field">
+15 -7
View File
@@ -1,6 +1,7 @@
// Regression coverage for issue #1485 — the "Add place" button vanished once a
// collection held its first mappable place on a wide/desktop layout, because the
// whole toolbar (which hosts the button) was gated on `!mapOverlay`. These tests
// collection held its first mappable place on a wide/desktop layout. The button
// now lives inside the filter row (delegated via `canAddPlace`) for a populated
// list, and as an empty-state CTA when the list has no places yet. These tests
// render the page against a mocked useCollections hook (per the Page pattern) and
// assert the Add affordance stays reachable — and that there is exactly one of it.
import { describe, it, expect, vi } from 'vitest'
@@ -16,7 +17,14 @@ vi.mock('../components/Collections/ListsRail', () => ({ default: () => <div /> }
vi.mock('../components/Collections/ListEditorModal', () => ({ default: () => null }))
vi.mock('../components/Collections/CollectionHero', () => ({ default: () => <div /> }))
vi.mock('../components/Collections/CollectionList', () => ({ default: () => <div data-testid="list" /> }))
vi.mock('../components/Collections/CollectionFilterBar', () => ({ default: () => <div /> }))
// The filter row hosts the Add button for a populated list; mirror that contract
// so the page-level "reachable + exactly one" assertion still holds end to end.
vi.mock('../components/Collections/CollectionFilterBar', () => ({
default: (props: { canAddPlace?: boolean; onAddPlace?: () => void }) =>
props.canAddPlace
? <button type="button" onClick={props.onAddPlace}>collections.addPlace</button>
: <div />,
}))
vi.mock('../components/Collections/CollectionMapPanel', () => ({ default: () => <div data-testid="map" /> }))
vi.mock('../components/Collections/CopyToTripModal', () => ({ default: () => null }))
vi.mock('../components/Collections/MoveToListModal', () => ({ default: () => null }))
@@ -104,20 +112,20 @@ describe('CollectionsPage — Add place button reachability (#1485)', () => {
// The exact bug: wide layout + one place with coordinates + editable list.
mockUseCollections.mockReturnValue(makeHook())
render(<CollectionsPage />)
const addButtons = screen.getAllByLabelText('collections.addPlace')
// Present, and exactly one — no duplicate map-overlay "+" alongside it.
const addButtons = screen.getAllByRole('button', { name: 'collections.addPlace' })
// Present, and exactly one — no duplicate affordance alongside it.
expect(addButtons).toHaveLength(1)
})
it('does not show the Add button for a viewer who cannot edit', () => {
mockUseCollections.mockReturnValue(makeHook({ canEdit: false, isOwner: false, myRole: 'viewer' }))
render(<CollectionsPage />)
expect(screen.queryByLabelText('collections.addPlace')).toBeNull()
expect(screen.queryByRole('button', { name: 'collections.addPlace' })).toBeNull()
})
it('shows the Add button on an empty collection', () => {
mockUseCollections.mockReturnValue(makeHook({ places: [], visiblePlaces: [], mappable: [] }))
render(<CollectionsPage />)
expect(screen.getAllByLabelText('collections.addPlace')).toHaveLength(1)
expect(screen.getAllByRole('button', { name: 'collections.addPlace' })).toHaveLength(1)
})
})
+15 -7
View File
@@ -103,9 +103,13 @@ function CollectionsPageDesktop(): React.ReactElement {
categoryFilter={c.categoryFilter}
categoryOptions={c.categoryOptions}
ratingFilter={c.ratingFilter}
sortMode={c.sortMode}
onStatusFilter={c.setStatusFilter}
onCategoryFilter={c.setCategoryFilter}
onRatingFilter={c.setRatingFilter}
onSortMode={c.setSortMode}
canAddPlace={canAddPlace}
onAddPlace={() => c.setShowAddPlace(true)}
showLabels={isRealList}
labelOptions={c.labelOptions}
labelFilter={c.labelFilter}
@@ -131,7 +135,16 @@ function CollectionsPageDesktop(): React.ReactElement {
if (c.placesLoading && !hasPlaces) {
body = <div className="col-loading"><div className="col-spinner" /></div>
} else if (!hasPlaces) {
body = <EmptyState scene="collections" title={t('collections.empty.title')} />
body = (
<div className="flex flex-col items-center">
<EmptyState scene="collections" title={t('collections.empty.title')} className={canAddPlace ? 'pb-4' : undefined} />
{canAddPlace && (
<button type="button" onClick={() => c.setShowAddPlace(true)} className="col-cta">
<Plus size={16} /> {t('collections.addPlace')}
</button>
)}
</div>
)
} else if (desktopSplit) {
body = (
<div className={`col-split${c.view === 'map' ? ' map-full' : ''}`}>
@@ -195,7 +208,7 @@ function CollectionsPageDesktop(): React.ReactElement {
/>
</div>
{(!mapOverlay || canAddPlace) && (
{!mapOverlay && (
<div className="col-toolbar">
<button type="button" className="col-rail-toggle" onClick={() => c.setMobileRailOpen(true)}>
<Bookmark size={15} /> {t('collections.title')}
@@ -210,11 +223,6 @@ function CollectionsPageDesktop(): React.ReactElement {
</button>
</div>
)}
{canAddPlace && (
<button type="button" onClick={() => c.setShowAddPlace(true)} className="col-iconbtn" aria-label={t('collections.addPlace')} title={t('collections.addPlace')}>
<Plus size={16} />
</button>
)}
<div className="col-toolbar-spacer" />
{!mapOverlay && (
<div className="col-search">
@@ -2,7 +2,7 @@ import { Circle, Bookmark, CheckCircle2 } from 'lucide-react'
import type { LucideIcon } from 'lucide-react'
import type { CollectionPlace, CollectionStatus, CollectionLabel } from '@trek/shared'
import { COLLECTION_STATUSES } from '@trek/shared'
import type { StatusFilter } from '../../store/collectionStore'
import type { StatusFilter, CollectionSortMode } from '../../store/collectionStore'
/**
* Pure data shaping + presentation metadata for the Collections page. No React
@@ -35,8 +35,12 @@ export function nextStatus(status: CollectionStatus): CollectionStatus {
return STATUS_ORDER[(i + 1) % STATUS_ORDER.length]
}
/** Sort places by explicit sort_order, falling back to created_at (newest first). */
export function sortPlaces(places: CollectionPlace[]): CollectionPlace[] {
/** Order the places for display. 'default' keeps the saved order (sort_order,
* then newest first); 'name_asc' sorts alphabetically by name (locale-aware). */
export function sortPlaces(places: CollectionPlace[], mode: CollectionSortMode = 'default'): CollectionPlace[] {
if (mode === 'name_asc') {
return [...places].sort((a, b) => a.name.localeCompare(b.name))
}
return [...places].sort((a, b) => {
const so = (a.sort_order ?? 0) - (b.sort_order ?? 0)
if (so !== 0) return so
@@ -50,7 +50,7 @@ export function useCollections() {
const store = useCollectionStore()
const {
collections, activeId, places, members, labels, incomingInvites,
view, statusFilter, categoryFilter, ratingFilter, labelFilter, search, selectedPlaceId, selectMode, selectedIds,
view, statusFilter, categoryFilter, ratingFilter, labelFilter, sortMode, search, selectedPlaceId, selectMode, selectedIds,
loading, placesLoading,
loadAll, setActive, refreshActive, loadCollection,
deleteCollection,
@@ -58,7 +58,7 @@ export function useCollections() {
moveToList, duplicateToList, setSelectedIds,
createLabel, updateLabel, deleteLabel, assignLabels,
acceptInvite, declineInvite,
setView, setStatusFilter, setCategoryFilter, setRatingFilter, setLabelFilter, setSearch, setSelectedPlaceId, setSelectMode, toggleSelect,
setView, setStatusFilter, setCategoryFilter, setRatingFilter, setLabelFilter, setSortMode, setSearch, setSelectedPlaceId, setSelectMode, toggleSelect,
} = store
// ── Page-local UI state ─────────────────────────────────────────────
@@ -167,8 +167,8 @@ export function useCollections() {
// Labels are per-collection, so never apply them on the "All saved" union.
const visiblePlaces = useMemo(
() => sortPlaces(filterPlaces(places, statusFilter, search, categoryFilter, isAllSaved ? [] : labelFilter, ratingFilter)),
[places, statusFilter, search, categoryFilter, isAllSaved, labelFilter, ratingFilter],
() => sortPlaces(filterPlaces(places, statusFilter, search, categoryFilter, isAllSaved ? [] : labelFilter, ratingFilter), sortMode),
[places, statusFilter, search, categoryFilter, isAllSaved, labelFilter, ratingFilter, sortMode],
)
// Categories actually present in this list, for the category filter dropdown.
const categoryOptions = useMemo(() => presentCategories(places), [places])
@@ -386,11 +386,11 @@ export function useCollections() {
myRole, canEdit, canDelete,
canShare, shareMemberCount,
activeId, places, visiblePlaces, mappable, members, incomingInvites, counts,
view, statusFilter, categoryFilter, categoryOptions, ratingFilter, search, selectedPlaceId, selectMode, selectedIds,
view, statusFilter, categoryFilter, categoryOptions, ratingFilter, sortMode, search, selectedPlaceId, selectMode, selectedIds,
labels, labelFilter, labelOptions,
loading, placesLoading,
// store setters
setView, setStatusFilter, setCategoryFilter, setRatingFilter, setLabelFilter, setSearch, setSelectedPlaceId, setSelectMode, toggleSelect,
setView, setStatusFilter, setCategoryFilter, setRatingFilter, setLabelFilter, setSortMode, setSearch, setSelectedPlaceId, setSelectMode, toggleSelect,
updatePlace, uploadPlaceImage,
// labels
showLabelManager, setShowLabelManager, labelPickerOpen, setLabelPickerOpen,
+6
View File
@@ -23,6 +23,8 @@ export type ActiveCollectionId = number | typeof ALL_SAVED | null
export type CollectionView = 'list' | 'map'
export type StatusFilter = CollectionStatus | 'all'
/** Display order for a list's places: the saved order, or alphabetical by name. */
export type CollectionSortMode = 'default' | 'name_asc'
interface CollectionState {
collections: Collection[]
@@ -36,6 +38,7 @@ interface CollectionState {
categoryFilter: number | 'all'
ratingFilter: number | 'all'
labelFilter: number[]
sortMode: CollectionSortMode
search: string
selectedPlaceId: number | null
selectMode: boolean
@@ -82,6 +85,7 @@ interface CollectionState {
setCategoryFilter: (filter: number | 'all') => void
setRatingFilter: (filter: number | 'all') => void
setLabelFilter: (labelIds: number[]) => void
setSortMode: (mode: CollectionSortMode) => void
setSearch: (search: string) => void
setSelectedPlaceId: (id: number | null) => void
setSelectMode: (on: boolean) => void
@@ -102,6 +106,7 @@ export const useCollectionStore = create<CollectionState>((set, get) => ({
categoryFilter: 'all',
ratingFilter: 'all',
labelFilter: [],
sortMode: 'default',
search: '',
selectedPlaceId: null,
selectMode: false,
@@ -394,6 +399,7 @@ export const useCollectionStore = create<CollectionState>((set, get) => ({
setCategoryFilter: (filter: number | 'all') => set({ categoryFilter: filter }),
setRatingFilter: (filter: number | 'all') => set({ ratingFilter: filter }),
setLabelFilter: (labelIds: number[]) => set({ labelFilter: labelIds }),
setSortMode: (mode: CollectionSortMode) => set({ sortMode: mode }),
setSearch: (search: string) => set({ search }),
setSelectedPlaceId: (id: number | null) => set({ selectedPlaceId: id }),
setSelectMode: (on: boolean) => set({ selectMode: on, selectedIds: on ? get().selectedIds : [] }),
+2 -1
View File
@@ -281,12 +281,13 @@
.trek-dash .col-labelchip.on { color: var(--label, var(--accent)); background: color-mix(in oklch, var(--label, var(--accent)) 16%, transparent); border-color: color-mix(in oklch, var(--label, var(--accent)) 42%, transparent); }
.trek-dash .col-labelchip.on .col-labelchip-dot { background: var(--label, var(--accent)); }
.trek-dash .col-labelchip.static { cursor: default; color: var(--label, var(--accent)); background: color-mix(in oklch, var(--label, var(--accent)) 14%, transparent); border-color: transparent; }
.trek-dash .col-labelchip-manage { color: var(--ink-3); border-style: dashed; }
.trek-dash .col-detail-labels { display: flex; flex-wrap: wrap; gap: 7px; margin: 2px 0 10px; }
/* ----------------- filter bar (status + category dropdowns) ----------------- */
.trek-dash .col-filterbar { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; }
.trek-dash .col-filter { position: relative; }
/* Icon-only add-place button: square it off so it matches the dropdowns' height. */
.trek-dash .col-filter-add { padding: 7px; }
.trek-dash .col-filter-select { margin-left: auto; }
.trek-dash .col-filter-select.open { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.trek-dash .col-filter-select.open:hover { background: var(--accent); color: var(--accent-text); }
@@ -598,6 +598,8 @@ export function updatePlace(userId: number, placeId: number, body: import('@trek
if (body.name !== undefined) { updates.push('name = ?'); params.push(body.name); }
if (body.description !== undefined) { updates.push('description = ?'); params.push(body.description ?? null); }
if (body.notes !== undefined) { updates.push('notes = ?'); params.push(body.notes ?? null); }
if (body.lat !== undefined) { updates.push('lat = ?'); params.push(body.lat ?? null); }
if (body.lng !== undefined) { updates.push('lng = ?'); params.push(body.lng ?? null); }
if (body.status !== undefined) { updates.push('status = ?'); params.push(body.status); }
if (body.category_id !== undefined) { updates.push('category_id = ?'); params.push(body.category_id ?? null); }
if (body.image_url !== undefined) { updates.push('image_url = ?'); params.push(body.image_url ?? null); }
@@ -177,6 +177,9 @@ export const collectionPlaceUpdateRequestSchema = z.object({
name: z.string().min(1).optional(),
description: z.string().nullable().optional(),
notes: z.string().nullable().optional(),
// Editable coordinates so a place added by GPS can be corrected later (#1435).
lat: z.number().nullable().optional(),
lng: z.number().nullable().optional(),
// .removeDefault() strips the inner .default('idea') so an ABSENT status parses to
// undefined (left unchanged) instead of being injected as 'idea' (see #1437). The
// .catch('idea') guard against invalid values is preserved.
+3
View File
@@ -36,6 +36,9 @@ const collection: TranslationStrings = {
'collections.addPlace': 'إضافة مكان',
'collections.addPlaceSearch': 'ابحث عن مكان…',
'collections.addPlaceHint': 'ابحث لإضافة مكان إلى هذه القائمة',
'collections.sort.default': 'افتراضي',
'collections.sort.nameAsc': 'الاسم (أ–ي)',
'collections.coordinates': 'الإحداثيات',
'collections.showList': 'إظهار القائمة',
'collections.expandMap': 'توسيع الخريطة',
'collections.hero.mine': 'مجموعتي',
+3
View File
@@ -36,6 +36,9 @@ const collection: TranslationStrings = {
'collections.addPlace': 'Adicionar um lugar',
'collections.addPlaceSearch': 'Pesquisar um lugar…',
'collections.addPlaceHint': 'Pesquise para adicionar um lugar a esta lista',
'collections.sort.default': 'Padrão',
'collections.sort.nameAsc': 'Nome (A–Z)',
'collections.coordinates': 'Coordenadas',
'collections.showList': 'Mostrar lista',
'collections.expandMap': 'Ampliar mapa',
'collections.hero.mine': 'Minha coleção',
+3
View File
@@ -36,6 +36,9 @@ const collection: TranslationStrings = {
'collections.addPlace': 'Afegir un lloc',
'collections.addPlaceSearch': 'Cercar un lloc…',
'collections.addPlaceHint': 'Cerca per afegir un lloc a aquesta llista',
'collections.sort.default': 'Predeterminat',
'collections.sort.nameAsc': 'Nom (A–Z)',
'collections.coordinates': 'Coordenades',
'collections.showList': 'Mostra la llista',
'collections.expandMap': 'Ampliar el mapa',
'collections.hero.mine': 'La meva col·lecció',
+3
View File
@@ -36,6 +36,9 @@ const collection: TranslationStrings = {
'collections.addPlace': 'Přidat místo',
'collections.addPlaceSearch': 'Hledat místo…',
'collections.addPlaceHint': 'Vyhledejte a přidejte místo do tohoto seznamu',
'collections.sort.default': 'Výchozí',
'collections.sort.nameAsc': 'Název (A–Z)',
'collections.coordinates': 'Souřadnice',
'collections.showList': 'Zobrazit seznam',
'collections.expandMap': 'Zvětšit mapu',
'collections.hero.mine': 'Moje sbírka',
+3
View File
@@ -36,6 +36,9 @@ const collection: TranslationStrings = {
'collections.addPlace': 'Ort hinzufügen',
'collections.addPlaceSearch': 'Nach einem Ort suchen…',
'collections.addPlaceHint': 'Suchen, um einen Ort zur Liste hinzuzufügen',
'collections.sort.default': 'Standard',
'collections.sort.nameAsc': 'Name (A–Z)',
'collections.coordinates': 'Koordinaten',
'collections.showList': 'Liste zeigen',
'collections.expandMap': 'Karte vergrößern',
'collections.hero.mine': 'Meine Sammlung',
+3
View File
@@ -36,6 +36,9 @@ const collection: TranslationStrings = {
'collections.addPlace': 'Add a place',
'collections.addPlaceSearch': 'Search for a place…',
'collections.addPlaceHint': 'Search to add a place to this list',
'collections.sort.default': 'Default',
'collections.sort.nameAsc': 'Name (A–Z)',
'collections.coordinates': 'Coordinates',
'collections.showList': 'Show list',
'collections.expandMap': 'Expand map',
'collections.hero.mine': 'My collection',
+3
View File
@@ -36,6 +36,9 @@ const collection: TranslationStrings = {
'collections.addPlace': 'Añadir un lugar',
'collections.addPlaceSearch': 'Buscar un lugar…',
'collections.addPlaceHint': 'Busca para añadir un lugar a esta lista',
'collections.sort.default': 'Predeterminado',
'collections.sort.nameAsc': 'Nombre (A–Z)',
'collections.coordinates': 'Coordenadas',
'collections.showList': 'Mostrar lista',
'collections.expandMap': 'Ampliar mapa',
'collections.hero.mine': 'Mi colección',
+3
View File
@@ -36,6 +36,9 @@ const collection: TranslationStrings = {
'collections.addPlace': 'Ajouter un lieu',
'collections.addPlaceSearch': 'Rechercher un lieu…',
'collections.addPlaceHint': 'Recherchez pour ajouter un lieu à cette liste',
'collections.sort.default': 'Par défaut',
'collections.sort.nameAsc': 'Nom (A–Z)',
'collections.coordinates': 'Coordonnées',
'collections.showList': 'Afficher la liste',
'collections.expandMap': 'Agrandir la carte',
'collections.hero.mine': 'Ma collection',
+3
View File
@@ -36,6 +36,9 @@ const collection: TranslationStrings = {
'collections.addPlace': 'Προσθήκη τόπου',
'collections.addPlaceSearch': 'Αναζήτηση τόπου…',
'collections.addPlaceHint': 'Αναζητήστε για να προσθέσετε έναν τόπο σε αυτήν τη λίστα',
'collections.sort.default': 'Προεπιλογή',
'collections.sort.nameAsc': 'Όνομα (Α–Ω)',
'collections.coordinates': 'Συντεταγμένες',
'collections.showList': 'Εμφάνιση λίστας',
'collections.expandMap': 'Μεγέθυνση χάρτη',
'collections.hero.mine': 'Η συλλογή μου',
+3
View File
@@ -36,6 +36,9 @@ const collection: TranslationStrings = {
'collections.addPlace': 'Hely hozzáadása',
'collections.addPlaceSearch': 'Hely keresése…',
'collections.addPlaceHint': 'Keressen, hogy helyet adjon a listához',
'collections.sort.default': 'Alapértelmezett',
'collections.sort.nameAsc': 'Név (A–Z)',
'collections.coordinates': 'Koordináták',
'collections.showList': 'Lista megjelenítése',
'collections.expandMap': 'Térkép nagyítása',
'collections.hero.mine': 'Saját gyűjtemény',
+3
View File
@@ -36,6 +36,9 @@ const collection: TranslationStrings = {
'collections.addPlace': 'Tambah tempat',
'collections.addPlaceSearch': 'Cari tempat…',
'collections.addPlaceHint': 'Cari untuk menambahkan tempat ke daftar ini',
'collections.sort.default': 'Bawaan',
'collections.sort.nameAsc': 'Nama (A–Z)',
'collections.coordinates': 'Koordinat',
'collections.showList': 'Tampilkan daftar',
'collections.expandMap': 'Perbesar peta',
'collections.hero.mine': 'Koleksi saya',
+3
View File
@@ -36,6 +36,9 @@ const collection: TranslationStrings = {
'collections.addPlace': 'Aggiungi un luogo',
'collections.addPlaceSearch': 'Cerca un luogo…',
'collections.addPlaceHint': 'Cerca per aggiungere un luogo a questo elenco',
'collections.sort.default': 'Predefinito',
'collections.sort.nameAsc': 'Nome (A–Z)',
'collections.coordinates': 'Coordinate',
'collections.showList': 'Mostra elenco',
'collections.expandMap': 'Espandi mappa',
'collections.hero.mine': 'La mia raccolta',
+3
View File
@@ -36,6 +36,9 @@ const collection: TranslationStrings = {
'collections.addPlace': '場所を追加',
'collections.addPlaceSearch': '場所を検索…',
'collections.addPlaceHint': '検索してこのリストに場所を追加',
'collections.sort.default': 'デフォルト',
'collections.sort.nameAsc': '名前順(A–Z)',
'collections.coordinates': '座標',
'collections.showList': 'リストを表示',
'collections.expandMap': '地図を拡大',
'collections.hero.mine': 'マイコレクション',
+3
View File
@@ -36,6 +36,9 @@ const collection: TranslationStrings = {
'collections.addPlace': '장소 추가',
'collections.addPlaceSearch': '장소 검색…',
'collections.addPlaceHint': '검색하여 이 목록에 장소 추가',
'collections.sort.default': '기본',
'collections.sort.nameAsc': '이름순 (A–Z)',
'collections.coordinates': '좌표',
'collections.showList': '목록 표시',
'collections.expandMap': '지도 확대',
'collections.hero.mine': '내 컬렉션',
+3
View File
@@ -36,6 +36,9 @@ const collection: TranslationStrings = {
'collections.addPlace': 'Plaats toevoegen',
'collections.addPlaceSearch': 'Zoek een plaats…',
'collections.addPlaceHint': 'Zoek om een plaats aan deze lijst toe te voegen',
'collections.sort.default': 'Standaard',
'collections.sort.nameAsc': 'Naam (A–Z)',
'collections.coordinates': 'Coördinaten',
'collections.showList': 'Lijst tonen',
'collections.expandMap': 'Kaart vergroten',
'collections.hero.mine': 'Mijn collectie',
+3
View File
@@ -36,6 +36,9 @@ const collection: TranslationStrings = {
'collections.addPlace': 'Dodaj miejsce',
'collections.addPlaceSearch': 'Wyszukaj miejsce…',
'collections.addPlaceHint': 'Wyszukaj, aby dodać miejsce do tej listy',
'collections.sort.default': 'Domyślnie',
'collections.sort.nameAsc': 'Nazwa (A–Z)',
'collections.coordinates': 'Współrzędne',
'collections.showList': 'Pokaż listę',
'collections.expandMap': 'Powiększ mapę',
'collections.hero.mine': 'Moja kolekcja',
+3
View File
@@ -36,6 +36,9 @@ const collection: TranslationStrings = {
'collections.addPlace': 'Добавить место',
'collections.addPlaceSearch': 'Поиск места…',
'collections.addPlaceHint': 'Найдите, чтобы добавить место в этот список',
'collections.sort.default': 'По умолчанию',
'collections.sort.nameAsc': 'Название (А–Я)',
'collections.coordinates': 'Координаты',
'collections.showList': 'Показать список',
'collections.expandMap': 'Развернуть карту',
'collections.hero.mine': 'Моя коллекция',
+3
View File
@@ -36,6 +36,9 @@ const collection: TranslationStrings = {
'collections.addPlace': 'Lägg till en plats',
'collections.addPlaceSearch': 'Sök efter en plats…',
'collections.addPlaceHint': 'Sök för att lägga till en plats i listan',
'collections.sort.default': 'Standard',
'collections.sort.nameAsc': 'Namn (A–Ö)',
'collections.coordinates': 'Koordinater',
'collections.showList': 'Visa lista',
'collections.expandMap': 'Förstora karta',
'collections.hero.mine': 'Min samling',
+3
View File
@@ -36,6 +36,9 @@ const collection: TranslationStrings = {
'collections.addPlace': 'Yer ekle',
'collections.addPlaceSearch': 'Yer ara…',
'collections.addPlaceHint': 'Bu listeye yer eklemek için arayın',
'collections.sort.default': 'Varsayılan',
'collections.sort.nameAsc': 'Ad (A–Z)',
'collections.coordinates': 'Koordinatlar',
'collections.showList': 'Listeyi göster',
'collections.expandMap': 'Haritayı genişlet',
'collections.hero.mine': 'Koleksiyonum',
+3
View File
@@ -36,6 +36,9 @@ const collection: TranslationStrings = {
'collections.addPlace': 'Додати місце',
'collections.addPlaceSearch': 'Пошук місця…',
'collections.addPlaceHint': 'Знайдіть, щоб додати місце до цього списку',
'collections.sort.default': 'За замовчуванням',
'collections.sort.nameAsc': 'Назва (А–Я)',
'collections.coordinates': 'Координати',
'collections.showList': 'Показати список',
'collections.expandMap': 'Розгорнути карту',
'collections.hero.mine': 'Моя колекція',
+3
View File
@@ -36,6 +36,9 @@ const collection: TranslationStrings = {
'collections.addPlace': 'Thêm địa điểm',
'collections.addPlaceSearch': 'Tìm địa điểm…',
'collections.addPlaceHint': 'Tìm để thêm địa điểm vào danh sách này',
'collections.sort.default': 'Mặc định',
'collections.sort.nameAsc': 'Tên (A–Z)',
'collections.coordinates': 'Tọa độ',
'collections.showList': 'Hiện danh sách',
'collections.expandMap': 'Mở rộng bản đồ',
'collections.hero.mine': 'Bộ sưu tập của tôi',
+3
View File
@@ -36,6 +36,9 @@ const collection: TranslationStrings = {
'collections.addPlace': '新增地點',
'collections.addPlaceSearch': '搜尋地點…',
'collections.addPlaceHint': '搜尋以將地點加入此清單',
'collections.sort.default': '預設',
'collections.sort.nameAsc': '名稱 (A–Z)',
'collections.coordinates': '座標',
'collections.showList': '顯示清單',
'collections.expandMap': '展開地圖',
'collections.hero.mine': '我的收藏',
+3
View File
@@ -36,6 +36,9 @@ const collection: TranslationStrings = {
'collections.addPlace': '添加地点',
'collections.addPlaceSearch': '搜索地点…',
'collections.addPlaceHint': '搜索以将地点添加到此清单',
'collections.sort.default': '默认',
'collections.sort.nameAsc': '名称 (A–Z)',
'collections.coordinates': '坐标',
'collections.showList': '显示列表',
'collections.expandMap': '展开地图',
'collections.hero.mine': '我的收藏',