11import React , { Component , PropTypes } from 'react' ;
2- import AlertMessage from '../common/AlertMessage' ;
32import BaseGroup from './BaseGroup' ;
4- import TabsForm from '../form/TabsForm ' ;
3+ import { Nav , NavItem } from 'react-bootstrap ' ;
54
65class TabGroup extends BaseGroup {
76 static propTypes = {
@@ -11,18 +10,41 @@ class TabGroup extends BaseGroup {
1110 componentFactory : PropTypes . object . isRequired
1211 } ;
1312
13+ state = {
14+ position : 0
15+ } ;
16+
17+ handleSelect = ( eventKey ) => {
18+ this . setState ( { position : eventKey } ) ;
19+ } ;
20+
1421 render ( ) {
1522 let { layout } = this . props ;
23+ let position = this . state . position ;
24+ let content = this . getContent ( ) ;
1625
17- // the passed in layout can contain either fields or groups.
18- // in case it contains 'fields', we're gonna render each of the fields.
19- // in case it contains 'groups', we're gonna render each group, passing the fields as a parameter
20- try {
21- return < TabsForm layout = { layout } content = { this . getContent ( ) } /> ;
22- } catch ( ex ) {
23- return < AlertMessage error = { ex } />
24- }
26+ return (
27+ < section >
28+ < div className = 'row' >
29+ < div className = "metaform-group" >
30+ < Nav bsStyle = "tabs" onSelect = { this . handleSelect } >
31+ {
32+ layout . groups . map ( ( { title } , index ) => (
33+ < NavItem key = { index } eventKey = { index } >
34+ { title }
35+ </ NavItem >
36+ ) )
37+ }
38+ </ Nav >
39+ < div className = "metaform-group-content" >
40+ { content [ position ] }
41+ </ div >
42+ </ div >
43+ </ div >
44+ </ section >
45+ ) ;
2546 }
47+
2648}
2749
2850export default TabGroup ;
0 commit comments