@@ -3,6 +3,7 @@ import { isEqual } from '@microsoft/sp-lodash-subset';
3
3
import { TimeConvention , DateConvention } from "./DateTimeConventions" ;
4
4
import { DatePicker } from "office-ui-fabric-react/lib/DatePicker" ;
5
5
import { Label } from "office-ui-fabric-react/lib/Label" ;
6
+ import { IconButton } from "office-ui-fabric-react/lib/Button" ;
6
7
import ErrorMessage from "../errorMessage/ErrorMessage" ;
7
8
import styles from "./DateTimePicker.module.scss" ;
8
9
import HoursComponent from "./HoursComponent" ;
@@ -97,9 +98,11 @@ export class DateTimePicker extends React.Component<IDateTimePickerProps, IDateT
97
98
* Function called when the DatePicker Office UI Fabric component selected date changed
98
99
*/
99
100
private onSelectDate = ( date : Date ) : void => {
101
+
100
102
if ( ! TimeHelper . isValidDate ( date ) ) {
101
103
return ;
102
104
}
105
+
103
106
// Get hours, minutes and seconds from state or default to zero
104
107
const { hours = 0 , minutes = 0 , seconds = 0 } = this . state ;
105
108
const day = TimeHelper . cloneDate ( date ) ;
@@ -109,7 +112,14 @@ export class DateTimePicker extends React.Component<IDateTimePickerProps, IDateT
109
112
this . setState ( { day } , ( ) => this . delayedValidate ( this . state . day ) ) ;
110
113
}
111
114
112
-
115
+ /**
116
+ * Function called from the clearDate iconbutton
117
+ */
118
+ private clearDate ( ) {
119
+ this . setState ( {
120
+ day : null
121
+ } ) ;
122
+ }
113
123
114
124
/**
115
125
* Function called when hours value have been changed
@@ -225,7 +235,9 @@ export class DateTimePicker extends React.Component<IDateTimePickerProps, IDateT
225
235
showLabels,
226
236
minDate,
227
237
maxDate,
228
- minutesIncrementStep
238
+ minutesIncrementStep,
239
+ showClearDate = false ,
240
+ showClearDateIcon= 'RemoveEvent'
229
241
} = this . props ;
230
242
231
243
const { textErrorMessage } = dateStrings ;
@@ -322,6 +334,8 @@ export class DateTimePicker extends React.Component<IDateTimePickerProps, IDateT
322
334
} }
323
335
/>
324
336
</ div >
337
+ { showClearDate === true && this . state . day !== null ? < IconButton iconProps = { { iconName : showClearDateIcon } } onClick = { ( ) => this . clearDate ( ) } /> : < > </ > }
338
+
325
339
</ div >
326
340
327
341
{ timeElm }
0 commit comments