Created
July 25, 2016 13:17
-
-
Save zindel/7cb1ff7e65c0f473391d521c497ee4a4 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React from 'react'; | |
import {Action} from 'rex-action'; | |
import {HBox, VBox} from 'rex-widget/layout'; | |
import {DataSet} from 'rex-widget/data'; | |
import autobind from 'autobind-decorator'; | |
import {DataTableBase} from 'rex-widget/datatable'; | |
import {SearchInput} from 'rex-widget/form'; | |
import Title from 'rex-action/lib/actions/Title'; | |
export default class PickTableWizard extends React.Component { | |
render() { | |
let {title, onClose, tables} = this.props; | |
let {filter = ''} = this.props.actionState; | |
let data = DataSet.fromData(tables.filter( | |
(table) => table.title.indexOf(filter) != -1 | |
)); | |
return ( | |
<Action title={title} onClose={onClose} noContentWrapper> | |
<VBox flex={1}> | |
<HBox padding={5}> | |
<SearchInput | |
debounce={500} | |
onChange={this.onChangeFilter} | |
value={filter} | |
/> | |
</HBox> | |
<VBox flex={1}> | |
<DataTableBase | |
flex={1} | |
columns={[ | |
{valueKey: ['title'], label: 'Table'}, | |
]} | |
data={data} | |
onSelect={this.onSelect} | |
/> | |
</VBox> | |
</VBox> | |
</Action> | |
); | |
} | |
@autobind | |
onSelect(id) { | |
this.props.onContext({ | |
table: id | |
}); | |
} | |
@autobind | |
onChangeFilter(value) { | |
this.props.setActionState({filter: value}); | |
} | |
static renderTitle(props, context) { | |
let {title} = props; | |
let {Primary, Secondary} = Title.stylesheet; | |
return ( | |
<VBox> | |
<Primary> | |
{title} | |
{context.table && <small>{context.table}</small>} | |
</Primary> | |
</VBox> | |
); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment