@@ -23,7 +23,9 @@ class GradersManager extends React.Component {
2323 sections : { } ,
2424 isGraderDistributionModalOpen : false ,
2525 show_hidden : false ,
26+ show_hidden_groups : false ,
2627 hidden_graders_count : 0 ,
28+ inactive_groups_count : 0 ,
2729 } ;
2830 }
2931
@@ -66,6 +68,15 @@ class GradersManager extends React.Component {
6668 if ( this . groupsTable ) this . groupsTable . resetSelection ( ) ;
6769 if ( this . criteriaTable ) this . criteriaTable . resetSelection ( ) ;
6870
71+ let inactive_groups_count = 0 ;
72+ res . groups . forEach ( group => {
73+ if ( group . members . length && group . members . every ( member => member [ 2 ] ) ) {
74+ group . inactive = true ;
75+ inactive_groups_count += 1 ;
76+ } else {
77+ group . inactive = false ;
78+ }
79+ } ) ;
6980 this . setState ( {
7081 graders : res . graders ,
7182 groups : res . groups ,
@@ -77,6 +88,7 @@ class GradersManager extends React.Component {
7788 hide_unassigned_criteria : res . hide_unassigned_criteria ,
7889 isGraderDistributionModalOpen : false ,
7990 hidden_graders_count : res . graders . filter ( grader => grader . hidden ) . length ,
91+ inactive_groups_count : inactive_groups_count ,
8092 } ) ;
8193 } ) ;
8294 } ;
@@ -282,6 +294,11 @@ class GradersManager extends React.Component {
282294 this . setState ( { show_hidden} ) ;
283295 } ;
284296
297+ toggleShowHiddenGroups = event => {
298+ let show_hidden_groups = event . target . checked ;
299+ this . setState ( { show_hidden_groups} ) ;
300+ } ;
301+
285302 render ( ) {
286303 return (
287304 < div >
@@ -290,8 +307,11 @@ class GradersManager extends React.Component {
290307 openGraderDistributionModal = { this . openGraderDistributionModal }
291308 unassignAll = { this . unassignAll }
292309 showHidden = { this . state . show_hidden }
310+ showHiddenGroups = { this . state . show_hidden_groups }
293311 updateShowHidden = { this . toggleShowHidden }
312+ updateShowHiddenGroups = { this . toggleShowHiddenGroups }
294313 hiddenGradersCount = { this . state . loading ? null : this . state . hidden_graders_count }
314+ hiddenGroupsCount = { this . state . loading ? null : this . state . inactive_groups_count }
295315 />
296316 < div className = "mapping-tables" >
297317 < div className = "mapping-table" >
@@ -346,6 +366,7 @@ class GradersManager extends React.Component {
346366 sections = { this . state . sections }
347367 numCriteria = { this . state . criteria . length }
348368 showCoverage = { this . state . assign_graders_to_criteria }
369+ showInactive = { this . state . show_hidden_groups }
349370 />
350371 </ TabPanel >
351372 < TabPanel >
@@ -509,6 +530,14 @@ class RawGroupsTable extends React.Component {
509530
510531 getColumns = ( ) => {
511532 return [
533+ {
534+ accessor : "inactive" ,
535+ id : "inactive" ,
536+ width : 0 ,
537+ className : "rt-hidden" ,
538+ headerClassName : "rt-hidden" ,
539+ resizable : false ,
540+ } ,
512541 {
513542 show : false ,
514543 accessor : "_id" ,
@@ -582,6 +611,19 @@ class RawGroupsTable extends React.Component {
582611 ] ;
583612 } ;
584613
614+ static getDerivedStateFromProps ( props , state ) {
615+ let filtered = state . filtered . filter ( group => group . id !== "inactive" ) ;
616+
617+ if ( ! props . showInactive ) {
618+ filtered . push ( { id : "inactive" , value : false } ) ;
619+ }
620+ return { filtered} ;
621+ }
622+
623+ onFilteredChange = filtered => {
624+ this . setState ( { filtered} ) ;
625+ } ;
626+
585627 render ( ) {
586628 return (
587629 < CheckboxTable
@@ -595,6 +637,8 @@ class RawGroupsTable extends React.Component {
595637 ] }
596638 loading = { this . props . loading }
597639 filterable
640+ filtered = { this . state . filtered }
641+ onFilteredChange = { this . onFilteredChange }
598642 { ...this . props . getCheckboxProps ( ) }
599643 />
600644 ) ;
@@ -682,11 +726,15 @@ const CriteriaTable = withSelection(RawCriteriaTable);
682726
683727class GradersActionBox extends React . Component {
684728 render = ( ) => {
685- let showHiddenTooltip = "" ;
686- if ( this . props . hiddenGradersCount !== null ) {
687- showHiddenTooltip = I18n . t ( "graders.inactive_graders_count" , {
688- count : this . props . hiddenGradersCount || 0 ,
689- } ) ;
729+ let showHiddenGraderTooltip = "" ;
730+ let showHiddenGroupsTooltip = "" ;
731+ if ( this . props . hiddenGradersCount !== null && this . props . hiddenGroupsCount !== null ) {
732+ showHiddenGraderTooltip = `${ I18n . t ( "graders.inactive_graders_count" , {
733+ count : this . props . hiddenGradersCount ,
734+ } ) } `;
735+ showHiddenGroupsTooltip = `${ I18n . t ( "activerecord.attributes.grouping.inactive_groups" , {
736+ count : this . props . hiddenGroupsCount ,
737+ } ) } `;
690738 }
691739
692740 return (
@@ -700,10 +748,28 @@ class GradersActionBox extends React.Component {
700748 onChange = { this . props . updateShowHidden }
701749 className = { "hide-user-checkbox" }
702750 />
703- < label title = { showHiddenTooltip } htmlFor = "show_hidden" >
751+ < label title = { showHiddenGraderTooltip } htmlFor = "show_hidden" >
704752 { I18n . t ( "tas.display_inactive" ) }
705753 </ label >
706754 </ span >
755+ < span >
756+ < input
757+ id = "show_hidden_groups"
758+ name = "show_hidden_groups"
759+ type = "checkbox"
760+ checked = { this . props . showHiddenGroups }
761+ onChange = { this . props . updateShowHiddenGroups }
762+ className = { "hide-user-checkbox" }
763+ data-testid = { "show_hidden_groups" }
764+ />
765+ < label
766+ title = { showHiddenGroupsTooltip }
767+ htmlFor = "show_hidden_groups"
768+ data-testid = { "show_hidden_groups_tooltip" }
769+ >
770+ { I18n . t ( "groups.display_inactive" ) }
771+ </ label >
772+ </ span >
707773 < button onClick = { this . props . assignAll } >
708774 < FontAwesomeIcon icon = "fa-solid fa-user-plus" />
709775 { I18n . t ( "graders.actions.assign_grader" ) }
@@ -724,3 +790,4 @@ class GradersActionBox extends React.Component {
724790export function makeGradersManager ( elem , props ) {
725791 render ( < GradersManager { ...props } /> , elem ) ;
726792}
793+ export { GradersManager } ;
0 commit comments