Skip to content

Implement sub-field filtering on CURRENCY field type #11726

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 9 commits into from
Apr 25, 2025

Conversation

lucasbordeau
Copy link
Contributor

This PR implements sub-field filtering on CURRENCY field type and improves many related zones.

  • Created a ObjectFilterDropdownCurrencySelect dropdown component for filtering on multiple currencies
  • Added currencyCode sub-field to CurrencyFilter type
  • Created getDefaultSubFieldNameForCompositeFilterableFieldType to avoid situation where we don't have any sub field name in sub field filtering situations.
  • Implemented filtering for currencyCode in computeFilterRecordGqlOperationFilter
  • Implemented CURRENCY type in getRecordFilterOperands
  • Implemented isMatchingCurrencyFilter for using in isRecordMatchingFilter for proper optimistic rendering
  • Created turnCurrencyIntoSelectableItem to help ObjectFilterDropdownCurrencySelect

Testing :

  • Added test for currency sub fields in getOperandsForFilterType
  • Completely reworked isMatchingCurrencyFilter test

Improvements :

  • Created a unique CURRENCIES constant to avoid re-creating it at various places
  • Derive the type FilterableFieldType from a constant array FILTERABLE_FIELD_TYPES, so it's easier to work with
  • Added areCompositeTypeSubFieldsFilterable
  • Fixed a bug with empty value '[]' that was preventing the auto-removal of a filter chip

Miscellaneous :

  • Created isExpectedSubFieldName util to do a type-safe check of a subFieldName
  • Better naming : renamed isCompositeField to isCompositeFieldType
  • Created isCompositeTypeFilterableWithAny to specify which field types are filterable by any sub field
  • Better naming : renamed ObjectFilterDropdownFilterSelectCompositeFieldSubMenu to ObjectFilterDropdownSubFieldSelect
  • Better naming : renamed ObjectFilterDropdownFilterSelect to ObjectFilterDropdownFieldSelect
  • Created isEmptinessOperand util instead of duplicating the same hard-coded check in multiple places
  • Better naming : used subFieldName instead of compositeFieldName for consistency
  • UseEffect removal : removed unnecessary useEffect in MultipleSelectDropdown

Fixes a bug where Empty and Not weren't appearing in filter chip in particular cases
Fixes twentyhq/core-team-issues#498
Fixes #7558

Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

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

PR Summary

This PR implements comprehensive sub-field filtering for CURRENCY field type, focusing on separate filtering capabilities for currency codes and amounts.

  • Added ObjectFilterDropdownCurrencySelect component for multi-currency code filtering with search functionality
  • Implemented specialized filtering logic for amountMicros and currencyCode sub-fields in computeViewRecordGqlOperationFilter
  • Centralized currency handling with new CURRENCIES constant and Currency type definition
  • Removed "Any currency field" option for better UX and added specific icons for currency sub-fields
  • Fixed bug with empty filter values ([]) and improved emptiness operand handling

49 file(s) reviewed, 28 comment(s)
Edit PR Review Bot Settings | Greptile

@lucasbordeau lucasbordeau requested review from bosiraphael and removed request for charlesBochet April 24, 2025 16:10
Copy link
Contributor

@bosiraphael bosiraphael left a comment

Choose a reason for hiding this comment

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

LGTM, left a couple of comments to address before merging

Copy link
Contributor

github-actions bot commented Apr 25, 2025

🚀 Preview Environment Ready!

Your preview environment is available at: http://bore.pub:33803

This environment will automatically shut down when the PR is closed or after 5 hours.

@lucasbordeau lucasbordeau enabled auto-merge (squash) April 25, 2025 17:20
@lucasbordeau lucasbordeau merged commit 50cb32d into main Apr 25, 2025
53 checks passed
@lucasbordeau lucasbordeau deleted the feat/sub-field-filtering-currency branch April 25, 2025 17:33
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.

Implement CURRENCY composite field type on filter and advanced filters Improve currency filter
2 participants