mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-11-23 13:23:04 +00:00
3fe34061fd
A saved tour can now be kept in a collection, apart from any trip, and later made into a tour of another trip. The bookmark button in a tour's footer and in the planner's head (waiting for the save while there are unsaved changes) opens a dialog with every list of the user; a list they may only read stays in it, dimmed with a lock and a tooltip. The list keeps an independent copy: the line, the type, every measure and setting, the waypoints in order with their roles, the origin, and the trip and tour it was saved from as they were called then. Its days, its links to places of the trip and its obstacle decisions stay in the trip, and later changes to the tour do not reach the copy. A collection shows its kept tours as cards above its places: the grade tile with the source badge, measures and the waypoint count as badges, the trip it came from, and who kept it. The owner or an admin of the list can remove one after a question; tours made from it stay. "Add to a trip" shows the kept tour on a map with its facts and numbered waypoints, lists the user's trips (the ones they may not add tours to dimmed), and asks outright whether the waypoints come along. "Line only" keeps the line as saved and adds no waypoints; a tour kept without a line can only bring them. The new tour has an id of its own, no days and no new places, and names the trip and tour it was saved from; the dialog then offers to open that trip. Neither the collection nor the original tour changes. On the server the kept tours are a table of their own in the tours domain (collection_tours, migration 046100), each row written whole once. Every copy, the in-trip "save as new tour", the take-over from another trip and both directions here, now goes through one copy model (tour-copy.helpers) instead of a second one. Reading and removing follow the collection's roles, keeping one also needs access to the source trip, and taking one over needs place_edit on the target trip; the kept tour is read again inside the write, so one removed meanwhile leaves no half-made tour. The MCP tools list_collection_tours, get_collection_tour, save_tour_to_collection, take_over_collection_tour and delete_collection_tour run over the same service and checks. All 27 locales carry the new strings, and the wiki describes the flow.
73 lines
3.7 KiB
TypeScript
73 lines
3.7 KiB
TypeScript
import type { StoreApi } from 'zustand';
|
|
import { useAddonStore } from '../../src/store/addonStore';
|
|
import { useAuthStore } from '../../src/store/authStore';
|
|
import { useInAppNotificationStore } from '../../src/store/inAppNotificationStore';
|
|
import { usePaddleObstacleStore } from '../../src/store/paddleObstacleStore';
|
|
import { usePermissionsStore } from '../../src/store/permissionsStore';
|
|
import { useSettingsStore } from '../../src/store/settingsStore';
|
|
import { useTourMapViewportStore } from '../../src/store/tourMapViewportStore';
|
|
import { useTourMapVisibilityStore } from '../../src/store/tourMapVisibilityStore';
|
|
import { useTrackMarkToolStore } from '../../src/store/trackMarkToolStore';
|
|
import { useTripStore } from '../../src/store/tripStore';
|
|
import { useVacayStore } from '../../src/store/vacayStore';
|
|
|
|
/**
|
|
* Every Zustand store in src/, and what resetAllStores does with it.
|
|
*
|
|
* RESET_STORES are put back to the state they had when this module was first
|
|
* imported, before any test touched them. UNRESET_STORES are left alone, each
|
|
* with the reason; their tests reset them on their own. The registry test
|
|
* (tests/unit/helpers/storeRegistry.test.ts) finds every `export const
|
|
* use…Store = create…` under src/ and fails on one that is in neither list,
|
|
* so a new store has to be placed here instead of being forgotten by the
|
|
* reset and leaking state from one test into the next.
|
|
*
|
|
* The stores are imported by name rather than through a glob: an eager glob
|
|
* would load every store module into each of the hundreds of test files that
|
|
* reset, including the ones that mock a store module or import it in a
|
|
* particular order (journeyStore), and a store moved from UNRESET to RESET
|
|
* changes what those files start from. Each such move is its own change.
|
|
*/
|
|
type ResettableStore = Pick<StoreApi<object>, 'getState' | 'setState'>;
|
|
|
|
export const RESET_STORES: Record<string, ResettableStore> = {
|
|
useAuthStore,
|
|
useTripStore,
|
|
useSettingsStore,
|
|
useVacayStore,
|
|
useAddonStore,
|
|
useInAppNotificationStore,
|
|
usePermissionsStore,
|
|
useTourMapVisibilityStore,
|
|
useTourMapViewportStore,
|
|
usePaddleObstacleStore,
|
|
useTrackMarkToolStore,
|
|
};
|
|
|
|
/** Not reset so far; moving one into RESET_STORES changes what every file that resets starts from. */
|
|
const NOT_YET = 'never reset by resetAllStores; its own tests set the state they need';
|
|
|
|
export const UNRESET_STORES: Record<string, string> = {
|
|
useJourneyStore: 'reset in the journey tests themselves; importing it here pulls in a circular import',
|
|
useBackgroundTasksStore: NOT_YET,
|
|
useCollectionStore: NOT_YET,
|
|
useCollectionTourStore: 'its own tests put it back with clear(); it holds one open collection and nothing else reads it',
|
|
useDocSyncOfferStore: NOT_YET,
|
|
useHelpStore: NOT_YET,
|
|
usePluginStore: NOT_YET,
|
|
useRoadtripPreferencesStore: NOT_YET,
|
|
useSaveToCollectionStore: NOT_YET,
|
|
useServerVersionStore: NOT_YET,
|
|
useStudioStore: NOT_YET,
|
|
useSystemNoticeStore: NOT_YET,
|
|
useTourActivityCompareStore:
|
|
'the actual track compared on the map and whether the map can draw it; the tests that read it reset both in their own beforeEach',
|
|
useTourFerrataCrossingStore: 'set by the tour map stage; the tests that read it reset it in their own beforeEach',
|
|
useTourPlaceToolStore: 'reset in the tour tests themselves to initialTourPlaceToolState()',
|
|
useTourPoiStore: 'the places found along a tour; the tests that read it clear it in their own beforeEach',
|
|
useTourRouteHighlightStore:
|
|
'the stretches a bike card points at; the tests that read it clear it in their own beforeEach',
|
|
useTourVisitStore: 'the visits of city walks per day; the tests that read it reset it in their own beforeEach',
|
|
useTripJournalLinkStore: 'the journal link per trip; the tests that read it reset it in their own beforeEach',
|
|
};
|