Skip to content

feat: Grouped all search- and filter-related fields on TableCardConfig#188

Open
gkrajniak wants to merge 3 commits into
mainfrom
feat/extend-table-card-to-be-able-to-set-initial-search-and-filter-tab
Open

feat: Grouped all search- and filter-related fields on TableCardConfig#188
gkrajniak wants to merge 3 commits into
mainfrom
feat/extend-table-card-to-be-able-to-set-initial-search-and-filter-tab

Conversation

@gkrajniak

@gkrajniak gkrajniak commented Jul 2, 2026

Copy link
Copy Markdown
Member
  • Grouped all search- and filter-related fields on TableCardConfig under a new searchConfig object,
  • adding initialSearch and initialFilter as one-shot seeds so hosts can hydrate the search input and selected filter tab from external state (e.g. URL params) — previously impossible.
  • Removed the now-redundant top-level resourcesSearchable (derived from searchConfig presence) a
  • filterTabs (moved into searchConfig) - a breaking change.

Summary by CodeRabbit

  • New Features
    • Added unified searchConfig for table card search and filter tabs.
    • initialSearch can preset the search input, and initialFilter can preselect the matching filter tab.
    • Updated table card stories/examples to demonstrate richer filter-tab setups, including an explicit “All” tab.
  • Bug Fixes
    • Prevented seeded initialSearch values from triggering an extra searchChanged event on load.
    • Improved initialFilter seeding so default-tab promotion happens only once and won’t override later user selections.
  • Chores
    • Updated type safety for declarative form initial value handling.

…r a new searchConfig object, adding initialSearch and initialFilter as

  one-shot seeds so hosts can hydrate the search input and selected filter tab from external state (e.g. URL params) — previously
  impossible. Removed the now-redundant top-level resourcesSearchable (derived from searchConfig presence) and filterTabs (moved into
  searchConfig), a breaking change.

Signed-off-by: gkrajniak <gkrajniak@gmail.com>
@gkrajniak gkrajniak self-assigned this Jul 2, 2026
@gkrajniak gkrajniak requested review from a team as code owners July 2, 2026 13:40
@gkrajniak gkrajniak added the enhancement New feature or request label Jul 2, 2026
@coderabbitai

coderabbitai Bot commented Jul 2, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: cf9f0e93-ca19-4326-a591-a127cfdc1d87

📥 Commits

Reviewing files that changed from the base of the PR and between 8cf6fc2 and ad6377f.

📒 Files selected for processing (1)
  • projects/ngx/declarative-ui/table-card/declarative-table-card.component.spec.ts
🚧 Files skipped from review as they are similar to previous changes (1)
  • projects/ngx/declarative-ui/table-card/declarative-table-card.component.spec.ts

📝 Walkthrough

Walkthrough

This PR consolidates table-card search/filter inputs under searchConfig, adds one-shot initial search and filter seeding, updates the table-card template, stories, and tests, and narrows a form helper parameter type.

Changes

TableCardConfig search/filter consolidation

Layer / File(s) Summary
TableCardSearchConfig model and TableCardConfig updates
projects/ngx/declarative-ui/table-card/models/configs.ts
Adds TableCardSearchConfig with initialSearch, filterTabs, and initialFilter, updates the filter-tab JSDoc, and replaces TableCardConfig search-related top-level fields with searchConfig.
Component computed properties and seeding effects
projects/ngx/declarative-ui/table-card/declarative-table-card.component.ts
Adds searchConfig/resourcesSearchable computed properties, one-time initialFilter promotion for filterTabs, and one-shot initialSearch seeding through an effect().
Template gating and specs
projects/ngx/declarative-ui/table-card/declarative-table-card.component.html, projects/ngx/declarative-ui/table-card/declarative-table-card.component.spec.ts
Switches template gating to resourcesSearchable() and extends tests for searchConfig seeding, tab defaults, and search button presence/absence.
Stories updated to searchConfig
projects/ngx/declarative-ui/stories/declarative-table-card.stories.ts
Moves the table-card story search/filter examples under searchConfig.filterTabs.
Initial value type narrowing
projects/ngx/declarative-ui/form/declarative-form/declarative-form.component.ts
Narrows setInitialValues to accept the component resource type parameter T.

Estimated code review effort: 3 (Moderate) | ~25 minutes

Possibly related PRs

