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

Open
FelixMalfait opened this issue Jun 27, 2024 · 1 comment
Open

I should be able to sort by amount #6056

FelixMalfait opened this issue Jun 27, 2024 · 1 comment
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

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

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
Status: 🆕 New
Development

No branches or pull requests

1 participant