|
|
@@ -10,12 +10,11 @@ import Table from "./Table";
|
|
|
class Schema extends Component {
|
|
|
constructor(props) {
|
|
|
super(props);
|
|
|
- console.log('Schema props',props);
|
|
|
this.state = {
|
|
|
- currentTable: props.schemaID ?'':'add',
|
|
|
+ currentTable: props.location.state.create ? 'add' : '',
|
|
|
// default schemaID and schemaName
|
|
|
- schemaID: props.schemaID || props.history.location.state.schemaID,
|
|
|
- schemaName: props.schemaName || props.history.location.state.schemaName,
|
|
|
+ schemaID: props.schemaID || props.location.state.schemaID,
|
|
|
+ schemaName: props.schemaName || props.location.state.schemaName,
|
|
|
};
|
|
|
}
|
|
|
|
|
|
@@ -30,9 +29,15 @@ class Schema extends Component {
|
|
|
|
|
|
findRemark = data => this.state.currentTable === '' ? '' : data.find(table => table.name === this.state.currentTable) ? data.find(table => table.name === this.state.currentTable).remark : '';
|
|
|
|
|
|
+ goBack = () => {
|
|
|
+ this.setState({
|
|
|
+ currentTable: ''
|
|
|
+ })
|
|
|
+ };
|
|
|
+
|
|
|
componentWillReceiveProps(next) {
|
|
|
this.setState({
|
|
|
- currentTable: '',
|
|
|
+ currentTable: next.location.state.create ? 'add' : '',
|
|
|
schemaID: next.schemaID,
|
|
|
schemaName: next.schemaName
|
|
|
});
|
|
|
@@ -100,12 +105,14 @@ class Schema extends Component {
|
|
|
:
|
|
|
this.state.currentTable === 'add' ?
|
|
|
<Table
|
|
|
+ currentTable={''}
|
|
|
currentTableIndex={-2}
|
|
|
columns={[]}
|
|
|
remark=''
|
|
|
schemaID={this.state.schemaID}
|
|
|
schemaName={this.state.schemaName}
|
|
|
userID={userID}
|
|
|
+ goBack={this.goBack}
|
|
|
/> :
|
|
|
<Table
|
|
|
currentTable={this.state.currentTable}
|
|
|
@@ -115,6 +122,7 @@ class Schema extends Component {
|
|
|
schemaID={this.state.schemaID}
|
|
|
schemaName={this.state.schemaName}
|
|
|
userID={userID}
|
|
|
+ goBack={this.goBack}
|
|
|
/>
|
|
|
}
|
|
|
|