Skip to content

Commit 2993a96

Browse files
committed
#48 Entity Container
1 parent 51f8fb2 commit 2993a96

File tree

5 files changed

+86
-2
lines changed

5 files changed

+86
-2
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
{
2+
entities: [
3+
{
4+
name: "contact",
5+
fields: [
6+
{
7+
name: "name",
8+
displayName: "Name",
9+
type: "string",
10+
required: true,
11+
},
12+
{
13+
name: "email",
14+
displayName: "E-mail",
15+
type: "entity",
16+
entityName: 'email'
17+
}
18+
]
19+
},
20+
{
21+
name: "email",
22+
fields: [
23+
{
24+
name: "emailType",
25+
displayName: "Type",
26+
type: "string"
27+
},
28+
{
29+
name: "address",
30+
displayName: "Address",
31+
type: "string"
32+
}
33+
]
34+
}
35+
]
36+
}

demo/client/presets/presets.js

+7
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,13 @@ export default [
149149
formTitle: 'Edit contact',
150150
schema: require('./base/components/Lookup.txt')
151151
},
152+
{
153+
name: 'EntityContainer',
154+
displayName: 'Components - EntityContainer',
155+
entityName: 'contact',
156+
formTitle: 'Edit contact',
157+
schema: require('./base/components/EntityContainer.txt')
158+
},
152159
{
153160
name: 'ArrayContainer',
154161
displayName: 'Components - ArrayContainer',
+37
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
import React from 'react';
2+
3+
const EntityContainer = React.createClass({
4+
5+
propTypes: {
6+
name: React.PropTypes.string.isRequired,
7+
componentFactory: React.PropTypes.object.isRequired
8+
},
9+
10+
render: function () {
11+
12+
var header = this.props.displayName
13+
? <header className="metaform-group-header no-lateral-margin">
14+
<span className="metaform-group-title">
15+
{this.props.displayName}
16+
</span>
17+
</header>
18+
: null;
19+
20+
21+
return <div className="entity-container">
22+
{header}
23+
<div className="entity-container-content">
24+
{
25+
this.props.componentFactory.buildGroupComponent({
26+
component: this.props.layout.component,
27+
layout: this.props.layout,
28+
fields: this.props.fields,
29+
componentFactory: this.props.componentFactory
30+
})
31+
}
32+
</div>
33+
</div>;
34+
}
35+
});
36+
37+
export default EntityContainer;

src/factory/BootstrapFactory.js

+2
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import FieldGroup from '../components/field/FieldGroup';
1212
import Checkbox from '../components/field/CheckBox';
1313
import Radio from '../components/field/Radio';
1414
import FileUpload from '../components/field/FileUpload';
15+
import EntityContainer from '../components/field/EntityContainer';
1516

1617
import Group from '../components/group/Group';
1718
import TabGroup from '../components/group/TabGroup';
@@ -43,6 +44,7 @@ class BootstrapFactory extends ComponentFactory {
4344
this.registerFieldComponent('Static', ['string', 'int', 'float', 'datetime', 'date', 'time', 'bool'], Static);
4445
this.registerFieldComponent('FieldGroup', ['group'], FieldGroup);
4546
this.registerFieldComponent('FileUpload', ['string'], FileUpload);
47+
this.registerFieldComponent('EntityContainer', ['entity'], EntityContainer);
4648

4749
this.registerGroupComponent('Group', Group);
4850
this.registerGroupComponent('TabGroup', TabGroup);

src/factory/constants/TypeConstants.js

+4-2
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@ export default {
88
int : 'TextBox',
99
float: 'TextBox',
1010
bool: 'Checkbox',
11-
group: 'FieldGroup'
11+
group: 'FieldGroup',
12+
entity: 'EntityContainer'
1213
},
1314
details: {
1415
string: 'Static',
@@ -19,6 +20,7 @@ export default {
1920
int: 'Static',
2021
float: 'Static',
2122
bool: 'Static',
22-
group: 'FieldGroup'
23+
group: 'FieldGroup',
24+
entity: 'EntityContainer'
2325
}
2426
}

0 commit comments

Comments
 (0)