Skip to content

Commit

Permalink
#110 #113 - download cols fix + show all reset fix
Browse files Browse the repository at this point in the history
  • Loading branch information
D-GopalKrishna committed Mar 18, 2024
1 parent 274e3b4 commit c8fd7ec
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ import {
GridColDef,
GridRenderCellParams,
GridCsvExportOptions,
GridNoRowsOverlay
GridNoRowsOverlay,
GridColumnVisibilityModel
} from "@mui/x-data-grid";
import {
Typography,
Expand All @@ -32,7 +33,7 @@ import {
import MoreVertIcon from '@mui/icons-material/MoreVert';
import TableHeader from "./HomeHeader";
import { Antibody } from "../../rest";
import { checkIfFilterSetExists, getProperCitation, getRandomId } from "../../utils/antibody";
import { checkIfFilterSetExists, getColumnsToDisplay, getProperCitation, getRandomId } from "../../utils/antibody";
import { UserContext } from "../../services/UserService";
import ConnectAccount from "./ConnectAccount";
import { ALLRESULTS, SEARCH_MODES, MYSUBMISSIONS, BLANK_FILTER_MODEL } from "../../constants/constants";
Expand Down Expand Up @@ -158,8 +159,8 @@ const RenderVendor = (props) => (
className="col-vendor"
>
{props.row.url ? <Link className="link-vendor" bgcolor="primary.light" px={0.5} py={0.25} display="block" underline="none" target="_blank" href={props.row.url}>
{props.row.vendorName}
</Link> : props.row.vendorName}
{props.value}
</Link> : props.value}
</Typography>
)

Expand Down Expand Up @@ -447,14 +448,12 @@ const AntibodiesTable = (props) => {
field: "abName",
headerName: "Name",
hide: true,
renderCell: RenderCellContent,
},
{
...columnsDefaultProps,
field: "abId",
headerName: "ID",
hide: true,
renderCell: RenderCellContent,
},
{
...columnsDefaultProps,
Expand All @@ -481,12 +480,11 @@ const AntibodiesTable = (props) => {
// },
{
...columnsDefaultProps,
field: "species",
field: "targetSpecies",
headerName: "Target species",
valueGetter: getList,
hide: true,
sortable: false,
renderCell: RenderCellContent,
},
{
...columnsDefaultProps,
Expand Down Expand Up @@ -541,18 +539,16 @@ const AntibodiesTable = (props) => {
field: "cloneId",
headerName: "Clone ID",
hide: true,
renderCell: RenderCellContent,
},
{
...columnsDefaultProps,
field: "sourceOrganism",
headerName: "Host organism",
flex: 1.5,
renderCell: RenderCellContent,
},
{
...columnsDefaultProps,
field: "vendor",
field: "vendorName",
headerName: "Vendor",
flex: 1.5,
renderCell: RenderVendor,
Expand All @@ -562,7 +558,6 @@ const AntibodiesTable = (props) => {
...columnsDefaultProps,
field: "catalogNum",
headerName: "Cat Num",
renderCell: RenderCellContent,
},
{
...columnsDefaultProps,
Expand Down Expand Up @@ -609,6 +604,8 @@ const AntibodiesTable = (props) => {
},
};

const [showColumns, setShowColumns] = useState<GridColumnVisibilityModel>(getColumnsToDisplay(columns));

const NoRowsOverlay = () =>
typeof activeSearch === "string" &&
activeSearch !== "" &&
Expand Down Expand Up @@ -645,6 +642,8 @@ const AntibodiesTable = (props) => {
onSortModelChange={(model) => addSortingColumn(model)}
checkboxSelection
disableSelectionOnClick
columnVisibilityModel={showColumns || {}}
onColumnVisibilityModelChange={(model) => setShowColumns(model)}
getRowHeight={() => "auto"}
loading={!searchedAntibodies || loader}
onFilterModelChange={(model) => addNewFilterColumn(model)}
Expand Down
15 changes: 13 additions & 2 deletions applications/portal/frontend/src/utils/antibody.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import { GridFilterModel } from "@mui/x-data-grid";
import { GridFilterModel, GridColumnVisibilityModel } from "@mui/x-data-grid";
import { Antibody, SearchCriteriaOptions } from "../rest";
import { modelType } from "../constants/constants";


export function getProperCitation(a: Antibody) {
if(!a) {return "ERROR";}
return a.catalogNum && a.vendorName ? `(${a.vendorName} Cat# ${a?.catalogNum?.split(" (")[0]}, RRID:AB_${a.abId})`: "ERROR";
Expand Down Expand Up @@ -88,4 +89,14 @@ export function mapColumnToBackendModel(columnItems, modeltype) {
}
});
return newFilters;
}
}


export const getColumnsToDisplay = (columns) => {
let showcolList: GridColumnVisibilityModel = {};
columns.filter((column) => column?.hide === true).map((column) => {
showcolList[column.field] = false;
});
return showcolList;
}

0 comments on commit c8fd7ec

Please sign in to comment.