Skip to content

Commit 59bfd93

Browse files
authored
Added the ability to pass onOpen and return initial value on cancel (demisto#8)
* Added the ability to pass onOpen and return initial value on cancel * increase version
1 parent a7e2880 commit 59bfd93

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

DateTime.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,8 @@ var Datetime = createClass({
2828
onBlur: TYPES.func,
2929
onChange: TYPES.func,
3030
onCancel: TYPES.func,
31-
onSave: TYPES.func,
31+
onSave: TYPES.func,
32+
onOpen: TYPES.func,
3233
locale: TYPES.string,
3334
input: TYPES.bool,
3435
// dateFormat: TYPES.string | TYPES.bool,
@@ -68,7 +69,11 @@ var Datetime = createClass({
6869
if( state.open == undefined )
6970
state.open = !this.props.input;
7071

72+
if (this.props.onOpen) {
73+
this.props.onOpen(this.props.defaultValue);
74+
}
7175
state.currentView = this.props.viewMode;
76+
state.initialDate = this.props.defaultValue;
7277
return state;
7378
},
7479

@@ -357,7 +362,7 @@ var Datetime = createClass({
357362
React.createElement('div',
358363
{key: 'footer', className: 'rdtPicker-footer'}, [this.props.footer ? this.props.footer : '',
359364
React.createElement('span', {key: 'tpb', className: 'timePickerButtons'},[
360-
React.createElement('div', {key: 'cancel', className: 'cancelBtn', onClick: this.props.onCancel.bind(this)}, 'Cancel'),
365+
React.createElement('div', {key: 'cancel', className: 'cancelBtn', onClick: this.props.onCancel.bind(this, this.state.initialDate)}, 'Cancel'),
361366
React.createElement('div', {key: 'save', className: 'saveBtn ui mini button green', onClick: this.props.onSave.bind(this)}, 'Save')])]
362367
)
363368
)

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "react-datetime-demisto",
3-
"version": "3.0.12",
3+
"version": "3.0.13",
44
"description": "A lightweight but complete datetime picker React.js component.",
55
"homepage": "https://github.com/demisto/react-datetime",
66
"repository": {

0 commit comments

Comments
 (0)