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:
committed by
GitHub
parent
0d023e5e77
commit
485670c823
@ -34,14 +34,16 @@ export const generateCsv: GenerateExport = ({
|
|||||||
columns,
|
columns,
|
||||||
rows,
|
rows,
|
||||||
}: GenerateExportOptions): string => {
|
}: GenerateExportOptions): string => {
|
||||||
const columnsWithoutRelations = columns.filter(
|
const columnsToExport = columns.filter(
|
||||||
(col) => !('relationType' in col.metadata && col.metadata.relationType),
|
(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 = {
|
const column = {
|
||||||
field: col.metadata.fieldName,
|
field: `${col.metadata.fieldName}${col.type === 'RELATION' ? 'Id' : ''}`,
|
||||||
title: col.label,
|
title: `${col.label} ${col.type === 'RELATION' ? 'Id' : ''}`,
|
||||||
};
|
};
|
||||||
|
|
||||||
const fieldsWithSubFields = rows.find((row) => {
|
const fieldsWithSubFields = rows.find((row) => {
|
||||||
|
|||||||
Reference in New Issue
Block a user