From e3ed57442065cdad41f8ec58e4d4abc9349b4826 Mon Sep 17 00:00:00 2001 From: nitin <142569587+ehconitin@users.noreply.github.com> Date: Fri, 4 Oct 2024 02:01:03 +0530 Subject: [PATCH] minor fix - reset single entity search (#7420) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit minor follow up fix #7285 --------- Co-authored-by: FĂ©lix Malfait --- packages/twenty-front/src/generated-metadata/graphql.ts | 2 ++ .../components/RecordBoardColumnHeader.tsx | 1 - .../record-board-column/hooks/useAddNewCard.ts | 7 ++++++- .../settings/data-model/constants/RelationTypes.ts | 8 ++++++++ .../components/SettingsDataModelFieldRelationForm.tsx | 6 +++++- 5 files changed, 21 insertions(+), 3 deletions(-) diff --git a/packages/twenty-front/src/generated-metadata/graphql.ts b/packages/twenty-front/src/generated-metadata/graphql.ts index 4f48fe60c4..64d5248023 100644 --- a/packages/twenty-front/src/generated-metadata/graphql.ts +++ b/packages/twenty-front/src/generated-metadata/graphql.ts @@ -992,6 +992,7 @@ export type RelationDefinition = { /** Relation definition type */ export enum RelationDefinitionType { + ManyToMany = 'MANY_TO_MANY', ManyToOne = 'MANY_TO_ONE', OneToMany = 'ONE_TO_MANY', OneToOne = 'ONE_TO_ONE' @@ -999,6 +1000,7 @@ export enum RelationDefinitionType { /** Type of the relation */ export enum RelationMetadataType { + ManyToMany = 'MANY_TO_MANY', ManyToOne = 'MANY_TO_ONE', OneToMany = 'ONE_TO_MANY', OneToOne = 'ONE_TO_ONE' diff --git a/packages/twenty-front/src/modules/object-record/record-board/record-board-column/components/RecordBoardColumnHeader.tsx b/packages/twenty-front/src/modules/object-record/record-board/record-board-column/components/RecordBoardColumnHeader.tsx index d0d7e93de0..e0ae827280 100644 --- a/packages/twenty-front/src/modules/object-record/record-board/record-board-column/components/RecordBoardColumnHeader.tsx +++ b/packages/twenty-front/src/modules/object-record/record-board/record-board-column/components/RecordBoardColumnHeader.tsx @@ -93,7 +93,6 @@ export const RecordBoardColumnHeader = () => { newRecord, handleNewButtonClick, handleCreateSuccess, - handleEntitySelect, } = useColumnNewCardActions(columnDefinition.id); const { isOpportunitiesCompanyFieldDisabled } = diff --git a/packages/twenty-front/src/modules/object-record/record-board/record-board-column/hooks/useAddNewCard.ts b/packages/twenty-front/src/modules/object-record/record-board/record-board-column/hooks/useAddNewCard.ts index f0921f82f3..97cb8c5d60 100644 --- a/packages/twenty-front/src/modules/object-record/record-board/record-board-column/hooks/useAddNewCard.ts +++ b/packages/twenty-front/src/modules/object-record/record-board/record-board-column/hooks/useAddNewCard.ts @@ -1,6 +1,7 @@ import { RecordBoardContext } from '@/object-record/record-board/contexts/RecordBoardContext'; import { RecordBoardColumnContext } from '@/object-record/record-board/record-board-column/contexts/RecordBoardColumnContext'; import { recordBoardNewRecordByColumnIdSelector } from '@/object-record/record-board/states/selectors/recordBoardNewRecordByColumnIdSelector'; +import { useEntitySelectSearch } from '@/object-record/relation-picker/hooks/useEntitySelectSearch'; import { EntityForSelect } from '@/object-record/relation-picker/types/EntityForSelect'; import { RelationPickerHotkeyScope } from '@/object-record/relation-picker/types/RelationPickerHotkeyScope'; import { usePreviousHotkeyScope } from '@/ui/utilities/hotkey/hooks/usePreviousHotkeyScope'; @@ -17,6 +18,9 @@ export const useAddNewCard = () => { const columnContext = useContext(RecordBoardColumnContext); const { createOneRecord, selectFieldMetadataItem } = useContext(RecordBoardContext); + const { resetSearchFilter } = useEntitySelectSearch({ + relationPickerScopeId: 'relation-picker', + }); const { goBackToPreviousHotkeyScope, @@ -132,11 +136,12 @@ export const useAddNewCard = () => { company: null, }, ); + resetSearchFilter(); if (isOpportunity === true) { goBackToPreviousHotkeyScope(); } }, - [getColumnDefinitionId, goBackToPreviousHotkeyScope], + [getColumnDefinitionId, goBackToPreviousHotkeyScope, resetSearchFilter], ); const handleCreate = ( diff --git a/packages/twenty-front/src/modules/settings/data-model/constants/RelationTypes.ts b/packages/twenty-front/src/modules/settings/data-model/constants/RelationTypes.ts index da5e9b8b96..179f60fe89 100644 --- a/packages/twenty-front/src/modules/settings/data-model/constants/RelationTypes.ts +++ b/packages/twenty-front/src/modules/settings/data-model/constants/RelationTypes.ts @@ -1,5 +1,6 @@ import { IconComponent, + IllustrationIconManyToMany, IllustrationIconOneToMany, IllustrationIconOneToOne, } from 'twenty-ui'; @@ -34,4 +35,11 @@ export const RELATION_TYPES: Record< imageSrc: OneToManySvg, isImageFlipped: true, }, + // Not supported yet + [RelationDefinitionType.ManyToMany]: { + label: 'Belongs to many', + Icon: IllustrationIconManyToMany, + imageSrc: OneToManySvg, + isImageFlipped: true, + }, }; diff --git a/packages/twenty-front/src/modules/settings/data-model/fields/forms/relation/components/SettingsDataModelFieldRelationForm.tsx b/packages/twenty-front/src/modules/settings/data-model/fields/forms/relation/components/SettingsDataModelFieldRelationForm.tsx index 63305b53d0..83f8132643 100644 --- a/packages/twenty-front/src/modules/settings/data-model/fields/forms/relation/components/SettingsDataModelFieldRelationForm.tsx +++ b/packages/twenty-front/src/modules/settings/data-model/fields/forms/relation/components/SettingsDataModelFieldRelationForm.tsx @@ -66,7 +66,11 @@ const StyledInputsContainer = styled.div` `; const RELATION_TYPE_OPTIONS = Object.entries(RELATION_TYPES) - .filter(([value]) => 'ONE_TO_ONE' !== value && 'MANY_TO_MANY' !== value) + .filter( + ([value]) => + RelationDefinitionType.OneToOne !== value && + RelationDefinitionType.ManyToMany !== value, + ) .map(([value, { label, Icon }]) => ({ label, value: value as RelationType,