Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 51a9f36

Browse files
author
jonatansalas
committed
#35 Added Number component
#43 Added Number component #51 Fix issues with bootstrap demo
1 parent 9a11422 commit 51a9f36

File tree

4 files changed

+36
-6
lines changed

4 files changed

+36
-6
lines changed

‎src/components/common/Input.js

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,18 @@ class Input extends Component {
1919

2020
static defaultProps = {
2121
inputType: "text"
22-
}
22+
};
2323

2424
render() {
2525
let {
2626
error, touched, displayName, name, help, fieldLayout, innerSize, children, inputType,
27-
value, placeholder, addonBefore, addonAfter, onChange, onBlur, componentClass, rows
27+
value, placeholder, addonBefore, addonAfter, onChange, onBlur, componentClass, rows,
28+
min, max
2829
} = this.props;
2930

31+
console.info("This is the min -> " + min);
32+
console.info("This is the max -> " + max);
33+
3034
let formGroupProps = {
3135
error,
3236
touched,
@@ -49,12 +53,12 @@ class Input extends Component {
4953
onChange,
5054
onBlur,
5155
componentClass,
52-
rows
56+
rows,
5357
};
5458

5559
return (
5660
<FormGroup {...formGroupProps}>
57-
<FormControl {...formControlProps}>
61+
<FormControl {...formControlProps}min={min}max={max}>
5862
{ children }
5963
</FormControl>
6064
</FormGroup>

‎src/components/field/DateTimePicker.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@ import React, { Component, PropTypes } from 'react';
22
import {DateTimePicker as ReactWidgetsDateTimePicker} from 'react-widgets';
33
import { getDateLocalizer } from 'redux-autoform-utils';
44
import FormGroup from '../common/FormGroup';
5+
import Moment from 'moment';
6+
import momentLocalizer from 'react-widgets/lib/localizers/moment';
7+
8+
momentLocalizer(Moment);
59

610
class DateTimePicker extends Component {
711
static propTypes = {

‎src/components/field/Number.js

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import React, { Component, PropTypes } from 'react';
2+
import Input from '../common/Input';
3+
4+
class Number extends Component {
5+
static propTypes = {
6+
value: PropTypes.any,
7+
onChange: PropTypes.func.isRequired,
8+
placeholder: PropTypes.string,
9+
displayName: PropTypes.string,
10+
name: PropTypes.string.isRequired,
11+
error: PropTypes.string,
12+
addonBefore: PropTypes.string,
13+
addonAfter: PropTypes.string,
14+
fieldLayout: PropTypes.string
15+
};
16+
17+
render() {
18+
return <Input componentClass="input" inputType="number" {...this.props}/>;
19+
}
20+
}
21+
22+
export default Number;

‎src/factory/BootstrapFactory.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import Checkbox from '../components/field/CheckBox';
1313
import Radio from '../components/field/Radio';
1414
import FileUpload from '../components/field/FileUpload';
1515
import EntityContainer from '../components/field/EntityContainer';
16+
import Number from '../components/field/Number';
1617

1718
import Group from '../components/group/Group';
1819
import TabGroup from '../components/group/TabGroup';
@@ -24,11 +25,9 @@ import Root from '../components/common/Root';
2425
class BootstrapFactory extends ComponentFactory {
2526
constructor(config) {
2627
super();
27-
2828
this.setBaseComponents();
2929
this.setDefaultConfiguration(config);
3030
}
31-
3231

3332
setBaseComponents = () => {
3433
this.registerFieldComponent('TextBox', ['string', 'int', 'float', 'datetime', 'date', 'time'], TextBox);
@@ -45,6 +44,7 @@ class BootstrapFactory extends ComponentFactory {
4544
this.registerFieldComponent('FieldGroup', ['group'], FieldGroup);
4645
this.registerFieldComponent('FileUpload', ['string'], FileUpload);
4746
this.registerFieldComponent('EntityContainer', ['entity'], EntityContainer);
47+
this.registerFieldComponent('Number', ['int'], Number);
4848

4949
this.registerGroupComponent('Group', Group);
5050
this.registerGroupComponent('TabGroup', TabGroup);

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /