Add sort feature for Links type (#6503)

Closes https://github.com/twentyhq/twenty/issues/5741

Filtering was already working.

I just added the required logic in the frontend to allow sorting by
primary link url (because label can be empty)
This commit is contained in:
Lucas Bordeau 2024-08-02 11:10:54 +02:00 committed by GitHub
parent f0ca3439a8
commit 68120d529c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 10 additions and 0 deletions

View File

@ -12,4 +12,5 @@ export const SORTABLE_FIELD_METADATA_TYPES = [
FieldMetadataType.FullName, FieldMetadataType.FullName,
FieldMetadataType.Rating, FieldMetadataType.Rating,
FieldMetadataType.Currency, FieldMetadataType.Currency,
FieldMetadataType.Links,
]; ];

View File

@ -1,6 +1,7 @@
import { FieldMetadataItem } from '@/object-metadata/types/FieldMetadataItem'; import { FieldMetadataItem } from '@/object-metadata/types/FieldMetadataItem';
import { OrderBy } from '@/object-metadata/types/OrderBy'; import { OrderBy } from '@/object-metadata/types/OrderBy';
import { RecordGqlOperationOrderBy } from '@/object-record/graphql/types/RecordGqlOperationOrderBy'; import { RecordGqlOperationOrderBy } from '@/object-record/graphql/types/RecordGqlOperationOrderBy';
import { FieldLinksValue } from '@/object-record/record-field/types/FieldMetadata';
import { FieldMetadataType } from '~/generated-metadata/graphql'; import { FieldMetadataType } from '~/generated-metadata/graphql';
export const getOrderByForFieldMetadataType = ( export const getOrderByForFieldMetadataType = (
@ -25,6 +26,14 @@ export const getOrderByForFieldMetadataType = (
}, },
}, },
]; ];
case FieldMetadataType.Links:
return [
{
[field.name]: {
primaryLinkUrl: direction ?? 'AscNullsLast',
} satisfies { [key in keyof FieldLinksValue]?: OrderBy },
},
];
default: default:
return [ return [
{ {