Skip to content

feat: allow many-to-one region mapping and multi-territory drill-down - #1243

Open
AdnanQuazi wants to merge 2 commits into
frappe:developfrom
AdnanQuazi:feat/many-to-one-map-regions
Open

feat: allow many-to-one region mapping and multi-territory drill-down#1243
AdnanQuazi wants to merge 2 commits into
frappe:developfrom
AdnanQuazi:feat/many-to-one-map-regions

Conversation

@AdnanQuazi

Copy link
Copy Markdown
Contributor

Overview

Resolves an issue where users could only map a single territory to a target region on Map charts (e.g., mapping South India -> India blocked mapping North India -> India or West India -> India). Previously, mapping multiple territories resulted in region selection disappearing from the UI, and the map click index overwritten previous mappings so drill-down only queried the last-mapped territory (WHERE territory = 'West India').

This PR removes the 1-to-1 UI restriction and updates the map chart indexing engine (locationRowIndex) to accumulate all matching raw values. When a map polygon with multiple mapped territories is clicked, the drill-down query dynamically upgrades the exact-match (=) filter to an in filter matching against the raw schema column name (WHERE territory IN ('South India', 'North India', 'West India')).

Key Changes

  • CHARTS (RegionMappingDialog.vue): Removed usedRegions restriction in getOptions() so users can select and map multiple dataset locations/territories to the same target map region.
  • CHARTS (ChartRenderer.vue): Updated locationRowIndex from single-row overwriting to storing { firstRow, rawValues: Set<string> } per map region. Updated handleMapChartClick to upgrade the drill-down query's dimension filter from = to in using the stable schema column (mapConfig.location_column.column_name) when multiple raw values resolve to the clicked map region.

Closes #1085

@mergify

mergify Bot commented Jul 15, 2026

Copy link
Copy Markdown
Contributor

Tick the box to add this pull request to the merge queue (same as @mergifyio queue).

  • Queue this pull request

@greptile-apps

greptile-apps Bot commented Jul 15, 2026

Copy link
Copy Markdown

Confidence Score: 5/5

Change is safe to merge; the fresh-query pattern in getDrillDownQuery makes the in-place filter mutation side-effect-free, and the logic correctly handles single- and multi-territory regions.

The filter mutation targets a freshly-created query object each time, the rawValues Set correctly de-duplicates and accumulates territories under a shared mapped region, and the !mutated guard prevents returning a stale single-territory query when the filter structure doesn't match expectations.

No files require special attention.

Reviews (2): Last reviewed commit: "fix: return null when no matching filter..." | Re-trigger Greptile

Comment thread frontend/src2/charts/components/ChartRenderer.vue
@AdnanQuazi
AdnanQuazi marked this pull request as draft July 15, 2026 20:26
@codecov-commenter

codecov-commenter commented Jul 15, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 47.70%. Comparing base (83bcccf) to head (0b79ef6).
⚠️ Report is 54 commits behind head on develop.

Additional details and impacted files
@@             Coverage Diff             @@
##           develop    #1243      +/-   ##
===========================================
- Coverage    47.91%   47.70%   -0.22%     
===========================================
  Files           76       76              
  Lines         5998     6002       +4     
===========================================
- Hits          2874     2863      -11     
- Misses        3124     3139      +15     
Flag Coverage Δ
server 47.70% <ø> (-0.22%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@AdnanQuazi
AdnanQuazi marked this pull request as ready for review July 15, 2026 21:32
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.

Issue with 'Resolve Locations' in map chart

2 participants