Skip to content

feat(analysis): Analysis Mode URL hash deep link support (#617)#652

Merged
cct08311github merged 1 commit intodotnet8from
feat/analysis-url-hash-617
Mar 18, 2026
Merged

feat(analysis): Analysis Mode URL hash deep link support (#617)#652
cct08311github merged 1 commit intodotnet8from
feat/analysis-url-hash-617

Conversation

@cct08311github
Copy link
Copy Markdown
Owner

Summary

  • Add hashSerialize / hashDeserialize pure functions to encode/decode Analysis Mode query state (dims, msrs, filters, pivot, chartType) into URL hash
  • Add hashPush(gridId) — called after each successful query to push state via history.pushState for back-button support
  • Add hashApply(gridId, state) + hashApplyFromLocation(gridId) — programmatically restores drop-zone pills, filter rows, and chart type from hash on page load
  • Register a popstate listener (once at module init) to re-apply state on browser back/forward navigation
  • Hook into renderPanel() (auto-restore on load) and query() success (push state after render)
  • Filter values containing | are handled correctly (split on | with max-3-split)
  • Malformed percent-encoding in hash is safely ignored (no throw)

Tests

  • 16 new Jest tests in framework_analysis.test.js covering: hashDeserialize edge cases (empty, missing gid/vm, malformed encoding), full round-trip parsing (dims/msrs/filters/pivot/chartType), hashPush history API guards
  • Total test count: 486 (all passing)

Test plan

  • Open Analysis Mode on a grid, drag dimensions/measures, apply filters, run query — URL hash updates
  • Copy URL, open in new tab — query state is restored automatically
  • Use browser Back/Forward — state navigates correctly
  • Page with no hash — loads normally, no errors

Closes #617

- Add hashSerialize(gridId) — encodes current dims/msrs/filters/pivot/chartType
  as URLSearchParams-style hash (#gid=…&vm=…&dims=…&msrs=…&f0=…&ct=…)
- Add hashDeserialize(hashStr) — parses hash back to structured state object;
  returns null for missing/malformed gid or vm params
- Add hashApply(gridId, parsed) — restores dims/msrs as drop-zone pills,
  adds filter rows with field/op/value, sets chartType preference, triggers query
- Add hashPush(gridId) — calls history.pushState after each successful query;
  replaceState clears hash when selection is empty
- Register popstate listener (once at module load) to restore query on back/forward
- Call hashApplyFromLocation(gridId) at end of renderPanel() so a fresh page
  load from a shared URL auto-replays the query
- Export all four public functions for testability
- 16 new Jest tests: null/malformed hash, gid/vm parsing, dims/msrs/filters/pivot/
  chartType round-trip, filter value with pipe, history API guards (486 total, all pass)

Closes #617

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@cct08311github cct08311github force-pushed the feat/analysis-url-hash-617 branch from b8bd8b3 to 77d5742 Compare March 18, 2026 13:47
@cct08311github cct08311github merged commit 6f19c4f into dotnet8 Mar 18, 2026
8 checks passed
@cct08311github cct08311github deleted the feat/analysis-url-hash-617 branch March 20, 2026 12:38
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.

enhancement(analysis): Analysis Mode 查詢條件 URL 狀態同步(deep link 支援)

1 participant