Skip to content

feat: add ability to filter master data table by sex and date of birth#1275

Merged
joshunrau merged 1 commit intoDouglasNeuroInformatics:mainfrom
joshunrau:table-filters
Feb 3, 2026
Merged

feat: add ability to filter master data table by sex and date of birth#1275
joshunrau merged 1 commit intoDouglasNeuroInformatics:mainfrom
joshunrau:table-filters

Conversation

@joshunrau
Copy link
Collaborator

@joshunrau joshunrau commented Feb 2, 2026

Screenshot 2026-02-02 at 5 21 10 PM

Summary by CodeRabbit

  • New Features
    • Added sex and date-of-birth filtering capabilities to the data hub
    • New filter dropdown menu integrated into the interface with pre-configured filter options
    • Enhanced data table with improved filtering support for date-of-birth and sex columns

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Feb 2, 2026

Walkthrough

A new client-side filtering UI is added to the data hub. A Filters component provides dropdown controls for sex and date-of-birth filtering, while MasterDataTable columns are updated with filter functions and renderers to support these filters.

Changes

Cohort / File(s) Summary
Filter Types
apps/web/src/routes/_app/datahub/index.tsx
New DateFilter and SexFilter types define filter configurations for date-of-birth (min, max, allowNull) and sex (array of Sex values or null).
Filters Component
apps/web/src/routes/_app/datahub/index.tsx
New Filters component renders a DropdownMenu with controls for sex (MALE, FEMALE, NULL) and date-of-birth (min/max date inputs, NULL toggle), updating table column filters via setFilterValue on change.
MasterDataTable Enhancements
apps/web/src/routes/_app/datahub/index.tsx
Column definitions updated: date-of-birth column adds Date type accessor, cell formatter (toBasicISOString), and custom filterFn; sex column adds null handling, localized cell renderer, and custom filterFn. initialState pre-populates columnFilters for both columns.
UI Integration
apps/web/src/routes/_app/datahub/index.tsx
Filters component integrated into Toggles area alongside Subject Lookup dialog and export dropdown; minor layout adjustments for button gaps; DropdownMenu and icon imports added.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~23 minutes

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main feature added: filtering the master data table by sex and date of birth, matching the core changes in the changeset.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

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 and usage tips.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Fix all issues with AI agents
In `@apps/web/src/routes/_app/datahub/index.tsx`:
- Around line 107-123: Replace the hardcoded "Min:" and "Max:" span labels with
calls to the app's translation function used in this file (e.g., t('...') or
i18n.t('...')) so they render localized strings; update both span elements near
the Date input (the spans just before the inputs that reference dobFilter and
dobColumn) to use translation keys like "datahub.dob.min" and "datahub.dob.max"
(or appropriate existing keys) and provide sensible fallback text if your
translation helper supports it.
🧹 Nitpick comments (1)
apps/web/src/routes/_app/datahub/index.tsx (1)

61-102: Optional: Extract repeated checkbox logic.

The three sex filter checkbox handlers share identical logic. A helper function could reduce repetition.

Proposed refactor
const toggleSexFilter = (value: null | Sex) => (checked: boolean) => {
  sexColumn.setFilterValue((prevValue: SexFilter): SexFilter => {
    return checked ? [...prevValue, value] : prevValue.filter((item) => item !== value);
  });
};

Then use onCheckedChange={toggleSexFilter('MALE')}, etc.

Comment on lines +107 to +123
<span className="pb-1">Min:</span>
<input
className="text-muted-foreground pointer-events-auto rounded-sm border-b pb-0.5"
type="date"
value={dobFilter.min ? toBasicISOString(dobFilter.min) : ''}
onChange={(event) => {
dobColumn.setFilterValue((prevValue: DateFilter): DateFilter => {
return {
...prevValue,
min: event.target.valueAsDate
};
});
}}
/>
</div>
<div className="rounded-xs relative flex items-center justify-between gap-1 px-2 pb-1 pt-1.5 text-sm transition-colors">
<span className="pb-1">Max:</span>
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

Untranslated labels: "Min:" and "Max:"

These labels should use the translation function for consistency with the rest of the UI.

Proposed fix
-            <span className="pb-1">Min:</span>
+            <span className="pb-1">{t({ en: 'Min:', fr: 'Min :' })}</span>
-            <span className="pb-1">Max:</span>
+            <span className="pb-1">{t({ en: 'Max:', fr: 'Max :' })}</span>
🤖 Prompt for AI Agents
In `@apps/web/src/routes/_app/datahub/index.tsx` around lines 107 - 123, Replace
the hardcoded "Min:" and "Max:" span labels with calls to the app's translation
function used in this file (e.g., t('...') or i18n.t('...')) so they render
localized strings; update both span elements near the Date input (the spans just
before the inputs that reference dobFilter and dobColumn) to use translation
keys like "datahub.dob.min" and "datahub.dob.max" (or appropriate existing keys)
and provide sensible fallback text if your translation helper supports it.

@joshunrau joshunrau merged commit e498899 into DouglasNeuroInformatics:main Feb 3, 2026
1 of 2 checks passed
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.

1 participant