Skip to content

Commit

Permalink
TimePicker autoOk prop
Browse files Browse the repository at this point in the history
  • Loading branch information
tyfoo committed Oct 21, 2015
1 parent 5f83108 commit 69d47fa
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 4 deletions.
14 changes: 13 additions & 1 deletion src/time-picker/clock.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ const Clock = React.createClass({
mixins: [StylePropable],

propTypes: {
onChangeMinutes: React.PropTypes.func,
onChangeHours: React.PropTypes.func,
initialTime: React.PropTypes.object,
mode: React.PropTypes.oneOf(['hour', 'minute']),
format: React.PropTypes.oneOf(['ampm', '24hr']),
Expand Down Expand Up @@ -148,12 +150,17 @@ const Clock = React.createClass({
this.setState({
selectedTime: time,
});


let { onChangeHours } = this.props;

if (finished) {
setTimeout(() => {
this.setState({
mode: 'minute',
});
if (typeof(onChangeHours === 'function')) {
onChangeHours(time);
}
}, 100);
}
},
Expand All @@ -164,6 +171,11 @@ const Clock = React.createClass({
this.setState({
selectedTime: time,
});

let { onChangeMinutes } = this.props;
if (typeof(onChangeMinutes === 'function')) {
onChangeMinutes(time);
}
},

getSelectedTime() {
Expand Down
9 changes: 7 additions & 2 deletions src/time-picker/time-picker-dialog.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ const TimePickerDialog = React.createClass({
},

propTypes: {
autoOk: React.PropTypes.bool,
initialTime: React.PropTypes.object,
onAccept: React.PropTypes.func,
onShow: React.PropTypes.func,
Expand Down Expand Up @@ -61,6 +62,7 @@ const TimePickerDialog = React.createClass({
initialTime,
onAccept,
format,
autoOk,
...other,
} = this.props;

Expand Down Expand Up @@ -89,7 +91,9 @@ const TimePickerDialog = React.createClass({
secondary={true}
onTouchTap={this._handleOKTouchTap} />,
];


let onClockChangeMinutes = (autoOk === true ? this._handleOKTouchTap : undefined);

return (
<Dialog {...other}
ref="dialogWindow"
Expand All @@ -103,7 +107,8 @@ const TimePickerDialog = React.createClass({
<Clock
ref="clock"
format={format}
initialTime={initialTime} />
initialTime={initialTime}
onChangeMinutes={onClockChangeMinutes} />
</Dialog>
);
},
Expand Down
5 changes: 4 additions & 1 deletion src/time-picker/time-picker.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ const TimePicker = React.createClass({
mixins: [StylePropable, WindowListenable],

propTypes: {
autoOk: React.PropTypes.bool,
defaultTime: React.PropTypes.object,
format: React.PropTypes.oneOf(['ampm', '24hr']),
pedantic: React.PropTypes.bool,
Expand Down Expand Up @@ -76,6 +77,7 @@ const TimePicker = React.createClass({

render() {
let {
autoOk,
format,
onFocus,
onTouchTap,
Expand Down Expand Up @@ -104,7 +106,8 @@ const TimePicker = React.createClass({
onAccept={this._handleDialogAccept}
onShow={onShow}
onDismiss={onDismiss}
format={format} />
format={format}
autoOk={autoOk} />
</div>
);
},
Expand Down

0 comments on commit 69d47fa

Please sign in to comment.