Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

KPMP-5693_add-tooltips #280

Merged
merged 3 commits into from
Nov 21, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
71 changes: 51 additions & 20 deletions src/components/SpatialViewer/ImageDatasetList.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React, { Component } from 'react';
import { DndProvider } from 'react-dnd'
import { HTML5Backend } from 'react-dnd-html5-backend'
import {Col, Container, Row, Spinner} from "reactstrap";
import {Col, Container, Row, Spinner, UncontrolledTooltip} from "reactstrap";
import { resultConverter } from "../../helpers/dataHelper";
import { getImageTypeTooltipCopy } from "./viewConfigHelper";
import { faXmark, faAnglesRight, faAnglesLeft, faTrashCan } from "@fortawesome/free-solid-svg-icons";
Expand Down Expand Up @@ -215,25 +215,56 @@ class ImageDatasetList extends Component {
};

getFilterPills = (filters) => {
return filters.map(
filter => {
return filter.values.map(value => {
return (
<div
key={(filter.field).toString() + value.toString()}
className="border rounded activeFilter">
<span>{value}
<FontAwesomeIcon
alt="Close Filter"
onClick={()=>{
this.props.removeFilter(filter.field, value)
}}
className="close-button fas fa-xmark ms-2"
icon={faXmark} />
</span>
</div>)
})
})
const filterDisplayNames = {
sex: "Sex",
age: "Age",
redcapid: "Participant ID",
enrollmentcategory: "Enrollment Category",
imagetype: "Image Type",
datatype: "Data Type",
configtype: "Config Type",
level: "Level",
releaseversion: "Release Version",
race: "Race",
proteinuria: "Proteinuria",
hypertensionhistory: "Hypertension History",
hypertensionduration: "Hypertension Duration",
onraasblockade: "RAAS Blockade",
diabetesduration: "Diabetes Duration",
diabeteshistory: "Diabetes History",
kdigostage: "KDIGO Stage",
a1c: "A1c",
albuminuria: "Albuminuria",
baselineegfr: "Baseline eGFR",
primaryadjudicatedcategory: "Primary Adjudicated Category"
};

return filters.map(filter => {
return filter.values.map(value => {
const sanitizedId = `${filter.field.toString()}-${value.toString()}`.replace(/[^a-zA-Z0-9-_]/g, '_');
return (
<div
key={sanitizedId}
className="border rounded activeFilter"
id={sanitizedId}
>
<span>{value}
<UncontrolledTooltip placement="bottom" target={sanitizedId}>
{filterDisplayNames[filter.field] || filter.field}
</UncontrolledTooltip>
<FontAwesomeIcon
alt="Close Filter"
onClick={() => {
this.props.removeFilter(filter.field, value);
}}
className="close-button fas fa-xmark ms-2"
icon={faXmark}
/>
</span>
</div>
);
});
});
};

render() {
Expand Down
Loading