feat(arl): implement dynamic filters#152
Conversation
There was a problem hiding this comment.
Pull Request Overview
This PR refactors the filtering and sorting system for resource lists, replacing the previous single search field approach with a flexible multi-filter system. The main changes introduce support for multiple simultaneous filters with different field types (text, select), consolidate sort and filter parameters into a unified format, and improve type safety throughout the filtering system.
- Replaced single
searchField/searchTermmodel with dynamicfiltersarray supporting multiple simultaneous filters - Introduced
FilterTypeenum andFilterOptionstype for better type safety and extensibility - Refactored sort parameter handling to use a combined
sortquery parameter (e.g.,+fieldor-field) instead of separatesortByandsortDirectionparameters
Reviewed Changes
Copilot reviewed 30 out of 30 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
src/types/forms.ts |
Added FilteredField type and SelectInputOptions interface; refactored FormSelectInput to use the new interface |
src/types/components.ts |
Removed old SortFiltersOptions and ListSearchParameters types; added FilterOptions type with discriminated union for filter types |
src/schemas/forms.ts |
Replaced complex validation schema with simpler FilteredFieldSchema and updated SortFiltersSchema to support nullable sortBy and filters array |
src/config/enums.ts |
Added SortDirection and FilterType enums for better type safety |
src/config/constants.ts |
Renamed SORT_DIRECTIONS to SORT_DIRECTION_NAMES; updated default values and removed search field declension case |
src/lib/helpers/transformations.ts |
Added isEmptyValue helper for null/undefined/whitespace checking |
src/lib/helpers/backend.ts |
Added parseSortParameter and sanitizeFilterParameters functions; refactored fetchResources to handle new filter format |
src/lib/helpers/app.ts |
Added parseFilterSearchParameters and getSearchParametersFromSortFilters for bidirectional parameter conversion |
src/components/select-clear.tsx |
Generalized component to accept resetValue prop instead of hardcoding empty string |
src/components/inputs/select-options.tsx |
New component extracting select option rendering logic |
src/components/inputs/pending-input.tsx |
New component for displaying placeholder inputs when dependencies aren't met |
src/components/abstract/resource-list/sort-filters/sort-filters.tsx |
Complete rewrite to support multiple dynamic filters with field selection and value input |
src/components/abstract/resource-list/sort-filters/sort-filters.test.tsx |
Updated tests to reflect new filter structure and removed obsolete validation tests |
src/components/abstract/resource-list/index.tsx |
Added getResourceFieldFilterOptions to automatically derive filterable fields from resource metadata |
src/tests/e2e/helpers.ts |
Updated E2E helper to support new filter array format |
src/tests/e2e/resources/*.spec.ts |
Updated E2E tests to use new filter structure |
src/app/(private)/*/page.tsx |
Removed searchableFields prop as filtering is now automatic |
Comments suppressed due to low confidence (1)
src/components/abstract/resource-list/index.tsx:103
- The
searchParamspromise is awaited twice in this component (line 77 and line 103). Store the awaited result in thesearchParametersvariable defined on line 77 and reuse it to avoid redundant awaits.
searchParameters={await searchParams}
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
9a6b77b to
9c38d87
Compare
There was a problem hiding this comment.
Pull Request Overview
Copilot reviewed 47 out of 47 changed files in this pull request and generated 2 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| return searchParameters; | ||
| }; | ||
|
|
||
| /** Parses a string like +field or -field into distinct, URI-encodable values. */ |
There was a problem hiding this comment.
The comment describes the format as '+field or -field' but the actual implementation uses a separator (e.g., 'asc.field' or 'desc.field' based on SORT_DIRECTION_SEPARATOR being '.'). Update the comment to match the actual format: 'Parses a string like asc.field or desc.field into distinct, URI-encodable values.'
resolves #86