Add relation in CSV exports (#5085)

### Description

Add Relation Id to Table in CSV exports

### Demo

Before:


<https://www.loom.com/share/c853cf32767947dcb23a91363bff52c4?sid=0295b6ee-4510-47f8-8ba9-b81b5182985a>

After:


<https://www.loom.com/share/5aa4f87a266c4d96881170a38e063fc0?sid=44eed60c-01a2-406f-9bac-af162e39b66e>

Co-authored-by: gitstart-twenty <gitstart-twenty@users.noreply.github.com>
Co-authored-by: Lucas Bordeau <bordeau.lucas@gmail.com>
Co-authored-by: v1b3m <vibenjamin6@gmail.com>
Co-authored-by: Chiazokam <chiazokamecheta@gmail.com>
This commit is contained in:
gitstart-app[bot] 2024-05-01 15:24:23 +02:00 committed by GitHub
parent 0d023e5e77
commit 485670c823
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -34,14 +34,16 @@ export const generateCsv: GenerateExport = ({
columns,
rows,
}: GenerateExportOptions): string => {
const columnsWithoutRelations = columns.filter(
(col) => !('relationType' in col.metadata && col.metadata.relationType),
const columnsToExport = columns.filter(
(col) =>
!('relationType' in col.metadata && col.metadata.relationType) ||
col.metadata.relationType === 'TO_ONE_OBJECT',
);
const keys = columnsWithoutRelations.flatMap((col) => {
const keys = columnsToExport.flatMap((col) => {
const column = {
field: col.metadata.fieldName,
title: col.label,
field: `${col.metadata.fieldName}${col.type === 'RELATION' ? 'Id' : ''}`,
title: `${col.label} ${col.type === 'RELATION' ? 'Id' : ''}`,
};
const fieldsWithSubFields = rows.find((row) => {