Implement sub-field filtering on CURRENCY field type (#11726)
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 https://github.com/twentyhq/core-team-issues/issues/498 Fixes https://github.com/twentyhq/twenty/issues/7558
This commit is contained in:
@ -2,7 +2,7 @@ import { useState } from 'react';
|
||||
import { ReadonlyDeep } from 'type-fest';
|
||||
|
||||
import { FieldMetadataItem } from '@/object-metadata/types/FieldMetadataItem';
|
||||
import { isCompositeField } from '@/object-record/object-filter-dropdown/utils/isCompositeField';
|
||||
import { isCompositeFieldType } from '@/object-record/object-filter-dropdown/utils/isCompositeFieldType';
|
||||
import { getSubFieldOptionKey } from '@/object-record/spreadsheet-import/utils/getSubFieldOptionKey';
|
||||
import { MatchColumnSelectFieldSelectDropdownContent } from '@/spreadsheet-import/components/MatchColumnSelectFieldSelectDropdownContent';
|
||||
import { MatchColumnSelectSubFieldSelectDropdownContent } from '@/spreadsheet-import/components/MatchColumnSelectSubFieldSelectDropdownContent';
|
||||
@ -40,7 +40,7 @@ export const MatchColumnToFieldSelect = ({
|
||||
) => {
|
||||
setSelectedFieldMetadataItem(selectedFieldMetadataItem);
|
||||
|
||||
if (!isCompositeField(selectedFieldMetadataItem.type)) {
|
||||
if (!isCompositeFieldType(selectedFieldMetadataItem.type)) {
|
||||
const correspondingOption = options.find(
|
||||
(option) => option.value === selectedFieldMetadataItem.name,
|
||||
);
|
||||
@ -100,11 +100,9 @@ export const MatchColumnToFieldSelect = ({
|
||||
(option) => option.value === DO_NOT_IMPORT_OPTION_KEY,
|
||||
);
|
||||
|
||||
const shouldDisplaySubFieldMetadataItemSelect = isDefined(
|
||||
selectedFieldMetadataItem?.type,
|
||||
)
|
||||
? isCompositeField(selectedFieldMetadataItem?.type)
|
||||
: false;
|
||||
const shouldDisplaySubFieldMetadataItemSelect =
|
||||
isDefined(selectedFieldMetadataItem?.type) &&
|
||||
isCompositeFieldType(selectedFieldMetadataItem?.type);
|
||||
|
||||
return (
|
||||
<Dropdown
|
||||
|
||||
Reference in New Issue
Block a user