feat: join field admin.defaultColumns (#9982)

Add the ability to specify which columns should appear in the
relationship table of a join fields

The new property is in the Join field `admin.defaultColumns` and can be
set to an array of strings containing the field names in the desired
order.
This commit is contained in:
Dan Ribbens
2024-12-14 22:31:31 -05:00
committed by GitHub
parent f5516b96da
commit 2ec4d0c2ef
6 changed files with 42 additions and 16 deletions

View File

@@ -115,12 +115,21 @@ export const RelationshipTable: React.FC<RelationshipTableComponentProps> = (pro
newQuery.where = hoistQueryParamsToAnd(newQuery.where, filterOptions)
}
// map columns from string[] to ColumnPreferences
const defaultColumns = field.admin.defaultColumns
? field.admin.defaultColumns.map((accessor) => ({
accessor,
active: true,
}))
: undefined
const {
data: newData,
state: newColumnState,
Table: NewTable,
} = await getTableState({
collectionSlug: relationTo,
columns: defaultColumns,
docs,
enableRowSelections: false,
query: newQuery,
@@ -134,11 +143,12 @@ export const RelationshipTable: React.FC<RelationshipTableComponentProps> = (pro
setIsLoadingTable(false)
},
[
query,
field.defaultLimit,
field.defaultSort,
field.admin.defaultColumns,
collectionConfig.admin.pagination.defaultLimit,
collectionConfig.defaultSort,
query,
filterOptions,
getTableState,
relationTo,