Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

I should be able to sort by amount #6056

Closed
FelixMalfait opened this issue Jun 27, 2024 · 1 comment · Fixed by #6333
Closed

I should be able to sort by amount #6056

FelixMalfait opened this issue Jun 27, 2024 · 1 comment · Fixed by #6333
Assignees
Labels
scope: front Issues that are affecting the frontend side only

Comments

@FelixMalfait
Copy link
Member

We haven't implemented sorting on the currency field type. It would be very useful.
While we're at it we should also solve for filtering?.

It's a composite type so that's probably why, but I see we did it for name.

@FelixMalfait FelixMalfait added the scope: front Issues that are affecting the frontend side only label Jun 27, 2024
Copy link
Contributor

greptile-apps bot commented Jun 27, 2024

To implement sorting and filtering for the currency field type, follow these steps:

  1. Update formatFieldMetadataItemInput:

    • Path: /packages/twenty-front/src/modules/object-metadata/utils/formatFieldMetadataItemInput.ts
    • Ensure the currency field type is correctly formatted.
  2. Modify selectOptionsSchema:

    • Path: /packages/twenty-front/src/modules/object-metadata/validation-schemas/selectOptionsSchema.ts
    • Add validation for the currency field type if necessary.
  3. Enhance getObjectRecordIdentifier:

    • Path: /packages/twenty-front/src/modules/object-metadata/utils/getObjectRecordIdentifier.ts
    • Ensure the currency field type is included in the identifier logic.
  4. Update useGetRelationMetadata:

    • Path: /packages/twenty-front/src/modules/object-metadata/hooks/useGetRelationMetadata.ts
    • Ensure the currency field type is handled in relation metadata.
  5. Implement Sorting and Filtering Logic:

    • Identify where sorting and filtering logic is applied in the codebase (e.g., in hooks or components handling object metadata).
    • Add cases for the currency field type to enable sorting and filtering.

Example Code Snippet for Sorting:

// Add this in the relevant sorting utility function
if (field.type === 'Currency') {
  // Sorting logic for currency
  return records.sort((a, b) => parseFloat(a[field.name]) - parseFloat(b[field.name]));
}

Example Code Snippet for Filtering:

// Add this in the relevant filtering utility function
if (field.type === 'Currency') {
  // Filtering logic for currency
  return records.filter(record => record[field.name] === filterValue);
}

References

/packages/twenty-front/src/modules/object-metadata/utils/getObjectRecordIdentifier.ts
/packages/twenty-front/src/modules/object-metadata/hooks/useGetRelationMetadata.ts
/packages/twenty-front/src/modules/object-metadata/utils/formatFieldMetadataItemInput.ts
/packages/twenty-front/src/modules/object-metadata/validation-schemas/selectOptionsSchema.ts
/packages/twenty-front/src/modules/object-metadata/components/ObjectMetadataNavItems.tsx
/packages/twenty-front/src/modules/object-metadata/utils/getAvatarType.ts
/packages/twenty-front/src/modules/object-metadata/hooks/useCreateOneObjectMetadataItem.ts

Ask Greptile · Edit Issue Bot Settings

@twentyhq twentyhq deleted a comment from Faisal-imtiyaz123 Jul 10, 2024
@charlesBochet charlesBochet moved this from 🆕 New to 🔖 Planned in Product development ✅ Jul 16, 2024
@FelixMalfait FelixMalfait added the T label Jul 18, 2024
@lucasbordeau lucasbordeau moved this from 🔖 Planned to 🏗 In progress in Product development ✅ Jul 18, 2024
@lucasbordeau lucasbordeau linked a pull request Jul 19, 2024 that will close this issue
Weiko pushed a commit that referenced this issue Jul 19, 2024
Fixes : #6056 

- Refactored the logic to get order by query variables for field types
- Added a case for Currency field type
@github-project-automation github-project-automation bot moved this from 🏗 In progress to ✅ Done in Product development ✅ Jul 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
scope: front Issues that are affecting the frontend side only
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

2 participants