2015-06-05 11:06:36 +02:00
|
|
|
'use strict';
|
|
|
|
|
2015-05-29 01:54:56 +02:00
|
|
|
import React from 'react';
|
|
|
|
|
2015-06-05 11:06:36 +02:00
|
|
|
import AlertMixin from '../../mixins/alert_mixin';
|
2015-05-29 01:54:56 +02:00
|
|
|
|
|
|
|
let InputText = React.createClass({
|
2015-06-09 16:10:38 +02:00
|
|
|
propTypes: {
|
|
|
|
submitted: React.PropTypes.bool,
|
|
|
|
onBlur: React.PropTypes.func,
|
|
|
|
type: React.PropTypes.string,
|
|
|
|
required: React.PropTypes.string,
|
|
|
|
placeHolder: React.PropTypes.string
|
|
|
|
},
|
2015-05-29 01:54:56 +02:00
|
|
|
|
2015-06-05 11:06:36 +02:00
|
|
|
mixins: [AlertMixin],
|
2015-05-29 01:54:56 +02:00
|
|
|
|
|
|
|
getInitialState() {
|
|
|
|
return {value: null,
|
2015-05-29 15:27:40 +02:00
|
|
|
alerts: null // needed in AlertMixin
|
2015-05-29 01:54:56 +02:00
|
|
|
};
|
|
|
|
},
|
2015-06-05 11:06:36 +02:00
|
|
|
|
2015-05-29 01:54:56 +02:00
|
|
|
handleChange(event) {
|
|
|
|
this.setState({value: event.target.value});
|
|
|
|
},
|
2015-06-05 11:06:36 +02:00
|
|
|
|
2015-05-29 01:54:56 +02:00
|
|
|
render() {
|
2015-06-05 11:06:36 +02:00
|
|
|
let className = 'form-control input-text-ascribe';
|
2015-05-29 01:54:56 +02:00
|
|
|
let alerts = (this.props.submitted) ? null : this.state.alerts;
|
|
|
|
return (
|
|
|
|
<div className="form-group">
|
|
|
|
{alerts}
|
|
|
|
<input className={className}
|
|
|
|
placeholder={this.props.placeHolder}
|
|
|
|
required={this.props.required}
|
|
|
|
type={this.props.type}
|
2015-06-01 13:02:53 +02:00
|
|
|
onChange={this.handleChange}
|
|
|
|
onBlur={this.props.onBlur}/>
|
2015-05-29 01:54:56 +02:00
|
|
|
</div>
|
|
|
|
);
|
|
|
|
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
export default InputText;
|