namirasoft-account-react 1.3.62 → 1.3.63
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/layouts/NSALayout.js +6 -7
- package/dist/layouts/NSALayout.js.map +1 -1
- package/dist/layouts/NSASectionList.d.ts +14 -4
- package/dist/layouts/NSASectionList.js +52 -42
- package/dist/layouts/NSASectionList.js.map +1 -1
- package/package.json +1 -1
- package/src/layouts/NSALayout.tsx +6 -9
- package/src/layouts/NSASectionList.tsx +77 -70
|
@@ -13,7 +13,7 @@ import { NSLayout } from 'namirasoft-site-react';
|
|
|
13
13
|
import { NSASectionList } from './NSASectionList';
|
|
14
14
|
import { NSASectionEdit, onApply as NSASectionEdit_onApply } from './NSASectionEdit';
|
|
15
15
|
import { NSASectionView } from './NSASectionView';
|
|
16
|
-
import { useState } from 'react';
|
|
16
|
+
import { useRef, useState } from 'react';
|
|
17
17
|
import { Actions } from './Actions';
|
|
18
18
|
import { useParams } from 'react-router-dom';
|
|
19
19
|
import { NamingConvention } from 'namirasoft-core';
|
|
@@ -28,6 +28,7 @@ export function NSALayout(props) {
|
|
|
28
28
|
const onNotiffication = () => {
|
|
29
29
|
console.log("clicked");
|
|
30
30
|
};
|
|
31
|
+
const Section_List = useRef(null);
|
|
31
32
|
const [state, setState] = useState({ showDeleteModal: false });
|
|
32
33
|
const hideDeleteModal = () => { setState(prevState => (Object.assign(Object.assign({}, prevState), { showDeleteModal: false }))); };
|
|
33
34
|
const showDeleteModal = () => { setState(prevState => (Object.assign(Object.assign({}, prevState), { showDeleteModal: true }))); };
|
|
@@ -48,15 +49,13 @@ export function NSALayout(props) {
|
|
|
48
49
|
action.menus[name_apply] = [];
|
|
49
50
|
action.menus[name_actions] = [];
|
|
50
51
|
let getIDs = null;
|
|
51
|
-
if ((_a = props.pages) === null || _a === void 0 ? void 0 : _a.list)
|
|
52
|
-
getIDs = () =>
|
|
53
|
-
}
|
|
52
|
+
if ((_a = props.pages) === null || _a === void 0 ? void 0 : _a.list)
|
|
53
|
+
getIDs = () => { var _a, _b; return (_b = (_a = Section_List.current) === null || _a === void 0 ? void 0 : _a.getSelectedIDs()) !== null && _b !== void 0 ? _b : []; };
|
|
54
54
|
if ((_b = props.pages) === null || _b === void 0 ? void 0 : _b.edit) {
|
|
55
55
|
let { id } = useParams();
|
|
56
56
|
getIDs = () => [id].filter(id => id);
|
|
57
|
-
if (!action.title)
|
|
57
|
+
if (!action.title)
|
|
58
58
|
action.title = (props.pages.edit.isEdit ? "Edit" : "New") + " " + name;
|
|
59
|
-
}
|
|
60
59
|
if ((_d = (_c = props.pages.edit.ui.action) === null || _c === void 0 ? void 0 : _c.menus.apply) !== null && _d !== void 0 ? _d : true)
|
|
61
60
|
action.menus[name_apply].push(Actions.apply(() => {
|
|
62
61
|
var _a, _b;
|
|
@@ -82,7 +81,7 @@ export function NSALayout(props) {
|
|
|
82
81
|
}
|
|
83
82
|
let content;
|
|
84
83
|
if ((_w = props.pages) === null || _w === void 0 ? void 0 : _w.list)
|
|
85
|
-
content = _jsx(NSASectionList, Object.assign({}, props.pages.list, { entity: props.pages.entity, children: props.children }));
|
|
84
|
+
content = _jsx(NSASectionList, Object.assign({ ref: Section_List }, props.pages.list, { entity: props.pages.entity, children: props.children }));
|
|
86
85
|
else if ((_x = props.pages) === null || _x === void 0 ? void 0 : _x.edit)
|
|
87
86
|
content = _jsx(NSASectionEdit, Object.assign({}, props.pages.edit, { entity: props.pages.entity, children: props.children }));
|
|
88
87
|
else if ((_y = props.pages) === null || _y === void 0 ? void 0 : _y.view)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NSALayout.js","sourceRoot":"","sources":["../../src/layouts/NSALayout.tsx"],"names":[],"mappings":";;;;;;;;;;AAAA,OAAO,EAA4G,WAAW,EAAE,OAAO,EAAE,MAAM,uBAAuB,CAAC;AACvK,OAAO,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AACjD,OAAO,EAAE,c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A4B,CAAC,CAAC;yCAC9D;;4CAGA,MAAM,IAAI,KAAK,CAAC,yCAAyC,CAAC,CAAC;qCAC5D;6BAEF;4BAAC,OAAO,KAAU,EACnB;gCACC,KAAK,CAAC,QAAQ,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;6BAC9B;wBACF,CAAC,CAAA,GAAI,GAAI,EACT,OAAO,IACH,IACI,CACX,CAAC;AACH,CAAC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ReactNode } from "react";
|
|
1
|
+
import { Component, ReactNode } from "react";
|
|
2
2
|
import { IEntityInfo } from "../IEntityInfo";
|
|
3
3
|
export interface NSASectionListProps {
|
|
4
4
|
ui: {
|
|
@@ -25,9 +25,19 @@ export interface NSASectionListState {
|
|
|
25
25
|
totalItems: number;
|
|
26
26
|
selected: string[];
|
|
27
27
|
}
|
|
28
|
-
export declare
|
|
28
|
+
export declare class NSASectionList<EntityType extends {
|
|
29
29
|
id: string;
|
|
30
|
-
}, EntityTypeInput>
|
|
30
|
+
}, EntityTypeInput = EntityType> extends Component<NSASectionListProps & {
|
|
31
31
|
entity: IEntityInfo<EntityType, EntityTypeInput>;
|
|
32
32
|
children: ReactNode;
|
|
33
|
-
}
|
|
33
|
+
}, NSASectionListState> {
|
|
34
|
+
private Table;
|
|
35
|
+
constructor(props: NSASectionListProps & {
|
|
36
|
+
entity: IEntityInfo<EntityType, EntityTypeInput>;
|
|
37
|
+
children: ReactNode;
|
|
38
|
+
});
|
|
39
|
+
reload(): void;
|
|
40
|
+
getSelectedIDs(): string[];
|
|
41
|
+
componentDidMount(): void;
|
|
42
|
+
render(): import("react/jsx-runtime").JSX.Element;
|
|
43
|
+
}
|
|
@@ -1,48 +1,58 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { NSLine, NSSection, NSSpace, NSSpaceSizeType, NSTabPage, NSTable } from "namirasoft-site-react";
|
|
3
|
-
import {
|
|
4
|
-
export
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
props.entity.server.list(null, state.page.current, state.page.size).then(response => {
|
|
3
|
+
import { Component, createRef } from "react";
|
|
4
|
+
export class NSASectionList extends Component {
|
|
5
|
+
constructor(props) {
|
|
6
|
+
super(props);
|
|
7
|
+
this.Table = createRef();
|
|
8
|
+
this.state = { page: { current: 1, size: 25 }, totalItems: 0, selected: [] };
|
|
9
|
+
this.reload = this.reload.bind(this);
|
|
10
|
+
this.getSelectedIDs = this.getSelectedIDs.bind(this);
|
|
11
|
+
}
|
|
12
|
+
reload() {
|
|
13
|
+
this.props.entity.server.list(null, this.state.page.current, this.state.page.size).then(response => {
|
|
15
14
|
var _a;
|
|
16
|
-
(_a =
|
|
17
|
-
setState(prevState => { var _a; return (Object.assign(Object.assign({}, prevState), { totalItems: (_a = response.count) !== null && _a !== void 0 ? _a : 0 })); });
|
|
15
|
+
(_a = this.Table.current) === null || _a === void 0 ? void 0 : _a.setRows(response.rows);
|
|
16
|
+
this.setState(prevState => { var _a; return (Object.assign(Object.assign({}, prevState), { totalItems: (_a = response.count) !== null && _a !== void 0 ? _a : 0 })); });
|
|
18
17
|
}).catch(() => { });
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
return
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
return
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
18
|
+
}
|
|
19
|
+
getSelectedIDs() {
|
|
20
|
+
return this.state.selected;
|
|
21
|
+
}
|
|
22
|
+
componentDidMount() {
|
|
23
|
+
this.reload();
|
|
24
|
+
}
|
|
25
|
+
render() {
|
|
26
|
+
const getColumns = () => {
|
|
27
|
+
return Object.assign({ selected: "" }, this.props.ui.getColumns());
|
|
28
|
+
};
|
|
29
|
+
const getRowKey = (row, _) => {
|
|
30
|
+
return row.id.toString();
|
|
31
|
+
};
|
|
32
|
+
const getColumnAttributes = () => {
|
|
33
|
+
return {};
|
|
34
|
+
};
|
|
35
|
+
const getCell = (row, column) => {
|
|
36
|
+
if (column === "selected")
|
|
37
|
+
return _jsx("input", { id: `checkbox_device_${row.id}`, type: "checkbox", defaultValue: this.state.selected.includes(row.id) + "", onVolumeChange: (e) => {
|
|
38
|
+
let selected = this.state.selected;
|
|
39
|
+
if (e.currentTarget.checked)
|
|
40
|
+
selected.push(row.id);
|
|
41
|
+
else
|
|
42
|
+
selected = selected.filter(x => x != row.id);
|
|
43
|
+
this.setState(prevState => (Object.assign(Object.assign({}, prevState), { selected })));
|
|
44
|
+
} });
|
|
45
|
+
return row[column];
|
|
46
|
+
};
|
|
47
|
+
let content1 = () => _jsx("p", { children: "Content for Tab" });
|
|
48
|
+
let content2 = () => _jsx("p", { children: "Content for Tab" });
|
|
49
|
+
let content3 = () => _jsx("p", { children: "Content for Tab" });
|
|
50
|
+
const tabs = [
|
|
51
|
+
{ title: 'Information', getContent: content1 },
|
|
52
|
+
{ title: 'Price History', getContent: content2 },
|
|
53
|
+
{ title: 'Price Estimator', getContent: content3 }
|
|
54
|
+
];
|
|
55
|
+
return (_jsxs(NSSection, { center_items: false, children: [_jsx(NSTable, { ref: this.Table, columns: getColumns(), getRowKey: getRowKey, getColumnAttributes: getColumnAttributes, getCell: getCell, pageSize: this.state.page.size, totalItems: this.state.totalItems, reload: this.reload }), _jsx(NSSpace, { size: NSSpaceSizeType.NORMAL }), _jsx(NSLine, {}), _jsx(NSSpace, { size: NSSpaceSizeType.NORMAL }), _jsx(NSTabPage, { tabs: tabs })] }));
|
|
56
|
+
}
|
|
47
57
|
}
|
|
48
58
|
//# sourceMappingURL=NSASectionList.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NSASectionList.js","sourceRoot":"","sources":["../../src/layouts/NSASectionList.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,OAAO,EAAE,eAAe,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,uBAAuB,CAAC;AACxG,OAAO,
|
|
1
|
+
{"version":3,"file":"NSASectionList.js","sourceRoot":"","sources":["../../src/layouts/NSASectionList.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,OAAO,EAAE,eAAe,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,uBAAuB,CAAC;AACxG,OAAO,EAAE,SAAS,EAAa,SAAS,EAAE,MAAM,OAAO,CAAC;AA8BxD,MAAM,OAAO,cAAgF,SAAQ,SAA+H;IAGnO,YAAY,KAAsG;QAEjH,KAAK,CAAC,KAAK,CAAC,CAAC;QAHN,UAAK,GAAG,SAAS,EAAuB,CAAC;QAIhD,IAAI,CAAC,KAAK,GAAG,EAAE,IAAI,EAAE,EAAE,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,EAAE,EAAE,EAAE,UAAU,EAAE,CAAC,EAAE,QAAQ,EAAE,EAAE,EAAE,CAAC;QAC7E,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QACrC,IAAI,CAAC,cAAc,GAAG,IAAI,CAAC,cAAc,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IACtD,CAAC;IACD,MAAM;QAEL,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,OAAO,EAAE,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC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O,IAAC,IAAI,EAAE,eAAe,CAAC,MAAM,GAAY,EACjD,KAAC,MAAM,KAAU,EACjB,KAAC,OAAO,IAAC,IAAI,EAAE,eAAe,CAAC,MAAM,GAAY,EACjD,KAAC,SAAS,IAAC,IAAI,EAAE,IAAI,GAAI,IACd,CACZ,CAAC;IACH,CAAC;CACD"}
|
package/package.json
CHANGED
|
@@ -4,7 +4,7 @@ import { NSASectionList, NSASectionListProps } from './NSASectionList';
|
|
|
4
4
|
import { NSASectionEdit, NSASectionEditProps, onApply as NSASectionEdit_onApply } from './NSASectionEdit';
|
|
5
5
|
import { NSASectionView, NSASectionViewProps } from './NSASectionView';
|
|
6
6
|
import { IHeaderProps } from 'namirasoft-site-react';
|
|
7
|
-
import { ReactNode, useState } from 'react';
|
|
7
|
+
import { ReactNode, useRef, useState } from 'react';
|
|
8
8
|
import { Actions } from './Actions';
|
|
9
9
|
import { INSARouterProps } from '../INSARouterProps';
|
|
10
10
|
import { useParams } from 'react-router-dom';
|
|
@@ -63,6 +63,7 @@ export function NSALayout<EntityType extends { id: string }, EntityTypeInput = E
|
|
|
63
63
|
console.log("clicked")
|
|
64
64
|
}
|
|
65
65
|
|
|
66
|
+
const Section_List = useRef<NSASectionList<EntityType, EntityTypeInput>>(null);
|
|
66
67
|
const [state, setState] = useState<NSALayoutState>({ showDeleteModal: false });
|
|
67
68
|
const hideDeleteModal = () => { setState(prevState => ({ ...prevState, showDeleteModal: false })); };
|
|
68
69
|
const showDeleteModal = () => { setState(prevState => ({ ...prevState, showDeleteModal: true })); };
|
|
@@ -90,10 +91,7 @@ export function NSALayout<EntityType extends { id: string }, EntityTypeInput = E
|
|
|
90
91
|
let getIDs: (() => string[]) | null = null;
|
|
91
92
|
|
|
92
93
|
if (props.pages?.list)
|
|
93
|
-
|
|
94
|
-
// todo
|
|
95
|
-
getIDs = () => [].filter(id => id) as string[];
|
|
96
|
-
}
|
|
94
|
+
getIDs = () => { return Section_List.current?.getSelectedIDs() ?? []; };
|
|
97
95
|
|
|
98
96
|
if (props.pages?.edit)
|
|
99
97
|
{
|
|
@@ -101,9 +99,7 @@ export function NSALayout<EntityType extends { id: string }, EntityTypeInput = E
|
|
|
101
99
|
getIDs = () => [id].filter(id => id) as string[];
|
|
102
100
|
|
|
103
101
|
if (!action.title)
|
|
104
|
-
{
|
|
105
102
|
action.title = (props.pages.edit.isEdit ? "Edit" : "New") + " " + name;
|
|
106
|
-
}
|
|
107
103
|
|
|
108
104
|
// Menu
|
|
109
105
|
if (props.pages.edit.ui.action?.menus.apply ?? true)
|
|
@@ -116,7 +112,6 @@ export function NSALayout<EntityType extends { id: string }, EntityTypeInput = E
|
|
|
116
112
|
|
|
117
113
|
if (props.pages?.view)
|
|
118
114
|
{
|
|
119
|
-
// todo
|
|
120
115
|
getIDs = () => [].filter(id => id) as string[];
|
|
121
116
|
}
|
|
122
117
|
|
|
@@ -137,7 +132,9 @@ export function NSALayout<EntityType extends { id: string }, EntityTypeInput = E
|
|
|
137
132
|
|
|
138
133
|
let content;
|
|
139
134
|
if (props.pages?.list)
|
|
140
|
-
content = <NSASectionList<EntityType, EntityTypeInput> {...props.pages.list} entity={props.pages.entity}>
|
|
135
|
+
content = <NSASectionList<EntityType, EntityTypeInput> ref={Section_List} {...props.pages.list} entity={props.pages.entity}>
|
|
136
|
+
{props.children}
|
|
137
|
+
</NSASectionList>;
|
|
141
138
|
else if (props.pages?.edit)
|
|
142
139
|
content = <NSASectionEdit<EntityType, EntityTypeInput> {...props.pages.edit} entity={props.pages.entity}>{props.children}</NSASectionEdit>;
|
|
143
140
|
else if (props.pages?.view)
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { NSLine, NSSection, NSSpace, NSSpaceSizeType, NSTabPage, NSTable } from "namirasoft-site-react";
|
|
2
|
-
import {
|
|
2
|
+
import { Component, ReactNode, createRef } from "react";
|
|
3
3
|
import { IEntityInfo } from "../IEntityInfo";
|
|
4
4
|
|
|
5
5
|
export interface NSASectionListProps
|
|
@@ -29,83 +29,90 @@ export interface NSASectionListState
|
|
|
29
29
|
selected: string[];
|
|
30
30
|
}
|
|
31
31
|
|
|
32
|
-
export
|
|
32
|
+
export class NSASectionList<EntityType extends { id: string }, EntityTypeInput = EntityType> extends Component<NSASectionListProps & { entity: IEntityInfo<EntityType, EntityTypeInput>, children: ReactNode }, NSASectionListState>
|
|
33
33
|
{
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
const [state, setState] = useState<NSASectionListState>({ page: { current: 1, size: 25 }, totalItems: 0, selected: [] });
|
|
37
|
-
|
|
38
|
-
useEffect(() =>
|
|
39
|
-
{
|
|
40
|
-
reload();
|
|
41
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
42
|
-
}, []);
|
|
43
|
-
|
|
44
|
-
const getColumns = (): { [key: string]: string } =>
|
|
34
|
+
private Table = createRef<NSTable<EntityType>>();
|
|
35
|
+
constructor(props: NSASectionListProps & { entity: IEntityInfo<EntityType, EntityTypeInput>, children: ReactNode })
|
|
45
36
|
{
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
const reload = (): void =>
|
|
37
|
+
super(props);
|
|
38
|
+
this.state = { page: { current: 1, size: 25 }, totalItems: 0, selected: [] };
|
|
39
|
+
this.reload = this.reload.bind(this);
|
|
40
|
+
this.getSelectedIDs = this.getSelectedIDs.bind(this);
|
|
41
|
+
}
|
|
42
|
+
reload(): void
|
|
53
43
|
{
|
|
54
|
-
props.entity.server.list(null, state.page.current, state.page.size).then(response =>
|
|
44
|
+
this.props.entity.server.list(null, this.state.page.current, this.state.page.size).then(response =>
|
|
55
45
|
{
|
|
56
|
-
|
|
57
|
-
setState(prevState => ({ ...prevState, totalItems: response.count ?? 0 }));
|
|
46
|
+
this.Table.current?.setRows(response.rows);
|
|
47
|
+
this.setState(prevState => ({ ...prevState, totalItems: response.count ?? 0 }));
|
|
58
48
|
}).catch(() => { });
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
const getRowKey = (row: EntityType, _: number): string =>
|
|
49
|
+
}
|
|
50
|
+
getSelectedIDs(): string[]
|
|
62
51
|
{
|
|
63
|
-
return
|
|
64
|
-
}
|
|
65
|
-
|
|
52
|
+
return this.state.selected;
|
|
53
|
+
}
|
|
54
|
+
override componentDidMount()
|
|
66
55
|
{
|
|
67
|
-
|
|
68
|
-
}
|
|
69
|
-
|
|
56
|
+
this.reload();
|
|
57
|
+
}
|
|
58
|
+
override render()
|
|
70
59
|
{
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
{
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
60
|
+
const getColumns = (): { [key: string]: string } =>
|
|
61
|
+
{
|
|
62
|
+
return {
|
|
63
|
+
selected: "",
|
|
64
|
+
...this.props.ui.getColumns()
|
|
65
|
+
};
|
|
66
|
+
};
|
|
67
|
+
const getRowKey = (row: EntityType, _: number): string =>
|
|
68
|
+
{
|
|
69
|
+
return row.id.toString();
|
|
70
|
+
};
|
|
71
|
+
const getColumnAttributes = (): { [key: string]: string } =>
|
|
72
|
+
{
|
|
73
|
+
return {};
|
|
74
|
+
};
|
|
75
|
+
const getCell = (row: EntityType, column: string) =>
|
|
76
|
+
{
|
|
77
|
+
if (column === "selected")
|
|
78
|
+
return <input id={`checkbox_device_${row.id}`} type="checkbox" defaultValue={this.state.selected.includes(row.id) + ""} onVolumeChange={(e) =>
|
|
79
|
+
{
|
|
80
|
+
let selected = this.state.selected;
|
|
81
|
+
if (e.currentTarget.checked)
|
|
82
|
+
selected.push(row.id);
|
|
83
|
+
else
|
|
84
|
+
selected = selected.filter(x => x != row.id);
|
|
85
|
+
this.setState(prevState => ({ ...prevState, selected }));
|
|
86
|
+
}} />;
|
|
87
|
+
return (row as any)[column];
|
|
88
|
+
};
|
|
83
89
|
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
90
|
+
let content1 = () => <p>Content for Tab</p>;
|
|
91
|
+
let content2 = () => <p>Content for Tab</p>;
|
|
92
|
+
let content3 = () => <p>Content for Tab</p>;
|
|
93
|
+
const tabs = [
|
|
94
|
+
{ title: 'Information', getContent: content1 },
|
|
95
|
+
{ title: 'Price History', getContent: content2 },
|
|
96
|
+
{ title: 'Price Estimator', getContent: content3 }
|
|
97
|
+
];
|
|
92
98
|
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
99
|
+
return (
|
|
100
|
+
<NSSection center_items={false}>
|
|
101
|
+
<NSTable<EntityType>
|
|
102
|
+
ref={this.Table}
|
|
103
|
+
columns={getColumns()}
|
|
104
|
+
getRowKey={getRowKey}
|
|
105
|
+
getColumnAttributes={getColumnAttributes}
|
|
106
|
+
getCell={getCell}
|
|
107
|
+
pageSize={this.state.page.size}
|
|
108
|
+
totalItems={this.state.totalItems}
|
|
109
|
+
reload={this.reload}
|
|
110
|
+
/>
|
|
111
|
+
<NSSpace size={NSSpaceSizeType.NORMAL}></NSSpace>
|
|
112
|
+
<NSLine></NSLine>
|
|
113
|
+
<NSSpace size={NSSpaceSizeType.NORMAL}></NSSpace>
|
|
114
|
+
<NSTabPage tabs={tabs} />
|
|
115
|
+
</NSSection>
|
|
116
|
+
);
|
|
117
|
+
}
|
|
111
118
|
}
|