mirror of
https://github.com/lrnselfreliance/wrolpi.git
synced 2026-11-19 14:36:22 -05:00
Using placeholder in SortableTable while data is loading.
This commit is contained in:
parent
095634a4ea
commit
12850bdb8b
5 changed files with 33 additions and 35 deletions
|
|
@ -1,7 +1,8 @@
|
|||
import React from "react";
|
||||
import _ from "lodash";
|
||||
import {TableBody, TableHeader, TableHeaderCell, TableRow} from "semantic-ui-react";
|
||||
import {TableBody, TableCell, TableHeader, TableHeaderCell, TableRow} from "semantic-ui-react";
|
||||
import {Table} from "./Theme";
|
||||
import {TextPlaceholder} from "./Placeholder";
|
||||
|
||||
export class SortableTable extends React.Component {
|
||||
constructor(props) {
|
||||
|
|
@ -41,7 +42,7 @@ export class SortableTable extends React.Component {
|
|||
let {direction} = this.state;
|
||||
rowKey = rowKey || 'key';
|
||||
|
||||
const data = this.sortData(this.props['data']);
|
||||
const data = this.props['data'] ? this.sortData(this.props['data']) : null;
|
||||
|
||||
const tableHeader = (spec) => {
|
||||
const {key, text, sortBy, width} = spec;
|
||||
|
|
@ -59,7 +60,11 @@ export class SortableTable extends React.Component {
|
|||
}
|
||||
}
|
||||
|
||||
const rows = data.map(i => <React.Fragment key={i[rowKey]}>{rowFunc(i, this.sortData)}</React.Fragment>);
|
||||
// Use placeholder while data is null.
|
||||
let rows = <TableRow><TableCell colSpan={tableHeaders.length}><TextPlaceholder/></TableCell></TableRow>;
|
||||
if (data !== null) {
|
||||
rows = data.map(i => <React.Fragment key={i[rowKey]}>{rowFunc(i, this.sortData)}</React.Fragment>);
|
||||
}
|
||||
|
||||
return <Table sortable {...this.props.tableProps}>
|
||||
<TableHeader>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue