Skip to content

Commit

Permalink
Merge pull request #101 from dhis2/DHIS2-11840
Browse files Browse the repository at this point in the history
Closes DHIS2-11840
  • Loading branch information
Mohammer5 authored Sep 30, 2021
2 parents 02a56e8 + 8fa7b74 commit 60c4665
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 13 deletions.
41 changes: 30 additions & 11 deletions src/data-workspace/display/table.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,29 +12,43 @@ import styles from './table.module.css'

// Needs to have the same width as the table, so can't use the one from
// @dhis2/ui
const DataTableToolbar = ({ children }) => (
const DataTableToolbar = ({ children, columns }) => (
<tr>
<th className={styles.titleCell} colSpan="2">
<th className={styles.titleCell} colSpan={columns.toString()}>
{children}
</th>
</tr>
)

DataTableToolbar.propTypes = {
children: PropTypes.any.isRequired,
columns: PropTypes.number.isRequired,
}

const Table = ({ title, columns, rows }) => (
<>
<DataTable className={styles.dataTable}>
<TableHead>
<DataTableToolbar>{title}</DataTableToolbar>
<DataTableToolbar columns={columns.length}>
{title}
</DataTableToolbar>
<DataTableRow>
{columns.map(column => (
<DataTableColumnHeader key={column}>
{column}
</DataTableColumnHeader>
))}
<DataTableColumnHeader className={styles.cell}>
<span className={styles.labelCellContent}>
{columns[0]}
</span>
</DataTableColumnHeader>

{columns.slice(1).map(column => {
return (
<DataTableColumnHeader
key={column}
className={styles.cell}
>
{column}
</DataTableColumnHeader>
)
})}
</DataTableRow>
</TableHead>
<TableBody>
Expand All @@ -43,12 +57,17 @@ const Table = ({ title, columns, rows }) => (

return (
<DataTableRow key={index}>
<DataTableCell className={styles.labelCell}>
{firstCell}
<DataTableCell className={styles.cell}>
<span className={styles.labelCellContent}>
{firstCell}
</span>
</DataTableCell>

{cells.map((value, index) => (
<DataTableCell key={index}>
<DataTableCell
key={index}
className={styles.cell}
>
{value}
</DataTableCell>
))}
Expand Down
10 changes: 9 additions & 1 deletion src/data-workspace/display/table.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,14 @@ table.dataTable {
width: auto;
}

td.labelCell {
th.cell, td.cell {
height: auto;
min-height: 45px;
padding-top: 14px;
padding-bottom: 14px;
}

.labelCellContent, .labelCellContent {
display: block;
max-width: 480px;
}
2 changes: 1 addition & 1 deletion src/selection-context/use-selection-context.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ describe('useSelectionContext', () => {
})

describe('functions returned from the hook update the state and url', () => {
it.only('setOpenedSelect', () => {
it('setOpenedSelect', () => {
const mock = jest.fn()
pushStateToHistory.mockImplementation(mock)

Expand Down

0 comments on commit 60c4665

Please sign in to comment.