Skip to content

Commit 2ba1edc

Browse files
author
avishbran
committed
Merge pull request demisto#2 from demisto/time-only-picker
Time only picker
2 parents 3b9a796 + 6272332 commit 2ba1edc

File tree

2 files changed

+21
-7
lines changed

2 files changed

+21
-7
lines changed

DateTime.js

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,8 @@ var Datetime = React.createClass({
3737
open: TYPES.bool,
3838
strictParsing: TYPES.bool,
3939
footer: TYPES.any,
40-
header: TYPES.any
40+
header: TYPES.any,
41+
timeOnly: TYPES.bool
4142
},
4243

4344
getDefaultProps: function() {
@@ -52,7 +53,8 @@ var Datetime = React.createClass({
5253
onChange: nof,
5354
timeFormat: true,
5455
dateFormat: true,
55-
strictParsing: true
56+
strictParsing: true,
57+
timeOnly: false
5658
};
5759
},
5860

@@ -324,17 +326,29 @@ var Datetime = React.createClass({
324326

325327
var date = this.state.selectedDate || this.state.viewDate;
326328

329+
var pickerSwitches = [];
330+
pickerSwitches.push(
331+
DOM.div({key: 'swt', className: 'rdtSwitch time-switch ' + (!showDate ? 'inner-content' : 'unselected-left'), onClick: this.showView('time')}, DOM.span({key: 'ht'},[DOM.i( {key: 'wi', className: 'wait icon'}), date.format( formats.time )]))
332+
);
333+
334+
if (!this.props.timeOnly) {
335+
pickerSwitches.push(
336+
DOM.div({
337+
key: 'swd',
338+
className: 'rdtSwitch date-switch ' + (showDate ? 'inner-content' : 'unselected-right'),
339+
onClick: this.showView('days')
340+
}, DOM.span({key: 'hd'}, [DOM.i({key: 'ci', className: 'calendar icon'}), date.format(formats.date)]))
341+
);
342+
}
343+
327344
return DOM.div({className: className},
328345
children.concat(
329346
DOM.div(
330347
{ key: 'dt', className: 'rdtPicker' },
331348
DOM.div(
332349
{key: 'header', className: 'rdtPicker-header'},
333350
[this.props.header ? this.props.header : '',
334-
DOM.span({key: 'h', className:'picker'}, [
335-
DOM.div({key: 'swt', className: 'rdtSwitch time-switch ' + (!showDate ? 'inner-content' : 'unselected-left'), onClick: this.showView('time')}, DOM.span({key: 'ht'},[DOM.i( {key: 'wi', className: 'wait icon'}), date.format( formats.time )])),
336-
DOM.div({key: 'swd', className: 'rdtSwitch date-switch ' + (showDate ? 'inner-content' : 'unselected-right'), onClick: this.showView('days')}, DOM.span({key: 'hd'},[DOM.i( {key: 'ci', className: 'calendar icon'}), date.format( formats.date )]))
337-
])]
351+
DOM.span({key: 'h', className:'picker'}, pickerSwitches)]
338352
),
339353
DOM.div({ key: 'content', className: 'data-section'}, React.createElement( Component, this.getComponentProps())),
340354
DOM.div(

package.json

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

0 commit comments

Comments
 (0)