1
1
import React from 'react' ;
2
2
import PropTypes from 'prop-types' ;
3
- import { NavLink } from 'react-router-dom' ;
4
3
import CatalogForm from '../../../../react2/src/components/catalog/CatalogForm' ;
5
4
import CatalogApi from '../../api/catalogApi' ;
6
5
import { Breadcrumb , Spin , notification , Modal } from 'antd' ;
@@ -24,8 +23,23 @@ export class ManageCatalogPage extends React.Component {
24
23
} ;
25
24
}
26
25
27
- componentWillMount ( ) {
28
- CatalogApi . getCatalogInfo ( this . props . match . params . name )
26
+ componentDidMount ( ) {
27
+ const id = this . props . match . params . id ;
28
+ const name = this . props . match . params . name ;
29
+
30
+ this . fetchCatalogData ( name , id ) ;
31
+ }
32
+
33
+ componentWillReceiveProps ( nextProps ) {
34
+ const nextId = nextProps . match . params . id ;
35
+ if ( nextId === this . props . match . params . id ) return ;
36
+
37
+ const name = this . props . match . params . name ;
38
+ this . fetchCatalogData ( name , nextId ) ;
39
+ }
40
+
41
+ fetchCatalogData = ( name , id ) => {
42
+ CatalogApi . getCatalogInfo ( name )
29
43
. then ( ( response ) => {
30
44
this . setState ( { catalog : response . data } ) ;
31
45
@@ -37,9 +51,6 @@ export class ManageCatalogPage extends React.Component {
37
51
}
38
52
} ) ;
39
53
40
- const id = this . props . match . params . id ;
41
- const name = this . props . match . params . name ;
42
-
43
54
if ( id ) {
44
55
return CatalogApi . getFormObjectById ( name , id ) ;
45
56
}
@@ -58,7 +69,7 @@ export class ManageCatalogPage extends React.Component {
58
69
message : 'An error has occurred: ' + summary
59
70
} ) ;
60
71
} ) ;
61
- }
72
+ } ;
62
73
63
74
loadCollection = ( catalogClass ) => {
64
75
return CatalogApi . getCatalogExtendWithClass ( catalogClass )
@@ -80,10 +91,8 @@ export class ManageCatalogPage extends React.Component {
80
91
let errors = { } ;
81
92
82
93
/*
83
- if (this.state.form.title.length < 5) {
84
- errors.title = 'Title must be at least 5 characters.';
85
- formIsValid = false;
86
- }*/
94
+ Put validation logic here
95
+ */
87
96
88
97
this . setState ( { errors } ) ;
89
98
return formIsValid ;
0 commit comments