-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add plugin component for outliers table (DHIS2-16356)
- Loading branch information
Showing
2 changed files
with
147 additions
and
34 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
import { | ||
DataTable, | ||
DataTableBody, | ||
DataTableCell, | ||
DataTableColumnHeader, | ||
DataTableHead, | ||
DataTableRow, | ||
} from '@dhis2/ui' | ||
import PropTypes from 'prop-types' | ||
import React from 'react' | ||
|
||
const OutliersTablePlugin = ({ | ||
responses, | ||
// XXX needed? | ||
//legendSets, | ||
//visualization, | ||
style, | ||
//id: renderCounter, | ||
//onToggleContextualMenu, | ||
}) => { | ||
const data = responses[0] | ||
|
||
const renderCellContent = ({ columnIndex, value }) => ( | ||
<DataTableCell key={columnIndex}>{value}</DataTableCell> | ||
) | ||
|
||
return ( | ||
// <OutliersTableTable | ||
// visualization={visualization} | ||
// data={responses[0].response} | ||
// legendSets={legendSets} | ||
// renderCounter={renderCounter} | ||
// onToggleContextualMenu={onToggleContextualMenu} | ||
// /> | ||
// </div> | ||
<div style={style}> | ||
<DataTable> | ||
<DataTableHead> | ||
<DataTableRow> | ||
{data.headers.map((header) => ( | ||
<DataTableColumnHeader | ||
fixed | ||
top="0" | ||
key={header.name} | ||
name={header.name} | ||
//className={cx( | ||
// styles.headerCell, | ||
// fontSizeClass, | ||
// sizeClass, | ||
// 'bordered' | ||
//)} | ||
dataTest={'table-header'} | ||
> | ||
{header.name} | ||
</DataTableColumnHeader> | ||
))} | ||
</DataTableRow> | ||
</DataTableHead> | ||
{/* https://jira.dhis2.org/browse/LIBS-278 */} | ||
<DataTableBody dataTest={'table-body'}> | ||
{data.rows.map((row, rowIndex) => ( | ||
<DataTableRow key={rowIndex} dataTest={'table-row'}> | ||
{row.map((value, columnIndex) => | ||
renderCellContent({ | ||
columnIndex, | ||
value, | ||
}) | ||
)} | ||
</DataTableRow> | ||
))} | ||
</DataTableBody> | ||
</DataTable> | ||
</div> | ||
) | ||
} | ||
|
||
OutliersTablePlugin.defaultProps = { | ||
style: {}, | ||
} | ||
|
||
OutliersTablePlugin.propTypes = { | ||
// legendSets: PropTypes.arrayOf(PropTypes.object).isRequired, | ||
responses: PropTypes.arrayOf(PropTypes.object).isRequired, | ||
// visualization: PropTypes.object.isRequired, | ||
// id: PropTypes.number, | ||
style: PropTypes.object, | ||
// onToggleContextualMenu: PropTypes.func, | ||
} | ||
|
||
export default OutliersTablePlugin |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters