feat(ui): add support for disabling join field row types (#12738)
### What? This PR adds a new `admin.disableRowTypes` config to `'join'` fields which hides the `"Type"` column from the relationship table. ### Why? While the collection type column _can be_ helpful for providing information, it's not always necessary and can sometimes be redundant when the field only has a singular relationTo. Hiding it can be helpful by removing visual noise and providing editors the data directly. ### How? By threading `admin.disableRowTypes` directly to the `getTableState` function of the `RelationshipTable` component. **With row types** (via `admin.disableRowTypes: false | undefined` OR default for polymorphic):  **Without row types** (default for monomorphic): 
This commit is contained in:
@@ -4,6 +4,7 @@ import { ValidationError } from 'payload'
|
||||
|
||||
import { categoriesSlug, hiddenPostsSlug, postsSlug } from '../shared.js'
|
||||
import { singularSlug } from './Singular.js'
|
||||
import { versionsSlug } from './Versions.js'
|
||||
|
||||
export const Categories: CollectionConfig = {
|
||||
slug: categoriesSlug,
|
||||
@@ -55,6 +56,7 @@ export const Categories: CollectionConfig = {
|
||||
beforeInput: ['/components/BeforeInput.js#BeforeInput'],
|
||||
Description: '/components/CustomDescription/index.js#FieldDescriptionComponent',
|
||||
},
|
||||
disableRowTypes: false,
|
||||
},
|
||||
collection: postsSlug,
|
||||
defaultSort: '-title',
|
||||
@@ -62,6 +64,14 @@ export const Categories: CollectionConfig = {
|
||||
on: 'category',
|
||||
maxDepth: 1,
|
||||
},
|
||||
{
|
||||
name: 'noRowTypes',
|
||||
type: 'join',
|
||||
collection: postsSlug,
|
||||
defaultLimit: 5,
|
||||
on: 'category',
|
||||
maxDepth: 1,
|
||||
},
|
||||
{
|
||||
name: 'hasManyPosts',
|
||||
type: 'join',
|
||||
@@ -95,6 +105,7 @@ export const Categories: CollectionConfig = {
|
||||
on: 'group.category',
|
||||
admin: {
|
||||
defaultColumns: ['id', 'createdAt', 'title'],
|
||||
disableRowTypes: false,
|
||||
},
|
||||
},
|
||||
{
|
||||
@@ -129,6 +140,21 @@ export const Categories: CollectionConfig = {
|
||||
collection: 'posts',
|
||||
on: 'blocks.category',
|
||||
},
|
||||
{
|
||||
name: 'polymorphicJoin',
|
||||
type: 'join',
|
||||
collection: [postsSlug, versionsSlug],
|
||||
on: 'category',
|
||||
},
|
||||
{
|
||||
name: 'polymorphicJoinNoRowTypes',
|
||||
type: 'join',
|
||||
collection: [postsSlug, versionsSlug],
|
||||
on: 'category',
|
||||
admin: {
|
||||
disableRowTypes: true,
|
||||
},
|
||||
},
|
||||
{
|
||||
name: 'polymorphic',
|
||||
type: 'join',
|
||||
|
||||
Reference in New Issue
Block a user