Skip to content

Commit 5815ca8

Browse files
committed
#24 Making it a little bit better
1 parent f01a5e9 commit 5815ca8

File tree

2 files changed

+32
-53
lines changed

2 files changed

+32
-53
lines changed

src/components/form/TabsForm.js

Lines changed: 0 additions & 43 deletions
This file was deleted.

src/components/group/TabGroup.js

Lines changed: 32 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import React, { Component, PropTypes } from 'react';
2-
import AlertMessage from '../common/AlertMessage';
32
import BaseGroup from './BaseGroup';
4-
import TabsForm from '../form/TabsForm';
3+
import { Nav, NavItem } from 'react-bootstrap';
54

65
class 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

2850
export default TabGroup;

0 commit comments

Comments
 (0)