feat(collections): import a whole trip's places into a list (#1903)

* feat(collections): preview which of a trip's places a list already holds

The bulk import endpoint has been there since the select-mode copy, but nothing
calls it and it only reports duplicates after the fact. A dialog needs the verdict
up front, so /:id/importable/:tripId returns the trip's places with the duplicate
check the import itself applies, plus whether any day holds the place.

* feat(collections): import a whole trip's places into a list

Two steps: pick a trip, then tick its places. Places already on the list are
greyed out and unpickable, and the ones no day holds start selected — those are
the plans a trip left behind, which is the reason to import at all. Sorted so a
mostly-saved trip reads as the two that are left rather than a wall of grey.

* feat(collections): reach the trip import from the filter row and an empty list

* i18n(collections): translate the trip import into all locales

* fix(collections): stop the label dialog's buttons wrapping mid-word

Three actions in a max-w-sm footer wrapped into two lines each. The assign
button also painted white text on the accent, which disappears on a light one.

* docs(collections): document the trip import
This commit is contained in:
Maurice
2026-08-12 11:54:36 +02:00
committed by GitHub
parent b0fd73681b
commit b842d74a5d
37 changed files with 1286 additions and 11 deletions
+27 -4
View File
@@ -1,5 +1,5 @@
import React from 'react'
import { List as ListIcon, Map as MapIcon, Search, Bookmark, CheckCheck, X, Trash2, Copy, CopyPlus, FolderInput, Plus, Tags } from 'lucide-react'
import { List as ListIcon, Map as MapIcon, Search, Bookmark, CheckCheck, X, Trash2, Copy, CopyPlus, FolderInput, Plus, Tags, DownloadCloud } from 'lucide-react'
import Navbar from '../components/Layout/Navbar'
import Modal from '../components/shared/Modal'
import ListsRail from '../components/Collections/ListsRail'
@@ -12,6 +12,7 @@ import CopyToTripModal from '../components/Collections/CopyToTripModal'
import MoveToListModal from '../components/Collections/MoveToListModal'
import ShareCollectionModal from '../components/Collections/ShareCollectionModal'
import AddPlaceToCollectionModal from '../components/Collections/AddPlaceToCollectionModal'
import ImportFromTripModal from '../components/Collections/ImportFromTripModal'
import CollectionPlaceDetail from '../components/Collections/CollectionPlaceDetail'
import LabelManager from '../components/Collections/LabelManager'
import BulkAssignLabelModal from '../components/Collections/BulkAssignLabelModal'
@@ -120,6 +121,8 @@ function CollectionsPageDesktop(): React.ReactElement {
onLabelFilter={c.setLabelFilter}
canManageLabels={canManageLabels}
onManageLabels={() => c.setShowLabelManager(true)}
canImport={canAddPlace}
onImport={() => c.setShowImport(true)}
showSelect={showSelect}
selectMode={c.selectMode}
onToggleSelect={() => c.setSelectMode(!c.selectMode)}
@@ -143,9 +146,16 @@ function CollectionsPageDesktop(): React.ReactElement {
<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 className="flex flex-wrap items-center justify-center gap-2">
<button type="button" onClick={() => c.setShowAddPlace(true)} className="col-cta">
<Plus size={16} /> {t('collections.addPlace')}
</button>
{/* An empty list is exactly where a trip import saves the most typing,
so it gets the same billing as adding one place by hand. */}
<button type="button" onClick={() => c.setShowImport(true)} className="col-cta col-cta-ghost">
<DownloadCloud size={16} /> {t('collections.importFromTrip')}
</button>
</div>
)}
</div>
)
@@ -331,6 +341,19 @@ function CollectionsPageDesktop(): React.ReactElement {
/>
)}
{/* Bulk import of a trip's places into the current list */}
{typeof c.activeId === 'number' && c.activeCollection && (
<ImportFromTripModal
isOpen={c.showImport}
collectionId={c.activeId}
collectionName={c.activeCollection.name}
categories={c.categories}
onClose={() => c.setShowImport(false)}
onImported={c.handlePlaceAdded}
t={t}
/>
)}
{/* Copy to trip */}
<CopyToTripModal
isOpen={c.copyIds != null}
@@ -68,6 +68,7 @@ export function useCollections() {
const [mobileRailOpen, setMobileRailOpen] = useState(false)
const [showShare, setShowShare] = useState(false)
const [showAddPlace, setShowAddPlace] = useState(false)
const [showImport, setShowImport] = useState(false)
// The place ids the Copy-to-trip modal is open for (null = closed). Single
// place from the detail panel, or the select-mode set for a bulk copy.
const [copyIds, setCopyIds] = useState<number[] | null>(null)
@@ -403,6 +404,7 @@ export function useCollections() {
// local UI state
editorTarget, setEditorTarget, handleEditorCreated,
showAddPlace, setShowAddPlace, handlePlaceAdded,
showImport, setShowImport,
confirmDeleteList, setConfirmDeleteList,
mobileRailOpen, setMobileRailOpen,
showShare, setShowShare, handleAfterLeave,