Skip to content

Support Full Name as Record Text Identifier #11610

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
May 19, 2025
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@ import { FieldMetadataType } from '~/generated-metadata/graphql';
export const LABEL_IDENTIFIER_FIELD_METADATA_TYPES = [
FieldMetadataType.NUMBER,
FieldMetadataType.TEXT,
FieldMetadataType.FULL_NAME,
];
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { recordIndexOpenRecordInState } from '@/object-record/record-index/state
import { ObjectRecord } from '@/object-record/types/ObjectRecord';
import { ViewOpenRecordInType } from '@/views/types/ViewOpenRecordInType';
import { useRecoilValue } from 'recoil';
import { FieldMetadataType } from 'twenty-shared/types';
import {
AvatarChip,
AvatarChipVariant,
Expand All @@ -23,6 +24,7 @@ export type RecordChipProps = {
to?: string | undefined;
size?: ChipSize;
isLabelHidden?: boolean;
field?: { type: string; name: string };
};

export const RecordChip = ({
Expand All @@ -35,6 +37,7 @@ export const RecordChip = ({
size,
forceDisableClick = false,
isLabelHidden = false,
field,
}: RecordChipProps) => {
const { recordChipData } = useRecordChipData({
objectNameSingular,
Expand Down Expand Up @@ -70,12 +73,18 @@ export const RecordChip = ({
})
: undefined;

let name = recordChipData.name;

if (field?.type === FieldMetadataType.FULL_NAME) {
name = `${record[field.name]?.firstName || ''} ${record[field.name]?.lastName || ''}`;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

style: Consider adding .trim() to remove extra space when either firstName or lastName is empty

Suggested change
name = `${record[field.name]?.firstName || ''} ${record[field.name]?.lastName || ''}`;
name = `${record[field.name]?.firstName || ''} ${record[field.name]?.lastName || ''}`.trim();

}

return (
<LinkAvatarChip
size={size}
maxWidth={maxWidth}
placeholderColorSeed={record.id}
name={recordChipData.name}
name={name}
isLabelHidden={isLabelHidden}
avatarType={recordChipData.avatarType}
avatarUrl={recordChipData.avatarUrl ?? ''}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ export const ChipFieldDisplay = () => {
objectNameSingular,
labelIdentifierLink,
isLabelIdentifierCompact,
fieldDefinition,
} = useChipFieldDisplay();

if (!isDefined(recordValue)) {
Expand All @@ -22,6 +23,10 @@ export const ChipFieldDisplay = () => {
size={ChipSize.Small}
to={labelIdentifierLink}
isLabelHidden={isLabelIdentifierCompact}
field={{
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

see comment above

type: fieldDefinition.type,
name: fieldDefinition.metadata.fieldName,
}}
/>
);
};
Original file line number Diff line number Diff line change
Expand Up @@ -48,5 +48,6 @@ export const useChipFieldDisplay = () => {
isLabelIdentifier,
labelIdentifierLink,
isLabelIdentifierCompact,
fieldDefinition,
};
};
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ import { useSnackBar } from '@/ui/feedback/snack-bar-manager/hooks/useSnackBar';
import { Select } from '@/ui/input/components/Select';
import { zodResolver } from '@hookform/resolvers/zod';
import { t } from '@lingui/core/macro';
import { IconCircleOff, useIcons } from 'twenty-ui/display';
import { useNavigate } from 'react-router-dom';
import { IconCircleOff, IconPlus, useIcons } from 'twenty-ui/display';
import { SelectOption } from 'twenty-ui/input';

export const settingsDataModelObjectIdentifiersFormSchema =
Expand Down Expand Up @@ -100,6 +101,9 @@ export const SettingsDataModelObjectIdentifiersForm = ({
label: 'None',
value: null,
};

const navigate = useNavigate();

return (
<StyledContainer>
{[
Expand All @@ -124,12 +128,23 @@ export const SettingsDataModelObjectIdentifiersForm = ({
render={({ field: { onChange, value } }) => (
<Select
label={label}
disabled={!objectMetadataItem.isCustom || !options.length}
fullWidth
dropdownId={`${fieldName}-select`}
emptyOption={emptyOption}
options={options}
value={value}
withSearchInput={label === t`Record label`}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't understand this change

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In Issue, required change is only in 'Record Label' dropdown, Not in 'Record Image' dropdown.

callToActionButton={
label === t`Record label`
? {
text: 'Create Text Field',
Icon: IconPlus,
onClick: () => {
navigate('./new-field/select');
},
}
: undefined
}
onChange={(value) => {
onChange(value);
formConfig.handleSubmit(handleSave)();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ const reservedKeywords = [
'links',
'currency',
'currencies',
'fullName',
'fullNames',
Comment on lines 52 to 53
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

style: Consider whether 'fullNames' should also be removed for consistency since 'fullName' is now allowed

'address',
'addresses',
Expand Down
Loading