CEC-6051 - Select All for fleet bulk actions

This commit is contained in:
padamsen_fisker
2024-05-21 13:58:10 -04:00
parent 207b4c776d
commit 80a338c7b4
3 changed files with 16 additions and 23 deletions

View File

@@ -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" }}
/>