mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-10-18 21:16:47 +00:00
refactor(places): one name for the uncategorized bucket and the category matcher
PlacesSidebarHeader uses the UNCATEGORIZED constant, placesBrowserModel stops re-exporting matchesCategoryFilter (its test imports it from utils/placesFilter), and the orphan comment in the en places strings joins the places.filters key.
This commit is contained in:
@@ -9,7 +9,7 @@ import { tintOf } from './planParts'
|
||||
import { CategoryTile } from './PlacesBulkCategoryModal'
|
||||
import type { PlacesFilter, SidebarState } from './usePlacesSidebar'
|
||||
import { PLACES_SORTS, type PlacesSort } from './placesSort'
|
||||
import { RATING_FLOORS } from '../../utils/placesFilter'
|
||||
import { RATING_FLOORS, UNCATEGORIZED } from '../../utils/placesFilter'
|
||||
|
||||
/**
|
||||
* Below this the two labels stop fitting side by side and both buttons fall back
|
||||
@@ -259,7 +259,7 @@ function CategoryFilter(S: SidebarState) {
|
||||
let label = t('places.allCategories')
|
||||
if (categoryFilters.size === 1) {
|
||||
const only = categories.find(c => categoryFilters.has(String(c.id)))
|
||||
if (categoryFilters.has('uncategorized')) label = t('places.noCategory')
|
||||
if (categoryFilters.has(UNCATEGORIZED)) label = t('places.noCategory')
|
||||
else if (only) label = only.name
|
||||
} else if (categoryFilters.size > 1) {
|
||||
label = `${categoryFilters.size} ${t('places.categoriesSelected')}`
|
||||
@@ -278,8 +278,8 @@ function CategoryFilter(S: SidebarState) {
|
||||
))}
|
||||
{places.some(p => p.category_id == null) && (
|
||||
<CategoryChoice
|
||||
on={categoryFilters.has('uncategorized')}
|
||||
onClick={() => toggleCategoryFilter('uncategorized')}
|
||||
on={categoryFilters.has(UNCATEGORIZED)}
|
||||
onClick={() => toggleCategoryFilter(UNCATEGORIZED)}
|
||||
tile={<CategoryTile size={22} />}
|
||||
label={t('places.noCategory')}
|
||||
/>
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
import { describe, it, expect } from 'vitest'
|
||||
import {
|
||||
filterPool, firstPlannedDayNumbers, matchesCategoryFilter, matchesSearch,
|
||||
filterPool, firstPlannedDayNumbers, matchesSearch,
|
||||
plannedPlaceIds, poolCounts,
|
||||
} from './placesBrowserModel'
|
||||
import { matchesCategoryFilter } from '../../../../utils/placesFilter'
|
||||
import type { AssignmentsMap, Day, Place } from '../../../../types'
|
||||
|
||||
const mkPlace = (id: number, over: Partial<Place> = {}): Place =>
|
||||
|
||||
@@ -17,9 +17,6 @@ import {
|
||||
* there.
|
||||
*/
|
||||
|
||||
/** Kept under this name for the browser's callers; the predicate itself lives in utils/placesFilter. */
|
||||
export { matchesCategoryFilter }
|
||||
|
||||
export function plannedPlaceIds(
|
||||
assignments: AssignmentsMap,
|
||||
accommodations: PlannedAccommodation[] = [],
|
||||
|
||||
@@ -61,10 +61,12 @@ const places: TranslationStrings = {
|
||||
'places.sortUpdated': 'Recently changed',
|
||||
'places.filterByLocation': 'Filter by country or region',
|
||||
'places.allLocations': 'All countries',
|
||||
/** The button that opens the filter panel, and the panel's name. */
|
||||
/** Label over the all/unplanned/planned/tracks choice in the filter panel. */
|
||||
'places.filterShow': 'Show',
|
||||
/** The phone map's button that opens the places filter sheet, and the sheet's title. */
|
||||
/**
|
||||
* The button that opens the places filter panel, and the panel's name: the phone
|
||||
* map's control and the title of its sheet, and the phone places list's panel button.
|
||||
*/
|
||||
'places.filters': 'Filters',
|
||||
'places.clearSearch': 'Clear search',
|
||||
'places.yourRating': 'Your rating',
|
||||
|
||||
Reference in New Issue
Block a user