-
Notifications
You must be signed in to change notification settings - Fork 2.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support for multiple values in the Phone field
- Loading branch information
1 parent
91187dc
commit 57f9246
Showing
52 changed files
with
793 additions
and
64 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 1 addition & 0 deletions
1
packages/twenty-front/src/modules/object-record/object-filter-dropdown/types/FilterType.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
export type FilterType = | ||
| 'TEXT' | ||
| 'PHONE' | ||
| 'PHONES' | ||
| 'EMAIL' | ||
| 'EMAILS' | ||
| 'DATE_TIME' | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
11 changes: 11 additions & 0 deletions
11
...c/modules/object-record/record-field/meta-types/display/components/PhonesFieldDisplay.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import { useFieldFocus } from '@/object-record/record-field/hooks/useFieldFocus'; | ||
import { usePhonesFieldDisplay } from '@/object-record/record-field/meta-types/hooks/usePhonesFieldDisplay'; | ||
import { PhonesDisplay } from '@/ui/field/display/components/PhonesDisplay'; | ||
|
||
export const PhonesFieldDisplay = () => { | ||
const { fieldValue } = usePhonesFieldDisplay(); | ||
|
||
const { isFocused } = useFieldFocus(); | ||
|
||
return <PhonesDisplay value={fieldValue} isFocused={isFocused} />; | ||
}; |
53 changes: 53 additions & 0 deletions
53
...es/twenty-front/src/modules/object-record/record-field/meta-types/hooks/usePhonesField.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
import { useContext } from 'react'; | ||
import { useRecoilState, useRecoilValue } from 'recoil'; | ||
|
||
import { usePersistField } from '@/object-record/record-field/hooks/usePersistField'; | ||
import { useRecordFieldInput } from '@/object-record/record-field/hooks/useRecordFieldInput'; | ||
import { FieldPhonesValue } from '@/object-record/record-field/types/FieldMetadata'; | ||
import { isFieldPhones } from '@/object-record/record-field/types/guards/isFieldPhones'; | ||
import { phonesSchema } from '@/object-record/record-field/types/guards/isFieldPhonesValue'; | ||
import { recordStoreFamilySelector } from '@/object-record/record-store/states/selectors/recordStoreFamilySelector'; | ||
import { FieldMetadataType } from '~/generated-metadata/graphql'; | ||
|
||
import { FieldContext } from '../../contexts/FieldContext'; | ||
import { assertFieldMetadata } from '../../types/guards/assertFieldMetadata'; | ||
|
||
export const usePhonesField = () => { | ||
const { recordId, fieldDefinition, hotkeyScope } = useContext(FieldContext); | ||
|
||
assertFieldMetadata(FieldMetadataType.Phones, isFieldPhones, fieldDefinition); | ||
|
||
const fieldName = fieldDefinition.metadata.fieldName; | ||
|
||
const [fieldValue, setFieldValue] = useRecoilState<FieldPhonesValue>( | ||
recordStoreFamilySelector({ | ||
recordId, | ||
fieldName: fieldName, | ||
}), | ||
); | ||
|
||
const { setDraftValue, getDraftValueSelector } = | ||
useRecordFieldInput<FieldPhonesValue>(`${recordId}-${fieldName}`); | ||
|
||
const draftValue = useRecoilValue(getDraftValueSelector()); | ||
|
||
const persistField = usePersistField(); | ||
|
||
const persistPhonesField = (nextValue: FieldPhonesValue) => { | ||
try { | ||
persistField(phonesSchema.parse(nextValue)); | ||
} catch { | ||
return; | ||
} | ||
}; | ||
|
||
return { | ||
fieldDefinition, | ||
fieldValue, | ||
draftValue, | ||
setDraftValue, | ||
setFieldValue, | ||
hotkeyScope, | ||
persistPhonesField, | ||
}; | ||
}; |
22 changes: 22 additions & 0 deletions
22
...ty-front/src/modules/object-record/record-field/meta-types/hooks/usePhonesFieldDisplay.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import { useContext } from 'react'; | ||
|
||
import { FieldPhonesValue } from '@/object-record/record-field/types/FieldMetadata'; | ||
import { useRecordFieldValue } from '@/object-record/record-store/contexts/RecordFieldValueSelectorContext'; | ||
|
||
import { FieldContext } from '../../contexts/FieldContext'; | ||
|
||
export const usePhonesFieldDisplay = () => { | ||
const { recordId, fieldDefinition } = useContext(FieldContext); | ||
|
||
const fieldName = fieldDefinition.metadata.fieldName; | ||
|
||
const fieldValue = useRecordFieldValue<FieldPhonesValue | undefined>( | ||
recordId, | ||
fieldName, | ||
); | ||
|
||
return { | ||
fieldDefinition, | ||
fieldValue, | ||
}; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.