Add province merge UI and merge logic#1433
Merged
Merged
Conversation
Add a "Merge provinces" button to the provinces toolbar and implement the modal dialog and merge behavior. The new dialog lists provinces in the currently filtered state, lets the user pick a primary province (radio) and select others (checkboxes), highlights provinces on hover, and confirms the destructive merge. Implement mergeProvinces(ids, primary) to move burgs and cell assignments to the primary province, mark merged provinces as removed, update the state's province list, and trigger a redraw when province layer is visible. Also harden provinceHighlightOff to handle missing targets and ensure highlight paths are removed when exiting.
✅ Deploy Preview for afmg ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
Contributor
There was a problem hiding this comment.
Pull request overview
This PR adds a “Merge provinces” capability to the Provinces Editor, aligning provinces tooling with the existing “merge states” workflow by introducing a merge dialog UI, hover highlighting, and underlying merge logic that consolidates selected provinces into a chosen primary province.
Changes:
- Added a “Merge provinces” toolbar button to the Provinces Editor UI.
- Implemented a merge dialog that lists provinces within the currently selected (filtered) state, supports choosing a primary province, and highlights provinces on hover.
- Added
mergeProvinces(ids, primary)logic to reassign burgs/cells and mark merged provinces as removed, plus a robustness update toprovinceHighlightOff.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| src/index.html | Adds the “Merge provinces” button to the provinces toolbar. |
| public/modules/ui/provinces-editor.js | Wires up the button, implements merge dialog + hover highlighting, adjusts highlight cleanup, and adds province merge logic. |
* calling drawProvinces() and then refreshing the editor UI. * function cleanupMergedProvince for removed provinces. * Single pass over pack.cells.province using a lookup to remap all merged province ids at once.
* Borders: Province merging changes cell ownership, so borders must be redrawn. * Statistics: Area and population calculations become invalid after merging. * Poles: Used for province label positioning and COA placement. * Fog/Debug: Prevents stale visual artifacts from remaining on the map.
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.
Added a "Merge provinces" button to the provinces toolbar. Implemented the merge behavior and the UI for the feature. When the button is clicked, a dialog opens. The new dialog lists provinces in the currently filtered state and lets the user pick a primary province (radio button) and select others provinces (checkboxes) inside that state.

Added a highlight province on hover like the one is already on "merge states" feature. Once the user decides and clicks "merge", a confirmation dialog appears. User can confirm the destructive merge.
Implemented mergeProvinces(ids, primary) to move burgs and cell assignments to the primary province, mark merged provinces as removed, update the state's province list, and trigger a redraw when province layer is visible. Also harden provinceHighlightOff to handle missing targets and ensure highlight paths are removed when exiting.