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

[DT-788] Footer: Apply for Access to selected Studies and Datasets #2723

Merged
merged 9 commits into from
Nov 14, 2024
Merged
39 changes: 39 additions & 0 deletions src/components/data_search/DatasetSearchFooter.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
import * as _ from 'lodash';
import {Button} from '@mui/material';
import * as React from 'react';
import {Dataset} from 'src/types/model';

interface DatasetSearchFooterProps {
selectedDatasets: number[];
datasets: Dataset[];
onClick: () => void;
}
export const DatasetSearchFooter = (props: DatasetSearchFooterProps) => {
const { selectedDatasets, datasets, onClick } = props;
const selectedStudies = _.uniq(
_.filter(datasets, dataset => selectedDatasets.includes(dataset.datasetId))
.map(dataset => dataset.study.studyId));
return <div style={{
position: 'fixed',
bottom: 0,
zIndex: 999,
width: '100vw',
height: 60,
display: 'flex',
justifyContent: 'flex-end',
backgroundColor: 'white',
border: '1px solid #DEDEDE',
alignItems: 'center'
}}>
{selectedDatasets.length > 1 && selectedStudies.length > 1 && (<div style={{paddingRight: 15}}> {selectedDatasets.length} Datasets selected from {selectedStudies.length} Studies </div>)}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about something like:

// at top of component
const datasetText = selectedDatasets.length > 1 ? 'datasets' : 'dataset';
const studyText = selectedStudies.length > 1 ? 'studies' : 'study';

{selectedDatasets.length > 0 && (<div>{selectedDatasets.length} {datasetText} selected from {selectedStudies.length} {studyText}</div>)}

{selectedDatasets.length > 1 && selectedStudies.length === 1 && (<div style={{paddingRight: 15}}> {selectedDatasets.length} Datasets selected from 1 Study </div>)}
{selectedDatasets.length === 1 && (<div style={{paddingRight: 15}}> 1 Dataset selected from 1 Study </div>)}
<Button
variant='contained'
onClick={onClick}
sx={{fontSize: 14, height: 35, marginRight: 5}}
>
Apply for Access
</Button>
</div>;
};
15 changes: 5 additions & 10 deletions src/components/data_search/DatasetSearchTable.jsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import Tab from '@mui/material/Tab';
import Tabs from '@mui/material/Tabs';
import useOnMount from '@mui/utils/useOnMount'
import useOnMount from '@mui/utils/useOnMount';
import * as React from 'react';
import { Box, Button } from '@mui/material';
import { useEffect, useState } from 'react';
Expand All @@ -15,6 +15,7 @@ import DatasetFilterList from './DatasetFilterList';
import { Notifications } from '../../libs/utils';
import { Styles } from '../../libs/theme';
import * as _ from 'lodash';
import {DatasetSearchFooter} from './DatasetSearchFooter';

const styles = {
subTab: {
Expand Down Expand Up @@ -140,7 +141,7 @@ export const DatasetSearchTable = (props) => {
'dac.dacName': term
}
}))
}
}
});

if (filterTerms.length > 0) {
Expand Down Expand Up @@ -288,14 +289,8 @@ export const DatasetSearchTable = (props) => {
})()}
</Box>
</Box>
<Box sx={{ display: 'flex', flexDirection: 'row', justifyContent: 'flex-end', padding: '2em 4em' }}>
{
!isEmpty(datasets) &&
<Button variant='contained' onClick={applyForAccess} sx={{ transform: 'scale(1.5)' }} >
Apply for Access
</Button>
}
</Box>
<Box sx={{padding: '1em'}}/>
{!isEmpty(selected) && <DatasetSearchFooter selectedDatasets={selected} datasets={datasets} onClick={applyForAccess}/>}
</Box>
</>
);
Expand Down
Loading