Skip to content

Filtering location options for Address & Location inputs, add user.jurisdiction() and user.scope().attribute() reference functions to toolkit#11858

Merged
cibelius merged 66 commits intodevelopfrom
ocrvs-11378
Mar 5, 2026
Merged

Filtering location options for Address & Location inputs, add user.jurisdiction() and user.scope().attribute() reference functions to toolkit#11858
cibelius merged 66 commits intodevelopfrom
ocrvs-11378

Conversation

@cibelius
Copy link
Copy Markdown
Contributor

@cibelius cibelius commented Feb 23, 2026

Description

Resolves: #11378

CC PR: opencrvs/opencrvs-countryconfig#1285
Farajaland PR: opencrvs/opencrvs-farajaland#1982

Location and administrative area filtering in frontend inputs

Affects:

  • FieldType.ADDRESS
  • FieldType.LOCATION
  • FieldType.OFFICE
  • FieldType.FACILITY

Changes:

  • Add allowedLocations to field config options
  • Add filtering of available locations to LocationSearch.tsx
  • Add filtering of available administrative areas to AdministrativeArea.tsx
  • Switch LocationSearch.tsx to use <SearchableSelect/> instead of <LocationSearchComponent/>

User jurisdiction and scope reference functions

  • Add support for user reference functions:
    • user.jurisdiction()
    • user.scope(<scopeName>).attribute(<attributeName>)
  • Add helpers for getting attributes out of scopes and resolving jurisdiction filter references

Misc.

  • Rename isOfficeUnderJurisdiction() -> isLocationUnderJurisdiction()
  • Remove unused functions from packages/client/src/utils/locationUtils.ts()

Performance test with 100k locations:

Minor lag noticeable (1-2sec)

Screen.Recording.2026-03-03.at.9.19.41.mov

Checklist

  • I have linked the correct Github issue under "Development"
  • I have tested the changes locally, and written appropriate tests
  • I have tested beyond the happy path (e.g. edge cases, failure paths)
  • I have updated the changelog with this change (if applicable)
  • I have updated the GitHub issue status accordingly

@github-actions
Copy link
Copy Markdown

Oops! Looks like you forgot to update the changelog. When updating CHANGELOG.md, please consider the following:

  • Changelog is read by country implementors who might not always be familiar with all technical details of OpenCRVS. Keep language high-level, user friendly and avoid technical references to internals.
  • Answer "What's new?", "Why was the change made?" and "Why should I care?" for each change.
  • If it's a breaking change, include a migration guide answering "What do I need to do to upgrade?".

@github-actions
Copy link
Copy Markdown

github-actions Bot commented Feb 23, 2026

ℹ️ Coverage metrics explained:
Statements — Executed code statements (basic logic lines)
Branches — Tested decision paths (if/else, switch, ternaries)
Functions — Functions invoked during tests
Lines — Source lines executed

@github-actions
Copy link
Copy Markdown

github-actions Bot commented Feb 23, 2026

📊 commons test coverage

Statements: 67.42%
Branches:   33.81%
Functions:  50.58%
Lines:      66.89%
Updated at: Thu, 05 Mar 2026 09:38:55 GMT

@github-actions
Copy link
Copy Markdown

github-actions Bot commented Feb 23, 2026

📊 events test coverage

Statements: 86.79%
Branches:   84.97%
Functions:  93.18%
Lines:      86.79%
Updated at: Thu, 05 Mar 2026 09:43:53 GMT

@cibelius cibelius changed the title Ocrvs 11378 Implement location filtering option for ADDRESS / FACILITY inputs Feb 25, 2026
@ocrvs-bot
Copy link
Copy Markdown
Contributor

Your environment is deployed to https://ocrvs-11378.e2e-k8s.opencrvs.dev

Copy link
Copy Markdown
Contributor

@makelicious makelicious left a comment

Choose a reason for hiding this comment

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

looks good, I'll give it a spin. Assuming a single scope is an issue we need to fix, unless told otherwise.

Comment thread packages/commons/src/scopes-v2.ts Outdated
Comment thread packages/commons/src/users/userReferences.ts Outdated
Comment thread packages/commons/src/users/userReferences.ts Outdated
Comment thread packages/commons/src/scopes.test.ts Outdated
Comment thread packages/commons/src/events/FieldConfig.ts
Comment thread packages/commons/src/scopes.test.ts Outdated
Comment thread packages/commons/src/scopes-v2.ts
@cibelius cibelius requested a review from makelicious March 4, 2026 15:04
* @param acceptedScopes - An array of acceptable scope types to filter by.
* @returns An array of parsed RecordScopeV2 objects that are found in the token and match the accepted scope types.
*/
export function getAcceptedScopesFromToken(
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Put this here to avoid cyclical dependency on v2-scopes.ts and authentication.ts. It was causing issues.

Copy link
Copy Markdown
Contributor

@makelicious makelicious left a comment

Choose a reason for hiding this comment

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

Looks good, thanks for your hard work!

Comment thread packages/commons/src/users/userReferences.ts Outdated
@cibelius
Copy link
Copy Markdown
Contributor Author

cibelius commented Mar 5, 2026

@cibelius cibelius merged commit 66b2dcb into develop Mar 5, 2026
59 checks passed
@cibelius cibelius deleted the ocrvs-11378 branch March 5, 2026 09:45
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.

Implement location filtering option for ADDRESS / FACILITY inputs

4 participants