-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixed sort for Currency type (#6333)
Fixes : #6056 - Refactored the logic to get order by query variables for field types - Added a case for Currency field type
- Loading branch information
1 parent
d488b7f
commit b380064
Showing
5 changed files
with
70 additions
and
55 deletions.
There are no files selected for viewing
15 changes: 15 additions & 0 deletions
15
packages/twenty-front/src/modules/object-metadata/constants/SortableFieldMetadataTypes.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import { FieldMetadataType } from '~/generated-metadata/graphql'; | ||
|
||
export const SORTABLE_FIELD_METADATA_TYPES = [ | ||
FieldMetadataType.DateTime, | ||
FieldMetadataType.Date, | ||
FieldMetadataType.Number, | ||
FieldMetadataType.Text, | ||
FieldMetadataType.Boolean, | ||
FieldMetadataType.Select, | ||
FieldMetadataType.Phone, | ||
FieldMetadataType.Email, | ||
FieldMetadataType.FullName, | ||
FieldMetadataType.Rating, | ||
FieldMetadataType.Currency, | ||
]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
35 changes: 35 additions & 0 deletions
35
packages/twenty-front/src/modules/object-metadata/utils/getOrderByForFieldMetadataType.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import { FieldMetadataItem } from '@/object-metadata/types/FieldMetadataItem'; | ||
import { OrderBy } from '@/object-metadata/types/OrderBy'; | ||
import { RecordGqlOperationOrderBy } from '@/object-record/graphql/types/RecordGqlOperationOrderBy'; | ||
import { FieldMetadataType } from '~/generated-metadata/graphql'; | ||
|
||
export const getOrderByForFieldMetadataType = ( | ||
field: Pick<FieldMetadataItem, 'id' | 'name' | 'type'>, | ||
direction: OrderBy | null | undefined, | ||
): RecordGqlOperationOrderBy => { | ||
switch (field.type) { | ||
case FieldMetadataType.FullName: | ||
return [ | ||
{ | ||
[field.name]: { | ||
firstName: direction ?? 'AscNullsLast', | ||
lastName: direction ?? 'AscNullsLast', | ||
}, | ||
}, | ||
]; | ||
case FieldMetadataType.Currency: | ||
return [ | ||
{ | ||
[field.name]: { | ||
amountMicros: direction ?? 'AscNullsLast', | ||
}, | ||
}, | ||
]; | ||
default: | ||
return [ | ||
{ | ||
[field.name]: direction ?? 'AscNullsLast', | ||
}, | ||
]; | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters