Skip to content

Commit

Permalink
[Platform]: add custom sorting to the chemical probes table (#279)
Browse files Browse the repository at this point in the history
  • Loading branch information
LucaFumis committed Nov 9, 2023
1 parent 49c7549 commit c0e2ea6
Showing 1 changed file with 14 additions and 5 deletions.
19 changes: 14 additions & 5 deletions packages/sections/src/target/ChemicalProbes/Body.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { definition } from ".";
import Description from "./Description";
import CHEMICAL_PROBES_QUERY from "./ChemicalProbes.gql";
import { naLabel, defaultRowsPerPageOptions } from "../../constants";
import _ from "lodash";

/**
* Style the tooltips as "label: value" with a bold label
Expand Down Expand Up @@ -96,17 +97,24 @@ function Body({ id, label: symbol, entity }) {
request={request}
entity={entity}
renderDescription={() => <Description symbol={symbol} />}
renderBody={(data) =>
data.target.chemicalProbes?.length > 0 ? (
renderBody={(data) => {
// sort probes manually as we need a custom sort based score, quality and origin
const sortedProbes = _.orderBy(data.target.chemicalProbes, [
'probesDrugsScore',
'isHighQuality',
p => p.origin?.map(o => o.toLowerCase()).includes('experimental'),
], ['desc', 'desc', 'desc']);

return data.target.chemicalProbes?.length > 0 ? (
<DataTable
columns={columns}
rows={data.target.chemicalProbes}
rows={sortedProbes}
showGlobalFilter
dataDownloader
dataDownloaderFileStem={`${symbol}-chemical-probes`}
fixed
sortBy="probesDrugsScore"
order="desc"
// sortBy="probesDrugsScore"
// order="desc"
rowsPerPageOptions={defaultRowsPerPageOptions}
noWrap={false}
noWrapHeader={false}
Expand All @@ -115,6 +123,7 @@ function Body({ id, label: symbol, entity }) {
/>
) : null
}
}
/>
);
}
Expand Down

0 comments on commit c0e2ea6

Please sign in to comment.