Skip to content

feat: add public map sort by date option#437

Open
joaquimds wants to merge 1 commit into
mainfrom
feat/public-map-sort-by-date
Open

feat: add public map sort by date option#437
joaquimds wants to merge 1 commit into
mainfrom
feat/public-map-sort-by-date

Conversation

@joaquimds
Copy link
Copy Markdown
Member

Description

Motivation and Context

How Can It Be Tested?

How Will This Be Deployed?

Screenshots (if appropriate):

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist:

  • I've checked the spec (e.g. Figma file) and documented any divergences.
  • My code follows the code style of this project.
  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I've updated the documentation accordingly.
  • Replace unused checkboxes with bullet points.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 / sortDirection to 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;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants