toggle Field on label between singular and plural based on relation type (#8817)
#7683   Hello, I’ve implemented the logic for dynamically toggling the Field on label between singular and plural based on the relation type selected by the user. Here's an overview of the changes: Added a variable selectedRelationType to store the user’s selected relation type. Based on this variable, I determine whether to use labelPlural or labelSingular from the selectedObjectMetadataItem. Please review my changes and let me know if there's anything that needs improvement . --------- Co-authored-by: Félix Malfait <felix@twenty.com>
This commit is contained in:
@ -9,6 +9,7 @@ import { getObjectTypeLabel } from '@/settings/data-model/utils/getObjectTypeLab
|
||||
export type SettingsDataModelObjectSummaryProps = {
|
||||
className?: string;
|
||||
objectMetadataItem: ObjectMetadataItem;
|
||||
pluralizeLabel?: boolean;
|
||||
};
|
||||
|
||||
const StyledObjectSummary = styled.div`
|
||||
@ -30,6 +31,7 @@ const StyledIconContainer = styled.div`
|
||||
export const SettingsDataModelObjectSummary = ({
|
||||
className,
|
||||
objectMetadataItem,
|
||||
pluralizeLabel = true,
|
||||
}: SettingsDataModelObjectSummaryProps) => {
|
||||
const theme = useTheme();
|
||||
|
||||
@ -43,7 +45,13 @@ export const SettingsDataModelObjectSummary = ({
|
||||
<StyledIconContainer>
|
||||
<ObjectIcon size={theme.icon.size.sm} stroke={theme.icon.stroke.md} />
|
||||
</StyledIconContainer>
|
||||
<OverflowingTextWithTooltip text={objectMetadataItem.labelPlural} />
|
||||
<OverflowingTextWithTooltip
|
||||
text={
|
||||
pluralizeLabel
|
||||
? objectMetadataItem.labelPlural
|
||||
: objectMetadataItem.labelSingular
|
||||
}
|
||||
/>
|
||||
</StyledObjectName>
|
||||
<SettingsDataModelObjectTypeTag objectTypeLabel={objectTypeLabel} />
|
||||
</StyledObjectSummary>
|
||||
|
||||
Reference in New Issue
Block a user