@@ -35,6 +35,7 @@ import {
3535 standardDeviation ,
3636} from 'utils/mathFunctions' ;
3737import useDataApiWithFeedback from 'utils/useDataApiWithFeedback' ;
38+ import { getFullUserName } from 'utils/user' ;
3839import withConfirm , { WithConfirmType } from 'utils/withConfirm' ;
3940
4041type FapProposalsAndAssignmentsTableProps = {
@@ -82,6 +83,18 @@ const FapProposalColumns: Column<FapProposalType>[] = [
8283 title : 'Title' ,
8384 field : 'proposal.title' ,
8485 } ,
86+ {
87+ title : 'Principal Investigator' ,
88+ render : ( rowData ) => {
89+ return getFullUserName ( rowData . proposal . proposer ) ;
90+ } ,
91+ customSort ( a , b ) {
92+ const name1 = getFullUserName ( a . proposal . proposer ) ;
93+ const name2 = getFullUserName ( b . proposal . proposer ) ;
94+
95+ return name1 < name2 ? - 1 : 1 ;
96+ } ,
97+ } ,
8598 {
8699 title : 'Status' ,
87100 field : 'proposal.status.name' ,
@@ -93,6 +106,8 @@ const FapProposalColumns: Column<FapProposalType>[] = [
93106 {
94107 title : 'Reviewers' ,
95108 render : ( data ) => data . assignments ?. length ,
109+ customSort : ( a , b ) =>
110+ ( a . assignments ?. length || 0 ) - ( b . assignments ?. length || 0 ) ,
96111 } ,
97112 {
98113 title : 'Reviews' ,
@@ -106,6 +121,29 @@ const FapProposalColumns: Column<FapProposalType>[] = [
106121
107122 return totalReviews === 0 ? '-' : `${ countReviews } / ${ totalReviews } ` ;
108123 } ,
124+ customSort : ( a , b ) => {
125+ const totalReviewsA = a . assignments ?. length || 0 ;
126+ const totalReviewsB = b . assignments ?. length || 0 ;
127+ const gradedProposalsA =
128+ a . assignments ?. filter (
129+ ( assignment ) =>
130+ assignment . review !== null && assignment . review . grade !== null
131+ ) . length || 0 ;
132+ const gradedProposalsB =
133+ b . assignments ?. filter (
134+ ( assignment ) =>
135+ assignment . review !== null && assignment . review . grade !== null
136+ ) . length || 0 ;
137+
138+ const incompleteReviewsA = totalReviewsA - gradedProposalsA ;
139+ const incompleteReviewsB = totalReviewsB - gradedProposalsB ;
140+
141+ if ( incompleteReviewsA === incompleteReviewsB ) {
142+ return totalReviewsB - totalReviewsA ;
143+ }
144+
145+ return incompleteReviewsA - incompleteReviewsB ;
146+ } ,
109147 } ,
110148 {
111149 title : 'Average grade' ,
@@ -459,6 +497,7 @@ const FapProposalsAndAssignmentsTable = ({
459497 ] }
460498 actions = { tableActions }
461499 options = { {
500+ columnsButton : true ,
462501 search : true ,
463502 selection : true ,
464503 pageSize : pageSize ? + pageSize : Math . min ( 10 , maxPageLength ) ,
0 commit comments