[arvados-workbench2] updated: 2.6.0-6-g24fc2a5a
git repository hosting
git at public.arvados.org
Tue Apr 25 16:48:26 UTC 2023
Summary of changes:
src/components/data-table/data-table.tsx | 42 +++++++++++---------------------
1 file changed, 14 insertions(+), 28 deletions(-)
via 24fc2a5a701dd4bb6edf503efee992942ea5b667 (commit)
from a60309a6b134ca66fa66a71c489e633a84f52f0f (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
commit 24fc2a5a701dd4bb6edf503efee992942ea5b667
Author: Lisa Knox <lisaknox83 at gmail.com>
Date: Tue Apr 25 12:48:21 2023 -0400
15768: state update on checkbox tick Arvados-DCO-1.1-Signed-off-by: Lisa Knox <lisa.knox at curii.com>
diff --git a/src/components/data-table/data-table.tsx b/src/components/data-table/data-table.tsx
index 2bb48a3c..6a02d7e6 100644
--- a/src/components/data-table/data-table.tsx
+++ b/src/components/data-table/data-table.tsx
@@ -102,23 +102,17 @@ type DataTableProps<T> = DataTableDataProps<T> & WithStyles<CssRules> & DataTabl
export const DataTable = withStyles(styles)(
class Component<T> extends React.Component<DataTableProps<T>> {
- constructor(props) {
- super(props);
- this.state = {
- checkedList: {},
- };
- this.initializeCheckedList = this.initializeCheckedList.bind(this);
- this.handleResourceSelect = this.handleResourceSelect.bind(this);
- }
+ state: DataTableState = {
+ checkedList: {},
+ };
checkBoxColumn: DataColumn<any, any> = {
name: 'checkBoxColumn',
selected: true,
configurable: false,
filters: createTree(),
- render: (uuid) => {
- return <input type='checkbox' name={uuid} color='primary' onChange={() => this.handleResourceSelect(uuid)}></input>;
- },
+ render: (uuid) => <input type='checkbox' name={uuid} color='primary' checked={this.state[uuid] ?? false} onChange={() => this.handleCheck(uuid)}></input>,
};
+
initializeCheckedList = (items: any[]): void => {
const checkedList = this.state;
for (const uuid in checkedList) {
@@ -131,24 +125,20 @@ export const DataTable = withStyles(styles)(
checkedList[uuid] = false;
}
});
- console.log(this.state);
- };
-
- handleResourceSelect = (uuid: string) => {
- const checkedList = this.state;
- if (!checkedList[uuid]) {
- checkedList[uuid] = true;
- } else {
- checkedList[uuid] = false;
- }
- console.log(checkedList);
};
- componentDidUpdate(prevProps: Readonly<DataTableProps<T>>, prevState: Readonly<{}>, snapshot?: any): void {
+ componentDidUpdate(prevProps: Readonly<DataTableProps<T>>): void {
if (prevProps.items !== this.props.items) {
this.initializeCheckedList(this.props.items);
}
}
+
+ handleCheck = async (uuid: string) => {
+ const checkedList = this.state;
+ const newCheckedList = { ...checkedList };
+ newCheckedList[uuid] = !checkedList[uuid];
+ await this.setState(newCheckedList);
+ };
render() {
const { items, classes, working, columns } = this.props;
if (columns[0].name !== this.checkBoxColumn.name) columns.unshift(this.checkBoxColumn);
@@ -158,15 +148,11 @@ export const DataTable = withStyles(styles)(
<div className={classes.content}>
<button
onClick={() => {
- // if (firstBox) this.handleResourceSelect(firstBox?.name);
- if (firstBox) firstBox.click();
- // if (firstBox) firstBox.checked = !firstBox.checked;
- console.log(firstBox);
+ if (firstBox) this.handleCheck(firstBox?.name);
}}
>
TEST
</button>
- {/* <input type='checkbox'></input> */}
<Table>
<TableHead>
<TableRow>{this.mapVisibleColumns(this.renderHeadCell)}</TableRow>
-----------------------------------------------------------------------
hooks/post-receive
--
More information about the arvados-commits
mailing list