X-Git-Url: https://git.arvados.org/arvados-workbench2.git/blobdiff_plain/27dd462657b3b7434780de3250d0b2b0a75cea65..0284278f61c66ccd75a6559c815ca299e912665f:/src/components/data-table/data-table.tsx diff --git a/src/components/data-table/data-table.tsx b/src/components/data-table/data-table.tsx index 0d53f331..54c87566 100644 --- a/src/components/data-table/data-table.tsx +++ b/src/components/data-table/data-table.tsx @@ -13,6 +13,8 @@ import { countNodes, getTreeDirty } from 'models/tree'; import { IconType, PendingIcon } from 'components/icon/icon'; import { SvgIconProps } from '@material-ui/core/SvgIcon'; import ArrowDownwardIcon from '@material-ui/icons/ArrowDownward'; +import { Checkbox } from '@material-ui/core'; +import { createTree } from 'models/tree'; export type DataColumns = Array>; @@ -37,7 +39,7 @@ export interface DataTableDataProps { currentRoute?: string; } -type CssRules = 'tableBody' | 'root' | 'content' | 'noItemsInfo' | 'tableCellSelect' | 'tableCell' | 'arrow' | 'arrowButton' | 'tableCellWorkflows' | 'loader'; +type CssRules = 'tableBody' | 'root' | 'content' | 'noItemsInfo' | 'checkBoxCell' | 'tableCell' | 'arrow' | 'arrowButton' | 'tableCellWorkflows' | 'loader'; const styles: StyleRulesCallback = (theme: Theme) => ({ root: { @@ -59,7 +61,8 @@ const styles: StyleRulesCallback = (theme: Theme) => ({ textAlign: 'center', padding: theme.spacing.unit, }, - tableCellSelect: { + checkBoxCell: { + // border: '1px dotted green', padding: '0', }, tableCell: { @@ -86,12 +89,29 @@ const styles: StyleRulesCallback = (theme: Theme) => ({ }, }); +const selectedList = new Set(); + +const handleResourceSelect = (uuid) => { + if (selectedList.has(uuid)) selectedList.delete(uuid); + else selectedList.add(uuid); + console.log(selectedList); +}; + +const checkBoxColumn: DataColumn = { + name: '', + selected: true, + configurable: false, + filters: createTree(), + render: (item) => handleResourceSelect(item)} />, +}; + type DataTableProps = DataTableDataProps & WithStyles; export const DataTable = withStyles(styles)( class Component extends React.Component> { render() { - const { items, classes, working } = this.props; + const { items, classes, working, columns } = this.props; + if (columns[0] !== checkBoxColumn) columns.unshift(checkBoxColumn); return (
@@ -170,7 +190,7 @@ export const DataTable = withStyles(styles)( {this.mapVisibleColumns((column, index) => ( {column.render(item)}