From 12d44281e05fbca87f6fc798daccdbfd0140d044 Mon Sep 17 00:00:00 2001 From: vmakhaev Date: Mon, 5 Jan 2015 15:06:50 +0300 Subject: [PATCH 1/3] add onChange to DatePicker --- src/js/date-picker/date-picker.jsx | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/js/date-picker/date-picker.jsx b/src/js/date-picker/date-picker.jsx index cf4fe2a9d0d54e..26196c34fb8f64 100644 --- a/src/js/date-picker/date-picker.jsx +++ b/src/js/date-picker/date-picker.jsx @@ -15,7 +15,8 @@ var DatePicker = React.createClass({ formatDate: React.PropTypes.func, mode: React.PropTypes.oneOf(['portrait', 'landscape', 'inline']), onFocus: React.PropTypes.func, - onTouchTap: React.PropTypes.func + onTouchTap: React.PropTypes.func, + onChange: React.PropTypes.func }, windowListeners: { @@ -66,7 +67,7 @@ var DatePicker = React.createClass({ initialDate={this.state.dialogDate} onAccept={this._handleDialogAccept} /> - + ); }, @@ -83,6 +84,7 @@ var DatePicker = React.createClass({ _handleDialogAccept: function(d) { this.setDate(d); + if (this.props.onChange) this.props.onChange(null, value); }, _handleInputFocus: function(e) { @@ -108,4 +110,4 @@ var DatePicker = React.createClass({ }); -module.exports = DatePicker; \ No newline at end of file +module.exports = DatePicker; From 23c848e077c1501b2ab3056ed3e5373c57f15d16 Mon Sep 17 00:00:00 2001 From: vmakhaev Date: Mon, 5 Jan 2015 16:02:20 +0300 Subject: [PATCH 2/3] fix onChange DatePicker --- src/js/date-picker/date-picker.jsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/js/date-picker/date-picker.jsx b/src/js/date-picker/date-picker.jsx index 26196c34fb8f64..ac18b17dadf102 100644 --- a/src/js/date-picker/date-picker.jsx +++ b/src/js/date-picker/date-picker.jsx @@ -84,7 +84,7 @@ var DatePicker = React.createClass({ _handleDialogAccept: function(d) { this.setDate(d); - if (this.props.onChange) this.props.onChange(null, value); + if (this.props.onChange) this.props.onChange(null, d); }, _handleInputFocus: function(e) { From ba1260d4b635783437023500d833af200a76eb6d Mon Sep 17 00:00:00 2001 From: vmakhaev Date: Mon, 5 Jan 2015 16:15:42 +0300 Subject: [PATCH 3/3] get dialog date from state --- src/js/date-picker/date-picker.jsx | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/src/js/date-picker/date-picker.jsx b/src/js/date-picker/date-picker.jsx index ac18b17dadf102..7fc1863b022a25 100644 --- a/src/js/date-picker/date-picker.jsx +++ b/src/js/date-picker/date-picker.jsx @@ -72,7 +72,7 @@ var DatePicker = React.createClass({ }, getDate: function() { - return this.state.value; + return this.state.date; }, setDate: function(d) { @@ -93,11 +93,8 @@ var DatePicker = React.createClass({ }, _handleInputTouchTap: function(e) { - var dateString = this.refs.input.getValue(); - var inputDate = dateString ? new Date(dateString) : new Date(); - this.setState({ - dialogDate: inputDate + dialogDate: this.getDate() }); this.refs.dialogWindow.show();