|
1 | | -import { Card, Col, Row, Button, Table, Tag, Dropdown, Menu, Modal } from 'antd'; |
| 1 | +import { Card, Col, Row, Button, Table, Tag, Dropdown, Menu, Modal, Input } from 'antd'; |
2 | 2 | import * as React from 'react'; |
3 | 3 | import { EntityDto } from 'src/services/dto/entityDto'; |
4 | 4 | import CreateOrUpdateTenant from './components/createOrUpdateTenant'; |
5 | 5 | import { inject, observer } from 'mobx-react'; |
6 | | -import { __await } from 'tslib'; |
7 | 6 | import Stores from 'src/stores/storeIdentifier'; |
8 | 7 | import TenantStore from 'src/stores/tenantStore'; |
9 | 8 | import { L } from 'src/lib/abpUtility'; |
| 9 | +import AppComponentBase from 'src/components/AppComponentBase'; |
10 | 10 |
|
11 | 11 | export interface ITenantProps { |
12 | 12 | tenantStore: TenantStore; |
13 | 13 | } |
14 | 14 |
|
| 15 | +export interface ITenantState { |
| 16 | + modalVisible: boolean; |
| 17 | + maxResultCount: number; |
| 18 | + skipCount: number; |
| 19 | + tenantId: number; |
| 20 | + filter: string; |
| 21 | +} |
| 22 | + |
15 | 23 | const confirm = Modal.confirm; |
| 24 | +const Search = Input.Search; |
16 | 25 |
|
17 | 26 | @inject(Stores.TenantStore) |
18 | 27 | @observer |
19 | | -class Tenant extends React.Component<ITenantProps> { |
| 28 | +class Tenant extends AppComponentBase<ITenantProps, ITenantState> { |
20 | 29 | formRef: any; |
21 | 30 |
|
22 | | - constructor(props: any) { |
23 | | - super(props); |
24 | | - |
25 | | - this.getAll = this.getAll.bind(this); |
26 | | - this.handleChange = this.handleChange.bind(this); |
27 | | - } |
28 | | - |
29 | 31 | state = { |
30 | 32 | modalVisible: false, |
31 | 33 | maxResultCount: 10, |
32 | 34 | skipCount: 0, |
33 | 35 | tenantId: 0, |
34 | | - filter: '' |
| 36 | + filter: '', |
35 | 37 | }; |
36 | 38 |
|
37 | 39 | async componentDidMount() { |
38 | 40 | await this.getAll(); |
39 | 41 | } |
40 | 42 |
|
41 | 43 | async getAll() { |
42 | | - await this.props.tenantStore.getAll({ maxResultCount: this.state.maxResultCount, skipCount: this.state.skipCount, keyword: this.state.filter }); |
| 44 | + await this.props.tenantStore.getAll({ maxResultCount: this.state.maxResultCount, skipCount: this.state.skipCount, keyword: this.state.filter }); |
43 | 45 | } |
44 | 46 |
|
45 | 47 | handleTableChange = (pagination: any) => { |
@@ -103,12 +105,11 @@ class Tenant extends React.Component<ITenantProps> { |
103 | 105 |
|
104 | 106 | saveFormRef = (formRef: any) => { |
105 | 107 | this.formRef = formRef; |
106 | | - }; |
| 108 | + }; |
107 | 109 |
|
108 | | - handleChange(event: any) { |
109 | | - this.state.filter = event.target.value; |
110 | | - this.setState({ value: event.target.value }); |
111 | | - } |
| 110 | + handleSearch = (value: string) => { |
| 111 | + this.setState({ filter: value }, async () => await this.getAll()); |
| 112 | + }; |
112 | 113 |
|
113 | 114 | public render() { |
114 | 115 | const { tenants } = this.props.tenantStore; |
@@ -173,14 +174,10 @@ class Tenant extends React.Component<ITenantProps> { |
173 | 174 | > |
174 | 175 | <Button type="primary" shape="circle" icon="plus" onClick={() => this.createOrUpdateModalOpen({ id: 0 })} /> |
175 | 176 | </Col> |
176 | | - </Row> |
| 177 | + </Row> |
177 | 178 | <Row> |
178 | | - <Col sm={{ span: 5, offset: 0 }}> |
179 | | - <input className="ant-input" type="text" placeholder="filter" value={this.state.filter} onChange={this.handleChange.bind(this)} /> |
180 | | - </Col> |
181 | | - |
182 | | - <Col sm={{ span: 4, offset: 1 }}> |
183 | | - <Button type="primary" icon="search" value="Submit" onClick={this.getAll}>{L('Search')}</Button> |
| 179 | + <Col sm={{ span: 10, offset: 0 }}> |
| 180 | + <Search placeholder={this.L('Filter')} onSearch={this.handleSearch} /> |
184 | 181 | </Col> |
185 | 182 | </Row> |
186 | 183 | <Row style={{ marginTop: 20 }}> |
|
0 commit comments