From d1080ca87832c8682e6891d78279deac542e762b Mon Sep 17 00:00:00 2001 From: Adam Gibson Date: Thu, 2 May 2024 11:52:06 -0500 Subject: [PATCH] SCRUM-3853 add sorting and filtering to DiseaseToModelTable --- .../diseasePage/DiseaseToModelTable.js | 43 +++++++++++++++++-- 1 file changed, 40 insertions(+), 3 deletions(-) diff --git a/src/containers/diseasePage/DiseaseToModelTable.js b/src/containers/diseasePage/DiseaseToModelTable.js index 4b9fcb3c..2111d1a8 100644 --- a/src/containers/diseasePage/DiseaseToModelTable.js +++ b/src/containers/diseasePage/DiseaseToModelTable.js @@ -8,7 +8,9 @@ import { } from '../../components/dataTable'; import ExperimentalConditionCellCuration from '../../components/dataTable/ExperimentalConditionCellCuration'; import GeneticModifiersCellCuration from '../../components/dataTable/GeneticModifiersCellCuration'; -import { buildProvidersWithUrl, getIdentifier } from '../../components/dataTable/utils'; +import { buildProvidersWithUrl, getIdentifier, getDistinctFieldValue } from '../../components/dataTable/utils'; +import { compareByFixedOrder } from '../../lib/utils'; +import { SPECIES_NAME_ORDER } from '../../constants'; import useDataTableQuery from '../../hooks/useDataTableQuery'; import SpeciesName from '../../components/SpeciesName'; import AssociationType from '../../components/AssociationType'; @@ -48,6 +50,7 @@ const DiseaseToModelTable = ({id}) => { ), + filterable: true, filterName: 'modelName', headerStyle: {width: '280px'}, }, @@ -57,12 +60,17 @@ const DiseaseToModelTable = ({id}) => { formatter: species => , filterFormatter: speciesName => {speciesName}, headerStyle: {width: '105px'}, + filterName: 'species', + filterable: getDistinctFieldValue(resolvedData, 'species').sort(compareByFixedOrder(SPECIES_NAME_ORDER)), + filterType: 'checkbox', }, { dataField: 'experimentalConditionList', text: 'Experimental condition', formatter: conditions => , headerStyle: {width: '220px'}, + filterName: "experimentalCondition", + filterable: true, }, { dataField: 'generatedRelationString', @@ -70,37 +78,49 @@ const DiseaseToModelTable = ({id}) => { formatter: type => , filterFormatter: type => , headerStyle: {width: '120px'}, + filterName: 'associationType', + filterable: getDistinctFieldValue(resolvedData, 'associationType'), + filterType: 'checkbox', }, { dataField: 'diseaseQualifiers', text: 'Disease Qualifiers', headerStyle: { width: '150px' }, formatter: qualifiers => , + filterable: getDistinctFieldValue(resolvedData, 'diseaseQualifiers'), + filterName: 'diseaseQualifier', + filterType: 'checkbox', }, { dataField: 'disease', text: 'Disease', headerStyle: { width: '150px' }, formatter: (curie, row) => , + filterable: true, }, { dataField: 'conditionModifierList', text: 'Condition Modifier', formatter: conditions => , headerStyle: {width: '220px'}, + filterName: "conditionModifier", + filterable: true, }, { dataField: 'geneticModifierList', text: 'Genetic Modifier', formatter: (modifiers, row) => , headerStyle: {width: '220px'}, + filterName: "geneticModifier", + filterable: true, }, { dataField: 'evidenceCodes', text: 'Evidence', - formatter: codes => , headerStyle: {width: '100px'}, filterName: 'evidenceCode', + formatter: (codes) => , + filterable: true, }, { dataField: 'providers', @@ -108,13 +128,15 @@ const DiseaseToModelTable = ({id}) => { formatter: providers => providers && , headerStyle: { width: '100px' }, filterName: 'dataProvider', + filterable: true, }, { dataField: 'pubmedPubModIDs', text: 'References', formatter: (pubModIds) => , headerStyle: {width: '150px'}, - filterName: 'reference' + filterName: 'reference', + filterable: true, } ]; @@ -124,6 +146,20 @@ const DiseaseToModelTable = ({id}) => { ...association, })); + const sortOptions = [ + { + value: 'disease', + label: 'Disease', + }, + { + value: 'model', + label: 'Model', + }, + { + value: 'species', + label: 'Species', + }, + ]; return ( { data={data} downloadUrl={`/api/disease/${id}/models/download`} keyField='primaryKey' + sortOptions={sortOptions} /> ); };