Skip to content

Commit

Permalink
Merge branch 'feat/allow-function-fields-in-export' into alpha
Browse files Browse the repository at this point in the history
  • Loading branch information
mguellsegarra committed Sep 6, 2024
2 parents 6641a03 + b6248c3 commit 8d23a64
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions src/hooks/useExport.ts
Original file line number Diff line number Diff line change
Expand Up @@ -235,18 +235,16 @@ const convertToExportFields = ({
for (const key of Object.keys(fields)) {
const valuesForField = fields[key];

if (valuesForField.relation && valuesForField.is_function === true) {
continue;
}

const relationField = isRelationField(valuesForField);
const isFunctionField = valuesForField.is_function === true;
const canBeExpanded = relationField && !isFunctionField;

exportFields.push({
key: compoundId({ key, parentKey }),
title: valuesForField.string,
tooltip: valuesForField.help,
required: valuesForField.required,
isLeaf: !relationField,
isLeaf: !canBeExpanded,
});
}
return exportFields;
Expand Down Expand Up @@ -407,7 +405,8 @@ const addIdToRelationFields = ({
const fieldDefinition = getFieldDefinition(key, fields);
const optsForField = fieldDefinition[childKey];
const relationField = isRelationField(optsForField);
return relationField ? `${key}/id` : key;
const functionField = optsForField.is_function === true;
return relationField && !functionField ? `${key}/id` : key;
});

const splitAndSortKeys = (keys: string[]): string[] => {
Expand Down

0 comments on commit 8d23a64

Please sign in to comment.