mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-12-01 17:03:15 +00:00
feat(tours): take a tour over from another trip, the dialog (LIB-02)
The Tours tab's list of the trip's tours gains a button beside the GPX import: take a tour over from another trip. Its dialog lists the tours of the user's other trips, searched by name and filtered by trip and type, each with its trip and the measures it has (time, distance, ascent; one it lacks is left out, a paddle tour's climb too). Choosing one shows it on a map with where it comes from, its type, distance, time, heights and number of waypoints, and the name it gets in this trip, its own name to start with. The note under the name says the copy is a tour of this trip of its own, on no day yet, and that later changes stay apart. Only the button in the foot takes it over. The new tour then comes into the trip's lists and map and opens in the editor, unless the editor holds unsaved work, which it never replaces. Nothing is written before the confirm, and closing writes nothing. The library is online only: offline, or when the list fails, the dialog says so and offers to try again; a list cut at 100 tours says to search or filter. A tour taken over names its source in its provenance: "Taken over from" with the trip and the tour as they were called then.
This commit is contained in:
@@ -43,6 +43,7 @@ import { TourRemoteChangeNotice, TourRevisionConflictDialog } from './TourRevisi
|
||||
import TourListFilterMenu, { TourFilterEmpty } from '../TourListFilterMenu'
|
||||
import { TourScopeSummary } from '../TourScopeSummary'
|
||||
import { useTourListFilters } from '../useTourListFilters'
|
||||
import { TourLibraryEntry } from '../library/TourLibraryDialog'
|
||||
|
||||
const STATUS_KEY: Partial<Record<TourPlannerStatus, string>> = {
|
||||
dirty: 'tours.planner.status.dirty',
|
||||
@@ -609,6 +610,8 @@ interface TourPlannerToursRailProps extends TourPermissionProps {
|
||||
onDeleteTour?: (placeId: number) => void
|
||||
/** The workspace's GPX import; its button sits beside "New tour". */
|
||||
gpxImport?: TourGpxImport
|
||||
/** LIB-02: takes a tour of another trip in; its button sits beside the import. */
|
||||
onTakenOver?: (tour: TourListItem) => Promise<void>
|
||||
}
|
||||
|
||||
/** The time facts of the overview: the estimate (walking, or paddling for a paddle tour), the breaks and the planned total. */
|
||||
@@ -641,7 +644,7 @@ function plannerTimeFields(planner: TourPlannerController, t: Translate) {
|
||||
}
|
||||
|
||||
export function TourPlannerToursRail({ planner, tours, days, loading, onAssignToDay, onViewGpxTour, onDeleteTour,
|
||||
gpxImport, canEdit: editPermission, canAssign: assignPermission }: TourPlannerToursRailProps) {
|
||||
gpxImport, onTakenOver, canEdit: editPermission, canAssign: assignPermission }: TourPlannerToursRailProps) {
|
||||
const { canEdit, canAssign } = useTourPermissions({ canEdit: editPermission ?? planner.canEdit, canAssign: assignPermission ?? planner.canAssign })
|
||||
const { t } = useTranslation()
|
||||
const toast = useToast()
|
||||
@@ -693,6 +696,7 @@ export function TourPlannerToursRail({ planner, tours, days, loading, onAssignTo
|
||||
<div className={RAIL_HEAD} style={{ background: NEUTRAL_TINT }}>
|
||||
<RailTitle title={t('tours.planner.tripTours')} />
|
||||
{canEdit && gpxImport && <RailImportButton gpxImport={gpxImport} disabled={isSaving} />}
|
||||
{canEdit && <TourLibraryEntry planner={planner} onTakenOver={onTakenOver} disabled={isSaving} />}
|
||||
{canEdit && planner.mode.type !== 'neutral' && (
|
||||
<BarButton label={t('tours.planner.newTour')} testId="tour-rail-new-tour" disabled={isSaving}
|
||||
onClick={() => { if (!isSaving) planner.startNewTour() }}
|
||||
|
||||
Reference in New Issue
Block a user