CEC-6051 - Select All for fleet bulk actions
This commit is contained in:
@@ -6,9 +6,10 @@ import {
|
||||
TableSortLabel
|
||||
} from "@material-ui/core";
|
||||
import PropTypes from "prop-types";
|
||||
import React from "react";
|
||||
import React, { useState } from "react";
|
||||
|
||||
const HeaderSortable = (props) => {
|
||||
const [selectAll, setSelectAll] = useState(false);
|
||||
const {
|
||||
classes,
|
||||
order,
|
||||
@@ -19,6 +20,7 @@ const HeaderSortable = (props) => {
|
||||
onSelectAll,
|
||||
selectCount,
|
||||
rowCount,
|
||||
selectAllForAllPages,
|
||||
} = props;
|
||||
|
||||
const sortHandler = (property) => (event) => {
|
||||
@@ -27,6 +29,7 @@ const HeaderSortable = (props) => {
|
||||
};
|
||||
|
||||
const selectAllHandler = (event) => {
|
||||
setSelectAll(selectAll => !selectAll);
|
||||
if (!onSelectAll) return;
|
||||
onSelectAll(event);
|
||||
};
|
||||
@@ -71,8 +74,8 @@ const HeaderSortable = (props) => {
|
||||
{multiSelect && (
|
||||
<TableCell padding="checkbox">
|
||||
<Checkbox
|
||||
indeterminate={selectCount > 0 && selectCount < rowCount}
|
||||
checked={rowCount > 0 && selectCount === rowCount}
|
||||
indeterminate={!selectAllForAllPages && selectCount > 0 && selectCount < rowCount}
|
||||
checked={selectAllForAllPages ? selectAll : rowCount > 0 && selectCount === rowCount}
|
||||
onChange={selectAllHandler}
|
||||
inputProps={{ "aria-label": "select all items" }}
|
||||
/>
|
||||
|
||||
Reference in New Issue
Block a user