mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-12-05 02:14:05 +00:00
feat(places): notes, visits, tours, history, tags and location in the place sheet, saved lists on the trip map
Both the desktop sheet and the phone sheet of All places show the place's location as a badge, its notes per list, its visits from trips (hidden without any), linked tours and bookings, its change history and the reader's own tags with a tag filter. A trip map can show the places of linked lists and add one to the trip. All places reloads after a list is added or removed.
This commit is contained in:
@@ -42,6 +42,7 @@ import type { EndDayControlProps } from '../Roadtrip/EndDayControl'
|
||||
import VisitControls, { type RoadtripStayControl } from '../Roadtrip/VisitControls'
|
||||
import { DialogButton, DialogIconButton, DialogSection, DeleteButton, FooterSpacer, fs } from '../shared/DialogShell'
|
||||
import { BOX, Field, TypeTile, toneOf, toneTint, useOpenFile } from './bookings/bookingParts'
|
||||
import TripPlaceVisits from '../Collections/TripPlaceVisits'
|
||||
import { parseMeta } from './bookings/bookingsModel'
|
||||
import { MoreButton, SoftPill } from './planParts'
|
||||
import { InspectorHead } from './PlaceInspectorHead'
|
||||
@@ -446,6 +447,7 @@ export default function PlaceInspector({
|
||||
onFileUpload={onFileUpload} filesExpanded={filesExpanded} setFilesExpanded={setFilesExpanded}
|
||||
fileInputRef={fileInputRef} handleFileUpload={handleFileUpload} isUploading={isUploading}
|
||||
distanceUnit={distanceUnit} onUpdatePlace={onUpdatePlace} />
|
||||
{mode === 'trip' && trip && <TripPlaceVisits trip={trip} place={place} language={locale} t={t} />}
|
||||
|
||||
{/* Extra native rows from placeDetailProvider plugins (#1429). */}
|
||||
{mode === 'trip' && providerDetails.length > 0 && (
|
||||
|
||||
@@ -149,7 +149,7 @@ function CategoryChoice({ on, onClick, tile, label }: { on: boolean; onClick: ()
|
||||
function ShowDropdown(S: SidebarState) {
|
||||
const { t, filter, pickFilter, filterCounts } = S
|
||||
const [open, setOpen] = useState(false)
|
||||
const tabs = placesFilterTabs(t, S.hasTracks)
|
||||
const tabs = placesFilterTabs(t, S.hasTracks, S.hasVisited)
|
||||
const current = tabs.find(tab => tab.id === filter) ?? tabs[0]
|
||||
return (
|
||||
<FilterDropdown
|
||||
|
||||
@@ -13,7 +13,7 @@ function colorFor(userId: number) {
|
||||
return SPLIT_COLORS[(((Math.trunc(userId) - 1) % n) + n) % n]
|
||||
}
|
||||
|
||||
function Avatar({ userId, username, avatarUrl, size = 22, dim = false }: {
|
||||
export function Avatar({ userId, username, avatarUrl, size = 22, dim = false }: {
|
||||
userId: number
|
||||
username?: string
|
||||
avatarUrl?: string | null
|
||||
|
||||
@@ -8,8 +8,8 @@ import { offlineOr } from '../../utils/needsConnection';
|
||||
import { tagChoices } from '../../utils/placeTags';
|
||||
import { useToast } from '../shared/Toast';
|
||||
|
||||
/** What the pool shows: everything, what is not on a day yet, what is, or the tracks. */
|
||||
export type PlacesFilter = 'all' | 'unplanned' | 'planned' | 'tracks';
|
||||
/** What the pool shows: everything, what is not on a day yet, what is, what the reader visited, or the tracks. */
|
||||
export type PlacesFilter = 'all' | 'unplanned' | 'planned' | 'visited' | 'tracks';
|
||||
|
||||
type Translate = ReturnType<typeof useTranslation>['t'];
|
||||
|
||||
@@ -18,13 +18,14 @@ export function poolHasTracks(places: Place[], toursEnabled: boolean | undefined
|
||||
return !toursEnabled && places.some((p) => p.route_geometry);
|
||||
}
|
||||
|
||||
/** The "show" choices; tracks only once a place has one. */
|
||||
export function placesFilterTabs(t: Translate, hasTracks: boolean) {
|
||||
/** The "show" choices; "visited" once the reader confirmed a visit at a place of the trip, tracks once a place has one. */
|
||||
export function placesFilterTabs(t: Translate, hasTracks: boolean, hasVisited = false) {
|
||||
const tabs: Array<{ id: PlacesFilter; label: string }> = [
|
||||
{ id: 'all', label: t('places.all') },
|
||||
{ id: 'unplanned', label: t('places.unplanned') },
|
||||
{ id: 'planned', label: t('places.planned') },
|
||||
];
|
||||
if (hasVisited) tabs.push({ id: 'visited', label: t('places.filterVisited') });
|
||||
if (hasTracks) tabs.push({ id: 'tracks', label: t('places.filterTracks') });
|
||||
return tabs;
|
||||
}
|
||||
|
||||
@@ -15,6 +15,7 @@ import { placeToSaveTarget } from '../Collections/saveTarget'
|
||||
import type { Place, Category, Day, AssignmentsMap } from '../../types'
|
||||
import { getGoogleMapsUrlForPlace } from './placeGoogleMaps'
|
||||
import { placeMatchesSearch } from '../../utils/placeSearch'
|
||||
import { useTripVisitedIds } from '../../hooks/useTripVisitedIds'
|
||||
import { matchesCategoryFilter, matchesPlacesFilter } from '../../utils/placesFilter'
|
||||
import { safeHttpUrl } from '../../utils/safeUrl'
|
||||
import { plannedPlaceIds, plannedPlaceIdsForDay, type PlannedAccommodation } from '../../utils/plannedPlaces'
|
||||
@@ -194,16 +195,17 @@ export function usePlacesSidebar(props: PlacesSidebarProps) {
|
||||
)
|
||||
const plannedFilterIds = plannedInDayIds ?? plannedIds
|
||||
const dayScoped = filter === 'planned' && plannedInDayIds !== null
|
||||
const visitedIds = useTripVisitedIds(tripId)
|
||||
|
||||
const filtered = useMemo(() => {
|
||||
const list = poolPlaces.filter(p => {
|
||||
if (!matchesPlacesFilter(p, { filter, categoryFilters, ratingFilter }, { plannedIds, plannedFilterIds })) return false
|
||||
if (!matchesPlacesFilter(p, { filter, categoryFilters, ratingFilter }, { plannedIds, plannedFilterIds, visitedIds })) return false
|
||||
if (!placeMatchesSearch(p, search)) return false
|
||||
if (localityFilter && !matchesLocality(localityOf.get(p.id), localityFilter)) return false
|
||||
return true
|
||||
})
|
||||
return sortPlaces(list, placesSort, language)
|
||||
}, [poolPlaces, filter, categoryFilters, search, plannedIds, plannedFilterIds, ratingFilter, localityFilter, localityOf, placesSort, language])
|
||||
}, [poolPlaces, filter, categoryFilters, search, plannedIds, plannedFilterIds, visitedIds, ratingFilter, localityFilter, localityOf, placesSort, language])
|
||||
|
||||
/**
|
||||
* How many places each "show" choice would leave, under the category and search
|
||||
@@ -218,9 +220,10 @@ export function usePlacesSidebar(props: PlacesSidebarProps) {
|
||||
all: base.length,
|
||||
unplanned: base.filter(p => !plannedIds.has(p.id)).length,
|
||||
planned: base.filter(p => plannedFilterIds.has(p.id)).length,
|
||||
visited: base.filter(p => visitedIds.has(p.id)).length,
|
||||
tracks: base.filter(p => p.route_geometry).length,
|
||||
} satisfies Record<PlacesFilter, number>
|
||||
}, [poolPlaces, categoryFilters, search, plannedIds, plannedFilterIds])
|
||||
}, [poolPlaces, categoryFilters, search, plannedIds, plannedFilterIds, visitedIds])
|
||||
|
||||
/** The filters narrowing the list besides the search box, for the badge on the filter button. */
|
||||
|
||||
@@ -316,7 +319,7 @@ export function usePlacesSidebar(props: PlacesSidebarProps) {
|
||||
markSelectionVisited, markVisitedBusy,
|
||||
exitSelectMode, toggleSelected, toggleCategoryFilter, dayPickerPlace, setDayPickerPlace,
|
||||
mobileShowDays, setMobileShowDays,
|
||||
hasTracks, plannedIds, plannedFilterIds, dayScoped, filtered, registerPlaceRow, isAssignedToSelectedDay, inDaySet,
|
||||
hasTracks, hasVisited: visitedIds.size > 0 || filter === 'visited', plannedIds, plannedFilterIds, dayScoped, filtered, registerPlaceRow, isAssignedToSelectedDay, inDaySet,
|
||||
openContextMenu, placeMenuItems,
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user