@@ -59,7 +59,6 @@ const initPeriodDetails = (
59
59
periodsVisible : [ ] ,
60
60
periodsIsLoading : true ,
61
61
hidePastPeriods : false ,
62
- lockWorkingDays : false ,
63
62
} ) ;
64
63
65
64
const initialState = {
@@ -375,21 +374,6 @@ const actionHandlers = {
375
374
periodsDetails,
376
375
} ;
377
376
} ,
378
- [ ACTION_TYPE . WP_SET_DETAILS_LOCK_WORKING_DAYS ] : (
379
- state ,
380
- { periodId, lock }
381
- ) => {
382
- const periodsDetails = { ...state . periodsDetails } ;
383
- let periodDetails = periodsDetails [ periodId ] ;
384
- if ( ! periodDetails ) {
385
- return state ;
386
- }
387
- periodsDetails [ periodId ] = { ...periodDetails , lockWorkingDays : lock } ;
388
- return {
389
- ...state ,
390
- periodsDetails,
391
- } ;
392
- } ,
393
377
[ ACTION_TYPE . WP_SET_DETAILS_WORKING_DAYS ] : (
394
378
state ,
395
379
{ parentPeriodId, periodId, workingDays }
@@ -455,7 +439,15 @@ const actionHandlers = {
455
439
delete periodsSelected [ periodId ] ;
456
440
}
457
441
}
458
- 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 ;
459
451
isSelectedPeriodsVisible = true ;
460
452
}
461
453
return {
@@ -549,7 +541,15 @@ const actionHandlers = {
549
541
const isSelected = ! periodsSelected [ periodId ] ;
550
542
if ( isSelected ) {
551
543
periodsSelected [ periodId ] = true ;
552
- 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 ;
553
553
isSelectedPeriodsVisible = true ;
554
554
}
555
555
} else {
@@ -580,18 +580,22 @@ const actionHandlers = {
580
580
} ;
581
581
} ,
582
582
[ ACTION_TYPE . WP_TOGGLE_PERIODS_VISIBLE ] : ( state , on ) => {
583
- const isSelected = on === null ? ! state . isSelectedPeriodsVisible : on ;
583
+ let isSelectedPeriodsAll = false ;
584
+ const isSelectedPeriodsVisible =
585
+ on === null ? ! state . isSelectedPeriodsVisible : on ;
584
586
const periodsSelected = { } ;
585
- if ( isSelected ) {
587
+ if ( isSelectedPeriodsVisible ) {
586
588
for ( let period of state . periods ) {
587
589
periodsSelected [ period . id ] = true ;
588
590
}
591
+ isSelectedPeriodsAll =
592
+ state . periods . length === state . pagination . totalCount ;
589
593
}
590
594
return {
591
595
...state ,
592
596
periodsSelected,
593
- isSelectedPeriodsAll : false ,
594
- isSelectedPeriodsVisible : isSelected ,
597
+ isSelectedPeriodsAll,
598
+ isSelectedPeriodsVisible,
595
599
} ;
596
600
} ,
597
601
[ ACTION_TYPE . WP_TOGGLE_PROCESSING_PAYMENTS ] : ( state , on ) => {
0 commit comments