twentyhq / twenty

Building a modern alternative to Salesforce, powered by the community.
https://twenty.com
GNU Affero General Public License v3.0
15.54k stars 1.63k forks source link

Ability to pick a relation when creating a record on Kanban Boards #6266

Open Bonapara opened 1 month ago

Bonapara commented 1 month ago

Current Behavior

When creating an opportunity from the Opportunity Kanban board:

  1. I click on "New."
  2. A menu opens, allowing me to choose which company to associate with my opportunity.
  3. The opportunity is created with the company relation field directly associated with the correct company.

When creating a record on a regular Kanban board:

Desired Behavior

We should either:

greptile-apps[bot] commented 1 month ago

To refactor the feature to be linked with Required relationships, follow these steps:

  1. Update RecordBoardColumnNewOpportunityButton.tsx:

    • Modify the handleEntitySelect function to handle required relationships.

      const handleEntitySelect = (company?: EntityForSelect) => {
      setIsCreatingCard(false);
      goBackToPreviousHotkeyScope();
      resetSearchFilter();
      
      if (!company) {
      return;
      }
      
      // Add logic to handle required relationships
      const requiredRelations = getRequiredRelations(); // Implement this function
      createOneRecord({
      name: company.name,
      companyId: company.id,
      position: 'last',
      ...requiredRelations,
      });
      };
  2. Update RelationPicker.tsx:

    • Ensure it integrates with required relationships logic.
      const handleEntitySelected = (selectedEntity: EntityForSelect | null | undefined) => {
      onSubmit(selectedEntity ?? null);
      // Add logic to handle required relationships
      const requiredRelations = getRequiredRelations(); // Implement this function
      persistField({ ...selectedEntity?.record, ...requiredRelations });
      };
  3. Implement getRequiredRelations function:

    • Create a utility function to fetch required relationships.
      const getRequiredRelations = () => {
      // Logic to fetch required relationships
      return {
      relationField1: value1,
      relationField2: value2,
      };
      };
  4. Ensure SettingsObjectNewFieldStep2 handles required relationships:

    • Modify form submission logic to include required relationships.
      const handleSubmit = () => {
      const requiredRelations = getRequiredRelations(); // Implement this function
      createMetadataField({ ...formData, ...requiredRelations });
      };

References

/packages/twenty-front/src/modules/object-record/record-board/record-board-column/components/RecordBoardColumnNewOpportunityButton.tsx /packages/twenty-front/src/modules/object-record/record-show/record-detail-section/components/RecordDetailRelationSection.tsx /packages/twenty-front/src/modules/object-record/relation-picker/components/RelationPicker.tsx /packages/twenty-front/src/modules/object-record/record-field/meta-types/input/components/RelationToOneFieldInput.tsx /packages/twenty-front/src/pages/settings/data-model/SettingsObjectNewField

#### 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](https://app.greptile.com/chat/github/twentyhq/twenty/main) ยท [Edit Issue Bot Settings](https://app.greptile.com/apps/github)
Faisal-imtiyaz123 commented 3 weeks ago

@Bonapara Sorry I couldn't understand what exactly is required in the desired behaviour. Could you please explain a bit further.

Bonapara commented 3 weeks ago

Hi @Faisal-imtiyaz123, unfortunately, this issue is not ready to be picked up. It's here to log the issue, but we have not decided on a solution yet. Thanks!