Skip to content

feat(arl): implement dynamic filters#152

Merged
kguzek merged 6 commits into
mainfrom
feat/sort-filter-fields
Nov 2, 2025
Merged

feat(arl): implement dynamic filters#152
kguzek merged 6 commits into
mainfrom
feat/sort-filter-fields

Conversation

@kguzek

@kguzek kguzek commented Nov 1, 2025

Copy link
Copy Markdown
Member

resolves #86

@kguzek kguzek self-assigned this Nov 1, 2025
Copilot AI review requested due to automatic review settings November 1, 2025 22:56
@kguzek kguzek added the enhancement New feature or request label Nov 1, 2025

Copilot AI 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.

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/searchTerm model with dynamic filters array supporting multiple simultaneous filters
  • Introduced FilterType enum and FilterOptions type for better type safety and extensibility
  • Refactored sort parameter handling to use a combined sort query parameter (e.g., +field or -field) instead of separate sortBy and sortDirection parameters

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 searchParams promise is awaited twice in this component (line 77 and line 103). Store the awaited result in the searchParameters variable 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.

Comment thread src/components/select-clear.tsx Outdated
Comment thread src/lib/helpers/app.ts Outdated
Comment thread src/components/abstract/resource-list/sort-filters/sort-filters.tsx Outdated
@kguzek
kguzek force-pushed the feat/sort-filter-fields branch from 9a6b77b to 9c38d87 Compare November 2, 2025 13:46
@kguzek
kguzek requested a review from Copilot November 2, 2025 16:41

Copilot AI 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.

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. */

Copilot AI Nov 2, 2025

Copy link

Choose a reason for hiding this comment

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

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.'

Copilot uses AI. Check for mistakes.
Comment thread src/config/constants.ts
@kguzek
kguzek merged commit d459f4a into main Nov 2, 2025
7 checks passed
@kguzek
kguzek deleted the feat/sort-filter-fields branch November 2, 2025 17:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request size/XXL

Projects

None yet

Development

Successfully merging this pull request may close these issues.

allow filtering by enum/relation values in ARL

2 participants