Files
payloadcms/test/group-by/collections/Posts/index.ts
Patrik 537f58b4bc feat: adds disableGroupBy to fields admin props (#14017)
### What?

Adds a new `disableGroupBy` admin config property for fields to control
their visibility in the list view GroupBy dropdown.

### Why

Previously, the GroupByBuilder was incorrectly using `disableListFilter`
to determine which fields to show in the group-by dropdown.

### How

- Added new `disableGroupBy` property to the field admin config types.
- Updated `GroupByBuilder` to filter fields based on `disableGroupBy`
instead of `disableListFilter`

---
- To see the specific tasks where the Asana app for GitHub is being
used, see below:
  - https://app.asana.com/0/0/1211511898438807
2025-10-02 06:22:32 -07:00

57 lines
1.0 KiB
TypeScript

import type { CollectionConfig } from 'payload'
import { categoriesSlug } from '../Categories/index.js'
export const postsSlug = 'posts'
export const PostsCollection: CollectionConfig = {
slug: postsSlug,
admin: {
useAsTitle: 'title',
groupBy: true,
defaultColumns: ['title', 'category', 'createdAt', 'updatedAt'],
},
trash: true,
fields: [
{
name: 'title',
type: 'text',
},
{
name: 'category',
type: 'relationship',
relationTo: categoriesSlug,
},
{
name: 'virtualTitleFromCategory',
type: 'text',
virtual: 'category.title',
admin: {
disableGroupBy: true,
},
},
{
name: 'checkbox',
type: 'checkbox',
},
{
name: 'date',
type: 'date',
},
{
type: 'tabs',
tabs: [
{
label: 'Tab 1',
fields: [
{
name: 'tab1Field',
type: 'text',
},
],
},
],
},
],
}