File tree Expand file tree Collapse file tree 4 files changed +65
-0
lines changed
packages/next/src/views/List Expand file tree Collapse file tree 4 files changed +65
-0
lines changed Original file line number Diff line number Diff line change @@ -163,6 +163,16 @@ export const handleGroupBy = async ({
163
163
} )
164
164
}
165
165
166
+ if ( groupByField . type === 'checkbox' ) {
167
+ if ( valueOrRelationshipID === true ) {
168
+ heading = req . i18n . t ( 'general:true' )
169
+ }
170
+
171
+ if ( valueOrRelationshipID === false ) {
172
+ heading = req . i18n . t ( 'general:false' )
173
+ }
174
+ }
175
+
166
176
if ( groupData . docs && groupData . docs . length > 0 ) {
167
177
const { columnState : newColumnState , Table : NewTable } = renderTable ( {
168
178
clientCollectionConfig,
Original file line number Diff line number Diff line change @@ -22,6 +22,10 @@ export const PostsCollection: CollectionConfig = {
22
22
type : 'relationship' ,
23
23
relationTo : categoriesSlug ,
24
24
} ,
25
+ {
26
+ name : 'checkbox' ,
27
+ type : 'checkbox' ,
28
+ } ,
25
29
{
26
30
name : 'date' ,
27
31
type : 'date' ,
Original file line number Diff line number Diff line change @@ -265,6 +265,55 @@ test.describe('Group By', () => {
265
265
) . toBeVisible ( )
266
266
} )
267
267
268
+ test ( 'should group by boolean values' , async ( ) => {
269
+ await Promise . all ( [
270
+ await payload . create ( {
271
+ collection : postsSlug ,
272
+ data : {
273
+ title : 'Null Post' ,
274
+ checkbox : null ,
275
+ } ,
276
+ } ) ,
277
+ await payload . create ( {
278
+ collection : postsSlug ,
279
+ data : {
280
+ title : 'True Post' ,
281
+ checkbox : true ,
282
+ } ,
283
+ } ) ,
284
+ await payload . create ( {
285
+ collection : postsSlug ,
286
+ data : {
287
+ title : 'False Post' ,
288
+ checkbox : false ,
289
+ } ,
290
+ } ) ,
291
+ ] )
292
+
293
+ await page . goto ( url . list )
294
+
295
+ await addGroupBy ( page , {
296
+ fieldLabel : 'Checkbox' ,
297
+ fieldPath : 'checkbox' ,
298
+ } )
299
+
300
+ await expect ( page . locator ( '.table-wrap' ) ) . toHaveCount ( 3 )
301
+
302
+ await expect ( page . locator ( '.group-by-header' ) ) . toHaveCount ( 3 )
303
+
304
+ await expect (
305
+ page . locator ( '.group-by-header__heading' , { hasText : exactText ( 'No value' ) } ) ,
306
+ ) . toBeVisible ( )
307
+
308
+ await expect (
309
+ page . locator ( '.group-by-header__heading' , { hasText : exactText ( 'True' ) } ) ,
310
+ ) . toBeVisible ( )
311
+
312
+ await expect (
313
+ page . locator ( '.group-by-header__heading' , { hasText : exactText ( 'False' ) } ) ,
314
+ ) . toBeVisible ( )
315
+ } )
316
+
268
317
test ( 'should sort the group-by field globally' , async ( ) => {
269
318
await page . goto ( url . list )
270
319
Original file line number Diff line number Diff line change @@ -125,6 +125,7 @@ export interface Post {
125
125
id : string ;
126
126
title ?: string | null ;
127
127
category ?: ( string | null ) | Category ;
128
+ checkbox ?: boolean | null ;
128
129
date ?: string | null ;
129
130
tab1Field ?: string | null ;
130
131
updatedAt : string ;
@@ -281,6 +282,7 @@ export interface PayloadMigration {
281
282
export interface PostsSelect < T extends boolean = true > {
282
283
title ?: T ;
283
284
category ?: T ;
285
+ checkbox ?: T ;
284
286
date ?: T ;
285
287
tab1Field ?: T ;
286
288
updatedAt ?: T ;
You can’t perform that action at this time.
0 commit comments