Giter Club home page Giter Club logo

Comments (1)

greptile-apps avatar greptile-apps commented on August 18, 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

from twenty.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.