import React, {Component} from 'react'; import {Select, Input, Icon, Button, notification} from 'antd'; const Option = Select.Option; class Change extends Component { constructor(props) { super(props); this.state = { currentSchema: props.currentSchema, currentTable: props.currentTable, remark: props.remark, columns: props.columns, newColName: '', newColType: 'type', types: ['ID', 'String', 'Int', 'Float'], descriptions: ['description', 'key', 'non-null', 'non-null-list'] } } handleNameChange = (index) => { return (e) => { let columns = this.state.columns; columns[index].name = e.target.value; this.setState({ columns }) }; }; handleNameNew = (e) => { this.setState({ newColName: e.target.value, showNewColumn: false }) }; handleTypeChange = (index) => { return (value) => { let columns = this.state.columns; columns[index].type = value; this.setState({ columns }); } }; handleTypeNew = (value) => { if (this.state.newColName !== '') { let columns = this.state.columns; columns.push({name: this.state.newColName, type: value, desc: 'description'}); this.setState({ columns, newColName: '', newColType: 'type' }) } else { notification['warning']({ message: 'Notification', description: 'Input a name first.', }); } }; handleDescChange = (index) => { return (value) => { let columns = this.state.columns; columns[index].desc = value; this.setState({ columns }); }; }; handleColDelete = (index) => { return () => { let columns = this.state.columns; columns.splice(index, 1); this.setState({ columns }); } }; componentWillReceiveProps(next) { this.setState({ currentTable: next.currentTable, currentSchema: next.currentSchema, columns: next.columns, remark: next.remark }); }; render() { return (
Table name { this.setState({currentTable: e.target.value}) }}/>
Table remark { this.setState({remark: e.target.value}) }}/>
Table columns name type description { this.state.columns.map((col, index) =>
) }
) } } export default Change;