From 0767831573d1c95f507f3d49197e8a2a265b0ef5 Mon Sep 17 00:00:00 2001 From: "Collin M. Barrett" Date: Sun, 4 Aug 2019 19:30:53 -0500 Subject: [PATCH] use newer TS table def syntax --- .../modules/allListsTable/AllListsTable.tsx | 14 ++++------ .../src/modules/allListsTable/columnProps.ts | 28 ------------------- src/FilterLists.Web.V2/src/utils/index.ts | 3 ++ src/FilterLists.Web.V2/src/utils/nameof.ts | 2 ++ 4 files changed, 10 insertions(+), 37 deletions(-) delete mode 100644 src/FilterLists.Web.V2/src/modules/allListsTable/columnProps.ts create mode 100644 src/FilterLists.Web.V2/src/utils/index.ts create mode 100644 src/FilterLists.Web.V2/src/utils/nameof.ts diff --git a/src/FilterLists.Web.V2/src/modules/allListsTable/AllListsTable.tsx b/src/FilterLists.Web.V2/src/modules/allListsTable/AllListsTable.tsx index 850d2143b..311a4c9a5 100644 --- a/src/FilterLists.Web.V2/src/modules/allListsTable/AllListsTable.tsx +++ b/src/FilterLists.Web.V2/src/modules/allListsTable/AllListsTable.tsx @@ -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 ( - record.id.toString()} - dataSource={this.state.data} - loading={this.state.loading} - /> + dataSource={this.state.data} rowKey={record => record.id.toString()} loading={this.state.loading}> + title="Name" dataIndex={nameof("name")} /> + title="Description" dataIndex={nameof("description")} /> +
); } } \ No newline at end of file diff --git a/src/FilterLists.Web.V2/src/modules/allListsTable/columnProps.ts b/src/FilterLists.Web.V2/src/modules/allListsTable/columnProps.ts deleted file mode 100644 index 9c5b34197..000000000 --- a/src/FilterLists.Web.V2/src/modules/allListsTable/columnProps.ts +++ /dev/null @@ -1,28 +0,0 @@ -import { ColumnProps } from "antd/lib/table"; -import { List } from './List'; - -const nameof = (name: Extract): string => name; - -export const columnProps: ColumnProps[] = [ - { - title: 'Name', - dataIndex: nameof("name"), - width: 200, - fixed: 'left' - }, - { - title: 'Description', - dataIndex: nameof("description"), - width: 400 - }, - { - title: 'Languages', - dataIndex: nameof("languageIds"), - width: 400 - }, - { - title: 'Tags', - dataIndex: nameof("tagIds"), - width: 400 - } -]; diff --git a/src/FilterLists.Web.V2/src/utils/index.ts b/src/FilterLists.Web.V2/src/utils/index.ts new file mode 100644 index 000000000..47426d11c --- /dev/null +++ b/src/FilterLists.Web.V2/src/utils/index.ts @@ -0,0 +1,3 @@ +import { nameof } from './nameof' + +export { nameof } \ No newline at end of file diff --git a/src/FilterLists.Web.V2/src/utils/nameof.ts b/src/FilterLists.Web.V2/src/utils/nameof.ts new file mode 100644 index 000000000..82c8d92ce --- /dev/null +++ b/src/FilterLists.Web.V2/src/utils/nameof.ts @@ -0,0 +1,2 @@ +//https://stackoverflow.com/a/50470026/2343739 +export const nameof = (name: Extract): string => name; \ No newline at end of file