feat: add public map sort by date option#437
Open
joaquimds wants to merge 1 commit into
Open
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Adds configurable sorting for public map listings (by record name or record date, with direction), implementing the sort client-side to respect public-map-specific name/date settings. The PR also removes the old server-side “sort by data source nameColumns” mechanism and adds cleanup to purge deleted data source IDs from map/mapView/publicMap configs, with a new unit test covering that behavior.
Changes:
- Add
sortBy/sortDirectionto public map data source configs and expose UI controls in the publish editor. - Implement client-side listing sorting (name/date) while keeping server-side sort only for proximity searches.
- Purge deleted data source references across maps, map views, and public maps (plus unit tests).
Reviewed changes
Copilot reviewed 15 out of 15 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| tests/unit/server/repositories/removeDataSourceReferences.test.ts | New unit test verifying data source reference cleanup across map/mapView/publicMap. |
| src/utils/dataRecord.ts | Adds getListingSort defaulting logic (events default to date/asc). |
| src/server/trpc/routers/dataSource.ts | On data source delete, triggers reference cleanup across related configs. |
| src/server/repositories/PublicMap.ts | Adds updatePublicMap and cleanup for deleted data source IDs in live + draft configs. |
| src/server/repositories/MapView.ts | Adds updateMapView and cleanup removing deleted data source IDs from views + choropleth config. |
| src/server/repositories/Map.ts | Adds cleanup removing deleted data source IDs from map config. |
| src/server/repositories/DataRecord.ts | Removes special “__name” sort path and related async nameColumns lookup. |
| src/models/PublicMap.ts | Extends schema with optional sortBy / sortDirection. |
| src/constants/index.ts | Adds sort option lists; removes SORT_BY_NAME_COLUMNS. |
| src/app/(private)/map/[id]/publish/utils.ts | Adds sortRecordsForListing (name/date, direction) for public listings. |
| src/app/(private)/map/[id]/publish/hooks/usePublicMap.ts | Filters out non-existent public data source IDs (now depends on useDataSources). |
| src/app/(private)/map/[id]/publish/hooks/usePublicDataRecordsQueries.ts | Removes default name sort; keeps server sort only for proximity. |
| src/app/(private)/map/[id]/publish/components/editable/EditorDataSettings.tsx | Adds listing sort controls in publish editor UI. |
| src/app/(private)/map/[id]/publish/components/DataRecordsList.tsx | Applies client-side sort unless proximity search is active. |
| src/app/(private)/map/[id]/hooks/useMarkerQueries.ts | Switches marker DS selection based on mapMode (“public” vs “private”). |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
681
to
693
| delete: dataSourceOwnerProcedure.mutation(async ({ ctx }) => { | ||
| await deleteDataSource(ctx.dataSource.id); | ||
| // Purge references to the deleted data source from the org's maps, | ||
| // map views, and public maps so they don't linger as orphans. | ||
| const ref = { | ||
| organisationId: ctx.dataSource.organisationId, | ||
| dataSourceId: ctx.dataSource.id, | ||
| }; | ||
| await removeDataSourceFromMaps(ref); | ||
| await removeDataSourceFromMapViews(ref); | ||
| await removeDataSourceFromPublicMaps(ref); | ||
| return true; | ||
| }), |
Comment on lines
+69
to
+73
| // Hide references to data sources that no longer exist (e.g. deleted), | ||
| // mirroring how private maps filter via useMarkerDataSources. While the | ||
| // data sources are still loading, keep the unfiltered list to avoid a flash. | ||
| if (!dataSources) { | ||
| return ids; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Motivation and Context
How Can It Be Tested?
How Will This Be Deployed?
Screenshots (if appropriate):
Types of changes
Checklist: