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

[DUOS-2757] Increase first column width in study and dataset tables #2400

Merged
merged 3 commits into from
Nov 28, 2023
Merged
Show file tree
Hide file tree
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
58 changes: 44 additions & 14 deletions src/components/CollapsibleTable.js
Original file line number Diff line number Diff line change
Expand Up @@ -164,15 +164,7 @@ const CollapsibleRow = (props) => {
</IconButton>
</StyledTableCell>
{row.data.map((cell, i) => {
return cell?.truncate ? (
<TruncatedTableCell key={i}>
{cell.value}
</TruncatedTableCell>
) : (
<StyledTableCell key={i}>
{cell.value}
</StyledTableCell>
);
return <TableCellRenderer key={i} cell={cell} />;
})}
</TableRow>
{/* subtable */}
Expand Down Expand Up @@ -201,11 +193,9 @@ const CollapsibleRow = (props) => {
checked={isSelected(subRow.id)}
/>
</StyledTableCell>
{subRow.data.map((cell, k) => (
<StyledTableCell key={k}>
{cell.value}
</StyledTableCell>
))}
{subRow.data.map((cell, k) => {
return <SubtableCellRenderer key={k} cell={cell} />;
})}
</TableRow>
))}
</TableBody>
Expand Down Expand Up @@ -268,3 +258,43 @@ export const CollapsibleTable = (props) => {
};

export default CollapsibleTable;

const TableCellRenderer = ({ cell }) => {

if (cell?.truncate && cell?.increaseWidth) {
return <TruncatedTableCell style={{ maxWidth: '30ch' }}>
{cell.value}
</TruncatedTableCell>;
}

if (cell?.truncate) {
return <TruncatedTableCell>
{cell.value}
</TruncatedTableCell>;
}

if (cell?.increaseWidth) {
return <StyledTableCell style={{ width: '37ch' }}>
{cell.value}
</StyledTableCell>;
}

// Default case:
return <StyledTableCell>
{cell.value}
</StyledTableCell>;
};

const SubtableCellRenderer = ({ cell }) => {

if (cell?.increaseWidth) {
return <StyledTableCell style={{ width: '15ch' }}>
{cell.value}
</StyledTableCell>;
}

// Default case:
return <StyledTableCell>
{cell.value}
</StyledTableCell>;
};
2 changes: 2 additions & 0 deletions src/components/data_search/DatasetSearchTable.js
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ export const DatasetSearchTable = (props) => {
{
value: entry[0].study.studyName,
truncate: true,
increaseWidth: true
},
{
value: entry[0].study.description,
Expand Down Expand Up @@ -152,6 +153,7 @@ export const DatasetSearchTable = (props) => {
data: [
{
value: dataset.datasetIdentifier,
increaseWidth: true
},
{
value: dataset.dataUse?.primary.map((use) => use.code).join(', ')
Expand Down
Loading