Skip to content

Commit 6e84d1b

Browse files
Merge branch 'develop' into dependabot-npm_and_yarn-apps-backend-multi-c66b7f6fbe
2 parents 51f58f3 + 83cc7f0 commit 6e84d1b

2 files changed

Lines changed: 42 additions & 0 deletions

File tree

apps/frontend/src/components/fap/Proposals/ProposalsView/FapProposalsAndAssignmentsTable.tsx

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ import {
3535
standardDeviation,
3636
} from 'utils/mathFunctions';
3737
import useDataApiWithFeedback from 'utils/useDataApiWithFeedback';
38+
import { getFullUserName } from 'utils/user';
3839
import withConfirm, { WithConfirmType } from 'utils/withConfirm';
3940

4041
type 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),

apps/frontend/src/graphql/fap/getFapProposals.graphql

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@ query getFapProposals($fapId: Int!, $callId: Int, $instrumentId: Int, $legacy: B
1111
proposalId
1212
proposer {
1313
id
14+
firstname
15+
lastname
16+
preferredname
1417
institutionId
1518
}
1619
status {

0 commit comments

Comments
 (0)