@@ -47,7 +47,7 @@ class SchemaArray extends PureComponent {
47
47
this . _tagPaddingLeftStyle = { } ;
48
48
}
49
49
50
- componentWillMount ( ) {
50
+ componentWillMount ( ) {
51
51
const { prefix } = this . props ;
52
52
let length = prefix . filter ( name => name != 'properties' ) . length ;
53
53
this . __tagPaddingLeftStyle = {
@@ -212,10 +212,10 @@ class SchemaItem extends PureComponent {
212
212
constructor ( props ) {
213
213
super ( props ) ;
214
214
this . _tagPaddingLeftStyle = { } ;
215
- this . num = 0
215
+ this . num = 0
216
216
}
217
217
218
- componentWillMount ( ) {
218
+ componentWillMount ( ) {
219
219
const { prefix } = this . props ;
220
220
let length = prefix . filter ( name => name != 'properties' ) . length ;
221
221
this . __tagPaddingLeftStyle = {
@@ -242,8 +242,8 @@ class SchemaItem extends PureComponent {
242
242
this . context . changeValueAction ( key , value ) ;
243
243
} ;
244
244
245
- handleChangeDesc = ( e ) => {
246
- const { data, name} = this . props
245
+ handleChangeDesc = ( e ) => {
246
+ const { data, name } = this . props
247
247
this . changeValue ( this . getPrefix ( ) , `description` , e . target . value )
248
248
}
249
249
@@ -252,7 +252,7 @@ class SchemaItem extends PureComponent {
252
252
this . context . changeTypeAction ( key , value ) ;
253
253
} ;
254
254
255
- handleChangeType = ( e ) => {
255
+ handleChangeType = ( e ) => {
256
256
this . changeType ( this . getPrefix ( ) , e )
257
257
}
258
258
@@ -262,44 +262,44 @@ class SchemaItem extends PureComponent {
262
262
this . context . enableRequireAction ( prefix , name , false ) ;
263
263
} ;
264
264
265
- handleDeleteItem = ( ) => {
266
- const { prefix, name} = this . props ;
265
+ handleDeleteItem = ( ) => {
266
+ const { prefix, name } = this . props ;
267
267
this . deleteItem ( prefix , name )
268
268
}
269
269
270
- handleShowEdit = ( ) => {
271
- const { data, name, showEdit} = this . props
270
+ handleShowEdit = ( ) => {
271
+ const { data, name, showEdit } = this . props
272
272
showEdit ( this . getPrefix ( ) , `description` , data . properties [ name ] . description )
273
273
}
274
274
275
- handleShowAdv = ( ) => {
276
- const { data, name, showAdv} = this . props
275
+ handleShowAdv = ( ) => {
276
+ const { data, name, showAdv } = this . props
277
277
showAdv ( this . getPrefix ( ) , data . properties [ name ] )
278
278
}
279
279
280
- handleAddField = ( ) => {
281
- const { prefix, name} = this . props ;
280
+ handleAddField = ( ) => {
281
+ const { prefix, name } = this . props ;
282
282
this . addField ( prefix , name )
283
283
}
284
284
285
285
addField = ( prefix , name ) => {
286
286
this . context . addFieldAction ( prefix , name ) ;
287
287
} ;
288
288
289
- getPrefix ( ) {
289
+ getPrefix ( ) {
290
290
return [ ] . concat ( this . props . prefix , this . props . name )
291
291
}
292
292
293
- handleClickIcon = ( ) => {
293
+ handleClickIcon = ( ) => {
294
294
this . clickIcon ( this . getPrefix ( ) )
295
295
}
296
296
297
- handleEnableRequire = ( e ) => {
297
+ handleEnableRequire = ( e ) => {
298
298
this . enableRequire ( this . props . prefix , this . props . name , e . target . checked )
299
299
}
300
300
301
- handleChangeName = ( e ) => {
302
- const { data, prefix, name} = this . props
301
+ handleChangeName = ( e ) => {
302
+ const { data, prefix, name } = this . props
303
303
if (
304
304
data . properties [ e . target . value ] &&
305
305
typeof data . properties [ e . target . value ] === 'object'
@@ -410,7 +410,7 @@ class SchemaItem extends PureComponent {
410
410
</ Row >
411
411
< div className = "option-formStyle" > { mapping ( prefixArray , value , showEdit , showAdv ) } </ div >
412
412
</ div >
413
- ) : null
413
+ ) : null
414
414
) ;
415
415
}
416
416
@@ -428,35 +428,40 @@ SchemaItem.contextTypes = {
428
428
getOpenValue : PropTypes . func
429
429
} ;
430
430
431
- const SchemaObject = ( props ) => {
432
- const { data, prefix, showEdit, showAdv } = props ;
433
- return (
434
- < div className = "object-style" >
435
- { Object . keys ( data . properties ) . map ( ( name , index ) =>
436
- < SchemaItem
437
- key = { index }
438
- data = { props . data }
439
- name = { name }
440
- prefix = { prefix }
441
- showEdit = { showEdit }
442
- showAdv = { showAdv } />
443
- ) }
444
- </ div >
445
- ) ;
431
+ class SchemaObjectComponent extends PureComponent {
432
+ shouldComponentUpdate ( nextProps ) {
433
+ if ( _ . isEqual ( nextProps . data , this . props . data )
434
+ && _ . isEqual ( nextProps . prefix , this . props . prefix )
435
+ && _ . isEqual ( nextProps . open , this . props . open )
436
+ ) {
437
+ return false ;
438
+ }
439
+ return true ;
440
+ }
446
441
442
+ render ( ) {
443
+ const { data, prefix, showEdit, showAdv } = this . props ;
444
+ return (
445
+ < div className = "object-style" >
446
+ { Object . keys ( data . properties ) . map ( ( name , index ) =>
447
+ < SchemaItem
448
+ key = { index }
449
+ data = { this . props . data }
450
+ name = { name }
451
+ prefix = { prefix }
452
+ showEdit = { showEdit }
453
+ showAdv = { showAdv } />
454
+ ) }
455
+ </ div >
456
+ ) ;
457
+ }
447
458
}
448
459
449
- // SchemaObject.contextTypes = {
450
- // changeNameAction: PropTypes.func,
451
- // changeValueAction: PropTypes.func,
452
- // enableRequireAction: PropTypes.func,
453
- // addFieldAction: PropTypes.func,
454
- // deleteItemAction: PropTypes.func,
455
- // changeTypeAction: PropTypes.func,
456
- // addChildFieldAction: PropTypes.func,
457
- // setOpenValueAction: PropTypes.func,
458
- // getOpenValue: PropTypes.func
459
- // };
460
+ const SchemaObject = connect ( state => ( {
461
+ open : state . schema . open
462
+ } ) ) ( SchemaObjectComponent )
463
+
464
+
460
465
461
466
const DropPlus = props => {
462
467
const { prefix, name, add } = props ;
0 commit comments