Ability to filter by composite's subfields (#6832)
# This PR - Fix #6425 See https://github.com/twentyhq/twenty/issues/7188 because there's some more work to do. --------- Co-authored-by: Lucas Bordeau <bordeau.lucas@gmail.com>
This commit is contained in:
committed by
GitHub
parent
af4f3cebb0
commit
4156d7821c
@ -16,6 +16,7 @@ const baseDefinition = {
|
||||
fieldMetadataId: '05731f68-6e7a-4903-8374-c0b6a9063482',
|
||||
label: 'label',
|
||||
iconName: 'iconName',
|
||||
fieldName: 'fieldName',
|
||||
};
|
||||
|
||||
describe('mapViewSortsToSorts', () => {
|
||||
|
||||
@ -1,17 +0,0 @@
|
||||
import { FilterDefinition } from '@/object-record/object-filter-dropdown/types/FilterDefinition';
|
||||
import { hasSubMenuFilter } from '@/object-record/object-filter-dropdown/utils/hasSubMenuFilter';
|
||||
import { ViewFilter } from '../types/ViewFilter';
|
||||
|
||||
export const getFilterDefinitionForViewFilter = (
|
||||
viewFilter: ViewFilter,
|
||||
availableFilterDefinition: FilterDefinition,
|
||||
): FilterDefinition => {
|
||||
return {
|
||||
...availableFilterDefinition,
|
||||
subFieldType:
|
||||
hasSubMenuFilter(availableFilterDefinition.type) &&
|
||||
viewFilter.definition?.type !== availableFilterDefinition.type
|
||||
? viewFilter.definition?.type
|
||||
: undefined,
|
||||
};
|
||||
};
|
||||
@ -2,7 +2,6 @@ import { Filter } from '@/object-record/object-filter-dropdown/types/Filter';
|
||||
import { FilterDefinition } from '@/object-record/object-filter-dropdown/types/FilterDefinition';
|
||||
import { isDefined } from '~/utils/isDefined';
|
||||
|
||||
import { getFilterDefinitionForViewFilter } from '@/views/utils/getFilterDefinitionForViewFilter';
|
||||
import { ViewFilter } from '../types/ViewFilter';
|
||||
|
||||
export const mapViewFiltersToFilters = (
|
||||
@ -24,10 +23,7 @@ export const mapViewFiltersToFilters = (
|
||||
value: viewFilter.value,
|
||||
displayValue: viewFilter.displayValue,
|
||||
operand: viewFilter.operand,
|
||||
definition: getFilterDefinitionForViewFilter(
|
||||
viewFilter,
|
||||
availableFilterDefinition,
|
||||
),
|
||||
definition: viewFilter.definition ?? availableFilterDefinition,
|
||||
};
|
||||
})
|
||||
.filter(isDefined);
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
import { Filter } from '@/object-record/object-filter-dropdown/types/Filter';
|
||||
import { FilterType } from '@/object-record/object-filter-dropdown/types/FilterType';
|
||||
import { FilterableFieldType } from '@/object-record/object-filter-dropdown/types/FilterableFieldType';
|
||||
import { ViewFilterOperand } from '@/views/types/ViewFilterOperand';
|
||||
import { resolveNumberViewFilterValue } from '@/views/utils/view-filter-value/resolveNumberViewFilterValue';
|
||||
import {
|
||||
@ -8,7 +8,7 @@ import {
|
||||
} from './resolveDateViewFilterValue';
|
||||
|
||||
type ResolvedFilterValue<
|
||||
T extends FilterType,
|
||||
T extends FilterableFieldType,
|
||||
O extends ViewFilterOperand,
|
||||
> = T extends 'DATE' | 'DATE_TIME'
|
||||
? ResolvedDateViewFilterValue<O>
|
||||
@ -16,16 +16,16 @@ type ResolvedFilterValue<
|
||||
? ReturnType<typeof resolveNumberViewFilterValue>
|
||||
: string;
|
||||
|
||||
type PartialFilter<T extends FilterType, O extends ViewFilterOperand> = Pick<
|
||||
Filter,
|
||||
'value'
|
||||
> & {
|
||||
type PartialFilter<
|
||||
T extends FilterableFieldType,
|
||||
O extends ViewFilterOperand,
|
||||
> = Pick<Filter, 'value'> & {
|
||||
definition: { type: T };
|
||||
operand: O;
|
||||
};
|
||||
|
||||
export const resolveFilterValue = <
|
||||
T extends FilterType,
|
||||
T extends FilterableFieldType,
|
||||
O extends ViewFilterOperand,
|
||||
>(
|
||||
filter: PartialFilter<T, O>,
|
||||
|
||||
Reference in New Issue
Block a user