@@ -439,7 +439,15 @@ const actionHandlers = {
439
439
delete periodsSelected [ periodId ] ;
440
440
}
441
441
}
442
- if ( Object . keys ( periodsSelected ) . length === state . pagination . pageSize ) {
442
+ const selectedCount = Object . keys ( periodsSelected ) . length ;
443
+ const pageSize = state . pagination . pageSize ;
444
+ const totalCount = state . pagination . totalCount ;
445
+ if ( totalCount > pageSize ) {
446
+ if ( selectedCount === pageSize ) {
447
+ isSelectedPeriodsVisible = true ;
448
+ }
449
+ } else if ( selectedCount === totalCount ) {
450
+ isSelectedPeriodsAll = true ;
443
451
isSelectedPeriodsVisible = true ;
444
452
}
445
453
return {
@@ -533,7 +541,15 @@ const actionHandlers = {
533
541
const isSelected = ! periodsSelected [ periodId ] ;
534
542
if ( isSelected ) {
535
543
periodsSelected [ periodId ] = true ;
536
- if ( Object . keys ( periodsSelected ) . length === state . pagination . pageSize ) {
544
+ const selectedCount = Object . keys ( periodsSelected ) . length ;
545
+ const pageSize = state . pagination . pageSize ;
546
+ const totalCount = state . pagination . totalCount ;
547
+ if ( totalCount > pageSize ) {
548
+ if ( selectedCount === pageSize ) {
549
+ isSelectedPeriodsVisible = true ;
550
+ }
551
+ } else if ( selectedCount === totalCount ) {
552
+ isSelectedPeriodsAll = true ;
537
553
isSelectedPeriodsVisible = true ;
538
554
}
539
555
} else {
@@ -564,18 +580,22 @@ const actionHandlers = {
564
580
} ;
565
581
} ,
566
582
[ ACTION_TYPE . WP_TOGGLE_PERIODS_VISIBLE ] : ( state , on ) => {
567
- const isSelected = on === null ? ! state . isSelectedPeriodsVisible : on ;
583
+ let isSelectedPeriodsAll = false ;
584
+ const isSelectedPeriodsVisible =
585
+ on === null ? ! state . isSelectedPeriodsVisible : on ;
568
586
const periodsSelected = { } ;
569
- if ( isSelected ) {
587
+ if ( isSelectedPeriodsVisible ) {
570
588
for ( let period of state . periods ) {
571
589
periodsSelected [ period . id ] = true ;
572
590
}
591
+ isSelectedPeriodsAll =
592
+ state . periods . length === state . pagination . totalCount ;
573
593
}
574
594
return {
575
595
...state ,
576
596
periodsSelected,
577
- isSelectedPeriodsAll : false ,
578
- isSelectedPeriodsVisible : isSelected ,
597
+ isSelectedPeriodsAll,
598
+ isSelectedPeriodsVisible,
579
599
} ;
580
600
} ,
581
601
[ ACTION_TYPE . WP_TOGGLE_PROCESSING_PAYMENTS ] : ( state , on ) => {
0 commit comments