Skip to content

Commit

Permalink
feat: SKFP-927 add sorting to certain columns in studies
Browse files Browse the repository at this point in the history
  • Loading branch information
aperron-ferlab committed Feb 6, 2024
1 parent 6c1a235 commit cf130e3
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 3 deletions.
15 changes: 12 additions & 3 deletions src/views/Studies/components/PageContent/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,11 @@ import { ReadOutlined } from '@ant-design/icons';
import { TExtendedMapping } from '@ferlab/ui/core/components/filters/types';
import ProTable from '@ferlab/ui/core/components/ProTable';
import { ProColumnType } from '@ferlab/ui/core/components/ProTable/types';
import { tieBreaker } from '@ferlab/ui/core/components/ProTable/utils';
import QueryBuilder from '@ferlab/ui/core/components/QueryBuilder';
import useQueryBuilderState from '@ferlab/ui/core/components/QueryBuilder/utils/useQueryBuilderState';
import { isEmptySqon, resolveSyntheticSqon } from '@ferlab/ui/core/data/sqon/utils';
import { SortDirection } from '@ferlab/ui/core/graphql/constants';
import { IExtendedMappingResults } from '@ferlab/ui/core/graphql/types';
import GridCard from '@ferlab/ui/core/view/v2/GridCard';
import { Space, Typography } from 'antd';
Expand Down Expand Up @@ -52,6 +54,12 @@ const PageContent = ({
first: PAGE_SIZE,
offset: PAGE_SIZE * (queryConfig.pageIndex - 1),
sqon: resolvedSqon,
sort: tieBreaker({
sort: queryConfig.sort,
defaultSort: [],
field: 'study_id',
order: queryConfig.operations?.previous ? SortDirection.Desc : SortDirection.Asc,
}),
});

useEffect(() => {
Expand Down Expand Up @@ -114,11 +122,12 @@ const PageContent = ({
initialColumnState={userInfo?.config.study?.tables?.study?.columns}
wrapperClassName={styles.tableWrapper}
loading={loading}
showSorterTooltip={false}
bordered
onChange={({ current, pageSize }, _, sorter) => {
onChange={(_pagination, _filter, sorter) => {
setQueryConfig({
pageIndex: current!,
size: pageSize!,
pageIndex: DEFAULT_PAGE_INDEX,
size: queryConfig.size!,
sort: formatQuerySortList(sorter),
});
}}
Expand Down
6 changes: 6 additions & 0 deletions src/views/Studies/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ const columns: ProColumnType<any>[] = [
{
key: 'study_code',
title: 'Code',
sorter: { multiple: 1 },
render: (record: IStudyEntity) =>
record?.website ? (
<ExternalLink href={record.website}>{record.study_code}</ExternalLink>
Expand All @@ -58,6 +59,7 @@ const columns: ProColumnType<any>[] = [
},
{
key: 'study_name',
sorter: { multiple: 1 },
title: 'Name',
dataIndex: 'study_name',
width: 500,
Expand All @@ -80,6 +82,7 @@ const columns: ProColumnType<any>[] = [
key: 'external_id',
title: 'dbGaP',
dataIndex: 'external_id',
sorter: { multiple: 1 },
render: (externalId: string) =>
externalId ? (
<ExternalLink
Expand All @@ -94,6 +97,7 @@ const columns: ProColumnType<any>[] = [
{
key: 'participant_count',
title: 'Participants',
sorter: { multiple: 1 },
render: (record: IStudyEntity) => {
const participantCount = record.participant_count;

Expand Down Expand Up @@ -126,6 +130,7 @@ const columns: ProColumnType<any>[] = [
{
key: 'biospecimen_count',
title: 'Biospecimens',
sorter: { multiple: 1 },
render: (record: IStudyEntity) => {
const biospecimenCount = record.biospecimen_count;

Expand Down Expand Up @@ -159,6 +164,7 @@ const columns: ProColumnType<any>[] = [
key: 'family_count',
title: 'Families',
dataIndex: 'family_count',
sorter: { multiple: 1 },
render: (family_count: number) =>
family_count ? numberWithCommas(family_count) : TABLE_EMPTY_PLACE_HOLDER,
},
Expand Down

0 comments on commit cf130e3

Please sign in to comment.