Suggested reviewers: Sobyt483, lpgarzonr

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed It accurately summarizes the main change: moving search and filter fields into a new searchConfig on TableCardConfig.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/extend-table-card-to-be-able-to-set-initial-search-and-filter-tab

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@gkrajniak gkrajniak moved this to In progress in OpenMFP Development Jul 2, 2026

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 3

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In
`@projects/ngx/declarative-ui/table-card/declarative-table-card.component.spec.ts`:
- Around line 322-323: The test file uses multiple inline
`@typescript-eslint/no-explicit-any` disables around `component as any`, which
violates the linting guidelines. Replace these accesses with a narrow test-only
internals type (for example, a `TestTableCardInternals` cast used in the
affected specs) or, if a disable must remain, add an explanatory reason plus a
TODO to remove it. Update all affected assertions and helpers in
`declarative-table-card.component.spec.ts` so the internals are accessed without
undocumented `any` usage.
- Around line 332-337: The seeded search test in
declarative-table-card.component.spec.ts is asserting too early to prove silence
because the debounce window has not elapsed. Update the spec around
setupWithSearchConfig and the searchChanged assertion to run under fakeAsync,
advance time with tick(301), and then verify searchEvents remains empty so the
test will fail if the initial seed emits.

In `@projects/ngx/declarative-ui/table-card/declarative-table-card.component.ts`:
- Around line 153-160: `DeclarativeTableCardComponent` is latching tab state too
early in the `getFilterTabs`/`seededFilterTabs` flow. Update the logic so
`initialFilter` is only consumed once when it actually exists, but do not mark
`hasSeededFilter` on the no-initial case; also stop returning a permanently
cached promoted array so later `searchConfig().filterTabs` changes can still
flow through. Apply the same one-shot-but-not-frozen behavior to the related
tab/filter handling in the other referenced blocks so `initialFilter` and tab
updates stay in sync.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 8ff12274-642f-4db0-a971-7dd3d9ca844f

📥 Commits

Reviewing files that changed from the base of the PR and between 511ae2c and 8cf6fc2.

📒 Files selected for processing (6)
  • projects/ngx/declarative-ui/form/declarative-form/declarative-form.component.ts
  • projects/ngx/declarative-ui/stories/declarative-table-card.stories.ts
  • projects/ngx/declarative-ui/table-card/declarative-table-card.component.html
  • projects/ngx/declarative-ui/table-card/declarative-table-card.component.spec.ts
  • projects/ngx/declarative-ui/table-card/declarative-table-card.component.ts
  • projects/ngx/declarative-ui/table-card/models/configs.ts

@gkrajniak gkrajniak requested a review from Sobyt483 July 3, 2026 07:17
@gkrajniak gkrajniak enabled auto-merge (squash) July 3, 2026 07:18
gkrajniak added 2 commits July 3, 2026 09:27
trigger rebuild

Signed-off-by: Grzegorz Krajniak <gkrajniak@gmail.com>

@Sobyt483 Sobyt483 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

And please can you put less comments on code itself. I don't know why, but It feel so messy when i see so many comments in code

// We also auto-expand the input so the seeded value is visible instead of
// hidden behind the collapsed toggle button.
effect(() => {
if (this.hasSeededSearch) return;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

One small suggestion: the "run once" semantics can be expressed structurally with take(1) instead of a boolean flag, which removes the need for hasSeededSearch and the guard at the top of the effect:

toObservable(this.searchConfig)
.pipe(
map(config => config?.initialSearch),
filter((initial): initial is string => !!initial),
take(1),
takeUntilDestroyed()
)
.subscribe(initial => {
this.searchControl.setValue(initial, { emitEvent: false });
this.searchState.set('expanded');
});
Not blocking — the current approach works fine. Just a readability nit.

* changes. Subsequent recomputations pass through untouched so user-driven
* tab clicks (which flow through `filterTabChanged`) aren't overridden.
*/
protected filterTabs = computed(() => {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I think here can be found hidden bug.

There's a subtle correctness bug in the initialFilter path. Once hasSeededFilter latches and seededFilterTabs is set, any subsequent change to filterTabs in the config is silently ignored — the computed always returns the cached promoted array:

if (this.hasSeededFilter) {
return this.seededFilterTabs ?? tabs; // tabs (fresh) is never used when seededFilterTabs is set
}
So if a host updates filterTabs after initial render (adds/removes a tab or translate), the new tabs never appear in the component.

Note that this only affects the initialFilter code path — when initialFilter is absent, seededFilterTabs stays undefined and ?? tabs returns the fresh value, so dynamic updates work fine. The inconsistency is hard to notice.

So I suggest to simplify here the API. We have default property for filter tab, so we can omit initialFilter (as they kind do same work) and user can just change default base on some logic like initial querry or something like this

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

Status: In progress

Development

Successfully merging this pull request may close these issues.

2 participants