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:
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user