Fix nested relations (#7158)
Co-authored-by: Charles Bochet <charles@twenty.com>
This commit is contained in:
@ -6,6 +6,7 @@ import { RecordChip } from '@/object-record/components/RecordChip';
|
||||
import { useFieldFocus } from '@/object-record/record-field/hooks/useFieldFocus';
|
||||
import { useRelationFromManyFieldDisplay } from '@/object-record/record-field/meta-types/hooks/useRelationFromManyFieldDisplay';
|
||||
import { ExpandableList } from '@/ui/layout/expandable-list/components/ExpandableList';
|
||||
import { isNull } from '@sniptt/guards';
|
||||
|
||||
export const RelationFromManyFieldDisplay = () => {
|
||||
const { fieldValue, fieldDefinition } = useRelationFromManyFieldDisplay();
|
||||
@ -47,37 +48,43 @@ export const RelationFromManyFieldDisplay = () => {
|
||||
|
||||
return (
|
||||
<ExpandableList isChipCountDisplayed={isFocused}>
|
||||
{fieldValue.map((record) => (
|
||||
<RecordChip
|
||||
key={record.id}
|
||||
objectNameSingular={objectNameSingular}
|
||||
record={record[relationFieldName]}
|
||||
/>
|
||||
))}
|
||||
{fieldValue
|
||||
.filter((record) => !isNull(record[relationFieldName]))
|
||||
.map((record) => (
|
||||
<RecordChip
|
||||
key={record.id}
|
||||
objectNameSingular={objectNameSingular}
|
||||
record={record[relationFieldName]}
|
||||
/>
|
||||
))}
|
||||
</ExpandableList>
|
||||
);
|
||||
} else if (isRelationFromActivityTargets) {
|
||||
return (
|
||||
<ExpandableList isChipCountDisplayed={isFocused}>
|
||||
{activityTargetObjectRecords.map((record) => (
|
||||
<RecordChip
|
||||
key={record.targetObject.id}
|
||||
objectNameSingular={record.targetObjectMetadataItem.nameSingular}
|
||||
record={record.targetObject}
|
||||
/>
|
||||
))}
|
||||
{activityTargetObjectRecords
|
||||
.filter((record) => !isNull(record.targetObject))
|
||||
.map((record) => (
|
||||
<RecordChip
|
||||
key={record.targetObject.id}
|
||||
objectNameSingular={record.targetObjectMetadataItem.nameSingular}
|
||||
record={record.targetObject}
|
||||
/>
|
||||
))}
|
||||
</ExpandableList>
|
||||
);
|
||||
} else {
|
||||
return (
|
||||
<ExpandableList isChipCountDisplayed={isFocused}>
|
||||
{fieldValue.map((record) => (
|
||||
<RecordChip
|
||||
key={record.id}
|
||||
objectNameSingular={relationObjectNameSingular}
|
||||
record={record}
|
||||
/>
|
||||
))}
|
||||
{fieldValue
|
||||
.filter((record) => !isNull(record))
|
||||
.map((record) => (
|
||||
<RecordChip
|
||||
key={record.id}
|
||||
objectNameSingular={relationObjectNameSingular}
|
||||
record={record}
|
||||
/>
|
||||
))}
|
||||
</ExpandableList>
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user