mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-12-04 09:54:14 +00:00
feat(tours): the trip's tour totals by type above the tour list (STA-01)
The Tours tab's list of the trip's tours gains the filter the plan's tour list has, and above the list a card with what the tours shown add up to: how many, how many are on a day and how many not, then per type distance, ascent and descent, and the three kinds of time apart, the router's for tours planned in TREK, the one an import brought, and the planned one with breaks. Nothing is added up across types. The filter narrows the list and the totals alike. Each tour counts once however many days it is on; the list is one row a tour. A value no tour has is left out rather than shown as zero, and a sum some tours lack is shown as at least that much, its info dot saying for how many of how many it is known. Paddling sums no heights: on the water a climb says nothing, and a planned paddle tour's heights would be the banks'. The card folds to its counts, remembered in this browser. The empty state for a filter that leaves nothing is shared by both lists now.
This commit is contained in:
@@ -151,8 +151,9 @@ describe('TourPlannerToursRail', () => {
|
||||
|
||||
expect(screen.getByRole('complementary', { name: 'Tours of this trip' })).toBeInTheDocument()
|
||||
expect(screen.getByRole('option', { name: /Saved ridge walk/i })).toHaveTextContent('4 km')
|
||||
expect(screen.getByText('Ascent')).toBeInTheDocument()
|
||||
expect(screen.getByText('50 m')).toBeInTheDocument()
|
||||
const overview = screen.getByTestId('tour-planner-overview')
|
||||
expect(within(overview).getByText('Ascent')).toBeInTheDocument()
|
||||
expect(within(overview).getByText('50 m')).toBeInTheDocument()
|
||||
expect(document.querySelector('svg[viewBox="0 0 440 100"]')).toBeInTheDocument()
|
||||
expect(screen.queryByText('Routing is planning assistance, not a safety guarantee.')).not.toBeInTheDocument()
|
||||
})
|
||||
|
||||
@@ -40,6 +40,9 @@ import { type AssignTourToDay, useTourDayAssignment } from '../useTourDayAssignm
|
||||
import WandererMark from '../wanderer/WandererMark'
|
||||
import { TourGpxExportBarButton } from '../TourGpxExportButton'
|
||||
import { TourRemoteChangeNotice, TourRevisionConflictDialog } from './TourRevisionNotice'
|
||||
import TourListFilterMenu, { TourFilterEmpty } from '../TourListFilterMenu'
|
||||
import { TourScopeSummary } from '../TourScopeSummary'
|
||||
import { useTourListFilters } from '../useTourListFilters'
|
||||
|
||||
const STATUS_KEY: Partial<Record<TourPlannerStatus, string>> = {
|
||||
dirty: 'tours.planner.status.dirty',
|
||||
@@ -645,6 +648,8 @@ export function TourPlannerToursRail({ planner, tours, days, loading, onAssignTo
|
||||
const distanceUnit = useSettingsStore(state => state.settings.distance_unit)
|
||||
const [pendingTour, setPendingTour] = useState<TourListItem | null>(null)
|
||||
const dayAssignment = useTourDayAssignment({ canAssign, onAssignToDay })
|
||||
// STA-01: one filter for the list and the summary above it, the same as the plan's tour list.
|
||||
const filters = useTourListFilters(tours)
|
||||
const isSaving = planner.isSaving
|
||||
const hasRoute = (planner.mode.type === 'new-draft' || planner.mode.type === 'edit-saved') && planner.route !== null
|
||||
// A paddle tour's heights are read off the banks, not the water: they stay unknown.
|
||||
@@ -723,17 +728,21 @@ export function TourPlannerToursRail({ planner, tours, days, loading, onAssignTo
|
||||
) : tours.length === 0 ? (
|
||||
<p className="m-0 py-6 text-center text-content-faint" style={fs(12, 'body')}>{t('common.loading')}</p>
|
||||
) : (
|
||||
<>
|
||||
<TourListFilterMenu filters={filters} />
|
||||
<TourScopeSummary tours={filters.filtered} />
|
||||
{filters.emptyByFilter ? <TourFilterEmpty filters={filters} /> : (
|
||||
<TourListCard
|
||||
icon={<Mountain size={14} strokeWidth={2} />}
|
||||
title={t('tours.mode.tours')}
|
||||
aside={
|
||||
<span className="flex-none tabular-nums text-content-faint" style={fs(11.5, 'body')}>
|
||||
{tours.length}
|
||||
{filters.filtered.length}
|
||||
</span>
|
||||
}
|
||||
label={t('tours.planner.tripTours')}
|
||||
>
|
||||
{tours.map(tour => (
|
||||
{filters.filtered.map(tour => (
|
||||
<TourListRow
|
||||
key={tour.place_id}
|
||||
tour={tour}
|
||||
@@ -769,6 +778,8 @@ export function TourPlannerToursRail({ planner, tours, days, loading, onAssignTo
|
||||
/>
|
||||
))}
|
||||
</TourListCard>
|
||||
)}
|
||||
</>
|
||||
)}
|
||||
</div>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user