2021-09-07 13:28:20 +02:00
|
|
|
import DataTable from '../DataTable/DataTable';
|
|
|
|
import TableBody from '../DataTable/TableBody';
|
|
|
|
import TableCell from '../DataTable/TableCell';
|
|
|
|
import TableHead from '../DataTable/TableHead';
|
|
|
|
import TableHeadCell from '../DataTable/TableHeadCell';
|
|
|
|
import TableHeadRow from '../DataTable/TableHeadRow';
|
|
|
|
import TableRow from '../DataTable/TableRow';
|
|
|
|
import Page from '../Page';
|
2021-08-26 20:10:31 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @abstract
|
|
|
|
*/
|
|
|
|
export default class ListPage extends Page {
|
|
|
|
columns: Array<{
|
|
|
|
id: string,
|
|
|
|
title: string,
|
|
|
|
type: string | null
|
|
|
|
}>;
|
|
|
|
|
|
|
|
rows: Array<Array<string>> = [];
|
|
|
|
|
|
|
|
view(vnode) {
|
|
|
|
const columns = this.columns.map(
|
2021-09-07 13:28:20 +02:00
|
|
|
(column, index) => (
|
|
|
|
<TableHeadCell key={index}>
|
2021-08-26 20:10:31 +02:00
|
|
|
{column}
|
|
|
|
</TableHeadCell>
|
|
|
|
)
|
|
|
|
);
|
|
|
|
|
2021-09-07 13:28:20 +02:00
|
|
|
const rows = this.rows.length > 0 ? this.rows.map((row, index) => (
|
|
|
|
<TableRow key={index}>
|
|
|
|
{row.map((cell, index_) => <TableCell key={index_}>{cell}</TableCell>)}
|
2021-08-26 20:10:31 +02:00
|
|
|
</TableRow>
|
|
|
|
)) : <TableRow><TableCell colspan={columns.length}>{this.__('Non sono presenti dati')}</TableCell></TableRow>;
|
|
|
|
|
|
|
|
return (
|
|
|
|
<>
|
|
|
|
<h2>{this.title}</h2>
|
|
|
|
<DataTable>
|
|
|
|
<TableHead>
|
|
|
|
<TableHeadRow>
|
|
|
|
{columns}
|
|
|
|
</TableHeadRow>
|
|
|
|
</TableHead>
|
|
|
|
<TableBody>
|
|
|
|
{rows}
|
|
|
|
</TableBody>
|
|
|
|
</DataTable>
|
|
|
|
</>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|