Giter Club home page Giter Club logo

Comments (1)

greptile-apps avatar greptile-apps commented on July 21, 2024

To add the 'create new entry' functionality to the 'from many' relation pickers, follow these steps:

  1. Import necessary hooks and components in /packages/twenty-front/src/modules/object-record/relation-picker/components/MultipleObjectRecordSelect.tsx:
import { useAddNewRecordAndOpenRightDrawer } from '@/object-record/relation-picker/hooks/useAddNewRecordAndOpenRightDrawer';
import { IconForbid } from 'twenty-ui';
  1. Initialize the hooks within the MultipleObjectRecordSelect component:
const { createNewRecordAndOpenRightDrawer } = useAddNewRecordAndOpenRightDrawer({
  relationObjectMetadataNameSingular: fieldDefinition.metadata.relationObjectMetadataNameSingular,
  relationObjectMetadataItem,
  relationFieldMetadataItem,
  entityId,
});
  1. Add the 'create new entry' button to the component's return statement:
<SingleEntitySelect
  EmptyIcon={IconForbid}
  emptyLabel={'No ' + fieldDefinition.label}
  onCancel={onCancel}
  onCreate={createNewRecordAndOpenRightDrawer}
  onEntitySelected={handleEntitySelected}
  width={width}
  relationObjectNameSingular={fieldDefinition.metadata.relationObjectMetadataNameSingular}
  relationPickerScopeId={relationPickerScopeId}
  selectedRelationRecordIds={recordId ? [recordId] : []}
  excludedRelationRecordIds={excludeRecordIds}
/>

This will enable the 'create new entry' functionality in the 'from many' relation pickers similar to the 'to one' relation pickers.

References

/packages/twenty-front/src/modules/object-record/relation-picker/components/RelationPicker.tsx
/packages/twenty-front/src/modules/object-record/relation-picker/components/MultipleObjectRecordSelect.tsx
/packages/twenty-front/src/modules/object-record/relation-picker/hooks/useAddNewRecordAndOpenRightDrawer.ts
/packages/twenty-front/src/modules/object-record/relation-picker/hooks/useRelationPicker.ts
/packages/twenty-front/src/modules/object-record/relation-picker/components
/packages/twenty-front/src/modules/object-record/record-show/record-detail-section/components/RecordDetailRelationSection.tsx
/packages/twenty-front/src/modules/object-record/record-field/meta-types/input/components/RelationManyFieldInput.tsx

About Greptile

This response provides a starting point for your research, not a precise solution.

Help us improve! Please leave a ๐Ÿ‘ if this is helpful and ๐Ÿ‘Ž if it is irrelevant.

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.