1
0
mirror of https://github.com/ascribe/onion.git synced 2024-06-30 21:52:08 +02:00
onion/js/components/ascribe_forms/input_date.js

62 lines
1.8 KiB
JavaScript
Raw Normal View History

'use strict';
2015-06-01 13:02:53 +02:00
import React from 'react';
import AlertMixin from '../../mixins/alert_mixin';
import DatePicker from 'react-datepicker/dist/react-datepicker';
2015-06-01 13:02:53 +02:00
let InputDate = React.createClass({
mixins: [AlertMixin],
2015-06-01 13:02:53 +02:00
getInitialState() {
return {
value: null,
2015-06-05 11:40:49 +02:00
value_formatted: null,
alerts: null // needed in AlertMixin
2015-06-01 13:02:53 +02:00
};
},
2015-06-01 14:49:13 +02:00
handleChange(date) {
2015-06-02 18:43:37 +02:00
this.setState({
value: date,
value_formatted: date.format("YYYY-MM-DD")});
2015-06-01 13:02:53 +02:00
},
2015-06-01 14:49:13 +02:00
2015-06-01 13:02:53 +02:00
render: function () {
let className = 'form-control input-text-ascribe';
2015-06-01 13:02:53 +02:00
let alerts = (this.props.submitted) ? null : this.state.alerts;
return (
2015-06-02 18:43:37 +02:00
<div className="form-group">
{alerts}
<DatePicker
key="example2"
dateFormat="YYYY-MM-DD"
selected={this.state.value}
onChange={this.handleChange}
placeholderText={this.props.placeholderText}/>
</div>
2015-06-01 13:02:53 +02:00
);
// CAN THIS BE REMOVED???
//
// - Tim?
//
2015-06-01 13:02:53 +02:00
//return (
// <div className="input-group date"
// ref={this.props.name + "_picker"}
// onChange={this.handleChange}>
// <input className={className}
// ref={this.props.name}
// placeholder={this.props.placeholder}
// required={this.props.required}
// type="text"/>
// <span className="input-group-addon input-text-ascribe">
// <span className="glyphicon glyphicon-calendar" style={{"color": "black"}}></span>
// </span>
// </div>
//)
}
});
2015-06-01 14:49:13 +02:00
export default InputDate;