mirror of
https://github.com/twentyhq/twenty.git
synced 2024-12-27 14:24:06 +03:00
Fix Filter search dynamic objectMetadataName (#2659)
This commit is contained in:
parent
02e60da923
commit
41c0cebf48
@ -46,6 +46,10 @@ const formatFieldMetadataItemAsFilterDefinition = ({
|
||||
fieldMetadataId: field.id,
|
||||
label: field.label,
|
||||
iconName: field.icon ?? 'Icon123',
|
||||
relationObjectMetadataNamePlural:
|
||||
field.toRelationMetadata?.fromObjectMetadata.namePlural,
|
||||
relationObjectMetadataNameSingular:
|
||||
field.toRelationMetadata?.fromObjectMetadata.nameSingular,
|
||||
type:
|
||||
field.type === FieldMetadataType.DateTime
|
||||
? 'DATE_TIME'
|
||||
|
@ -14,8 +14,14 @@ export const ObjectFilterDropdownEntitySelect = () => {
|
||||
objectFilterDropdownSelectedEntityId,
|
||||
} = useFilter();
|
||||
|
||||
const objectMetadataNameSingular =
|
||||
filterDefinitionUsedInDropdown?.relationObjectMetadataNameSingular ?? '';
|
||||
|
||||
const objectMetadataNamePlural =
|
||||
filterDefinitionUsedInDropdown?.relationObjectMetadataNamePlural ?? '';
|
||||
|
||||
const { findManyQuery } = useObjectMetadataItem({
|
||||
objectNameSingular: 'company',
|
||||
objectNameSingular: objectMetadataNameSingular,
|
||||
});
|
||||
|
||||
const useFindManyQuery = (options: any) => useQuery(findManyQuery, options);
|
||||
@ -26,7 +32,8 @@ export const ObjectFilterDropdownEntitySelect = () => {
|
||||
queryHook: useFindManyQuery,
|
||||
filters: [
|
||||
{
|
||||
fieldNames: searchQuery?.computeFilterFields?.('company') ?? [],
|
||||
fieldNames:
|
||||
searchQuery?.computeFilterFields?.(objectMetadataNameSingular) ?? [],
|
||||
filter: objectFilterDropdownSearchInput,
|
||||
},
|
||||
],
|
||||
@ -34,8 +41,9 @@ export const ObjectFilterDropdownEntitySelect = () => {
|
||||
selectedIds: objectFilterDropdownSelectedEntityId
|
||||
? [objectFilterDropdownSelectedEntityId]
|
||||
: [],
|
||||
mappingFunction: (record: any) => identifiersMapper?.(record, 'company'),
|
||||
objectNamePlural: 'companies',
|
||||
mappingFunction: (record: any) =>
|
||||
identifiersMapper?.(record, objectMetadataNameSingular),
|
||||
objectNamePlural: objectMetadataNamePlural,
|
||||
});
|
||||
|
||||
if (filterDefinitionUsedInDropdown?.type !== 'RELATION') {
|
||||
|
@ -7,7 +7,8 @@ export type FilterDefinition = {
|
||||
label: string;
|
||||
iconName: string;
|
||||
type: FilterType;
|
||||
entitySelectComponent?: JSX.Element;
|
||||
relationObjectMetadataNamePlural?: string;
|
||||
relationObjectMetadataNameSingular?: string;
|
||||
selectAllLabel?: string;
|
||||
SelectAllIcon?: IconComponent;
|
||||
};
|
||||
|
@ -100,8 +100,9 @@ export const ObjectSortDropdownButton = ({
|
||||
</DropdownMenuHeader>
|
||||
<DropdownMenuSeparator />
|
||||
<DropdownMenuItemsContainer>
|
||||
{availableSortDefinitions.map(
|
||||
(availableSortDefinition, index) => (
|
||||
{[...availableSortDefinitions]
|
||||
.sort((a, b) => a.label.localeCompare(b.label))
|
||||
.map((availableSortDefinition, index) => (
|
||||
<MenuItem
|
||||
testId={`select-sort-${index}`}
|
||||
key={index}
|
||||
@ -109,8 +110,7 @@ export const ObjectSortDropdownButton = ({
|
||||
LeftIcon={icons[availableSortDefinition.iconName]}
|
||||
text={availableSortDefinition.label}
|
||||
/>
|
||||
),
|
||||
)}
|
||||
))}
|
||||
</DropdownMenuItemsContainer>
|
||||
</>
|
||||
)}
|
||||
|
@ -1,7 +1,6 @@
|
||||
import { Activity } from '@/activities/types/Activity';
|
||||
import { IconUserCircle } from '@/ui/display/icon';
|
||||
import { FilterDefinitionByEntity } from '@/ui/object/object-filter-dropdown/types/FilterDefinitionByEntity';
|
||||
import { FilterDropdownUserSearchSelect } from '@/users/components/FilterDropdownUserSearchSelect';
|
||||
|
||||
export const tasksFilterDefinitions: FilterDefinitionByEntity<Activity>[] = [
|
||||
{
|
||||
@ -9,7 +8,8 @@ export const tasksFilterDefinitions: FilterDefinitionByEntity<Activity>[] = [
|
||||
label: 'Assignee',
|
||||
iconName: 'IconUser',
|
||||
type: 'RELATION',
|
||||
entitySelectComponent: <FilterDropdownUserSearchSelect />,
|
||||
relationObjectMetadataNamePlural: 'workspaceMembers',
|
||||
relationObjectMetadataNameSingular: 'workspaceMember',
|
||||
selectAllLabel: 'All assignees',
|
||||
SelectAllIcon: IconUserCircle,
|
||||
},
|
||||
|
Loading…
Reference in New Issue
Block a user