AB#129192-apply-user-context-filter-to-grid#2856
Conversation
There was a problem hiding this comment.
Pull request overview
Adds support for {{user.*}} placeholders in dashboard/grid context filters so filter values can be resolved from the currently logged-in user (including shortcuts to user attributes).
Changes:
- Extend
ContextServiceto resolve{{user.*}}placeholders in bothreplaceFilter()andinjectContext(). - Update filter-row editor selection logic to treat
{{user.*}}(and other placeholders) as “dynamic placeholder” values. - Update EN/FR tooltip copy and add unit tests covering user placeholder replacement.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| libs/shared/src/lib/services/context/context.service.ts | Adds user placeholder parsing/resolution and applies it during filter/context injection. |
| libs/shared/src/lib/services/context/context.service.spec.ts | Adds unit tests verifying user placeholder replacement for replaceFilter() and injectContext(). |
| libs/shared/src/lib/components/filter/filter-row/filter-row.component.ts | Ensures dynamic editor is used for {{user.*}} placeholder values. |
| libs/shared/src/i18n/fr.json | Updates tooltip text to document new {{user.*}} placeholders (FR). |
| libs/shared/src/i18n/en.json | Updates tooltip text to document new {{user.*}} placeholders (EN). |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| } else { | ||
| const userName = obj[prop]?.match(userRegex)?.[0]; | ||
| if (userName) { | ||
| obj[prop] = this.getUserPlaceholderValue(userName); |
There was a problem hiding this comment.
injectContext currently assigns undefined when a {{user.*}} placeholder can’t be resolved (e.g., user not loaded yet or attribute missing). Because composite filters later drop descriptors with nil values, this can silently remove the intended user-scoping filter and broaden the query results. Consider only overwriting the property when the resolved user value is non-nil (otherwise leave the placeholder string intact), or map missing user fields to an explicit “no match” sentinel rather than removing the filter.
| obj[prop] = this.getUserPlaceholderValue(userName); | |
| const userValue = this.getUserPlaceholderValue(userName); | |
| if (!isNil(userValue)) { | |
| obj[prop] = userValue; | |
| } |
Description
Adds support for
{{user.*}}placeholders in dashboard/grid context filters, so filters can be scoped to the current logged-in user.Type of change
How Has This Been Tested?
Automated
npx nx test shared --testFile=context.service.spec.tsManual
{ "field": "region", "operator": "eq", "value": "{{user.region}}" }Screenshots
without filter : 8408 lines
with filter: 2016
Checklist:
( * == Mandatory )
More explanation
https://www.loom.com/share/05a716d61b9744faaf51fb304c21d1e5?sid=f87cf896-582a-4f76-93ae-8ceed801b145