mirror of
https://github.com/collinbarrett/FilterLists.git
synced 2026-03-11 09:04:27 +00:00
use newer TS table def syntax
This commit is contained in:
parent
025e75739d
commit
0767831573
4 changed files with 10 additions and 37 deletions
|
|
@ -1,6 +1,6 @@
|
|||
import { Table } from 'antd';
|
||||
import * as React from "react";
|
||||
import { columnProps } from './columnProps';
|
||||
import { nameof } from '../../utils';
|
||||
import { List } from './List';
|
||||
|
||||
interface State {
|
||||
|
|
@ -32,14 +32,10 @@ export class AllListsTable extends React.Component<{}, State> {
|
|||
|
||||
render() {
|
||||
return (
|
||||
<Table
|
||||
size="small"
|
||||
scroll={{ x: 1500 }}
|
||||
columns={columnProps}
|
||||
rowKey={record => record.id.toString()}
|
||||
dataSource={this.state.data}
|
||||
loading={this.state.loading}
|
||||
/>
|
||||
<Table<List> dataSource={this.state.data} rowKey={record => record.id.toString()} loading={this.state.loading}>
|
||||
<Table.Column<List> title="Name" dataIndex={nameof<List>("name")} />
|
||||
<Table.Column<List> title="Description" dataIndex={nameof<List>("description")} />
|
||||
</Table>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
@ -1,28 +0,0 @@
|
|||
import { ColumnProps } from "antd/lib/table";
|
||||
import { List } from './List';
|
||||
|
||||
const nameof = <T>(name: Extract<keyof T, string>): string => name;
|
||||
|
||||
export const columnProps: ColumnProps<List>[] = [
|
||||
{
|
||||
title: 'Name',
|
||||
dataIndex: nameof<List>("name"),
|
||||
width: 200,
|
||||
fixed: 'left'
|
||||
},
|
||||
{
|
||||
title: 'Description',
|
||||
dataIndex: nameof<List>("description"),
|
||||
width: 400
|
||||
},
|
||||
{
|
||||
title: 'Languages',
|
||||
dataIndex: nameof<List>("languageIds"),
|
||||
width: 400
|
||||
},
|
||||
{
|
||||
title: 'Tags',
|
||||
dataIndex: nameof<List>("tagIds"),
|
||||
width: 400
|
||||
}
|
||||
];
|
||||
3
src/FilterLists.Web.V2/src/utils/index.ts
Normal file
3
src/FilterLists.Web.V2/src/utils/index.ts
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
import { nameof } from './nameof'
|
||||
|
||||
export { nameof }
|
||||
2
src/FilterLists.Web.V2/src/utils/nameof.ts
Normal file
2
src/FilterLists.Web.V2/src/utils/nameof.ts
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
//https://stackoverflow.com/a/50470026/2343739
|
||||
export const nameof = <T>(name: Extract<keyof T, string>): string => name;
|
||||
Loading…
Reference in a new issue