Skip to content

Commit 86ab93e

Browse files
committed
1 parent 9441ea1 commit 86ab93e

File tree

6 files changed

+25
-7
lines changed

6 files changed

+25
-7
lines changed

docs/documentation/docs/controls/DateTimePicker.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ The `DateTimePicker` control can be configured with the following properties:
7171
| placeholder | string | no | Placeholder text for the DatePicker. |
7272
| maxDate | Date | no | The maximum allowable date. |
7373
| minDate | Date | no | The minimum allowable date. |
74+
| minutesIncrementStep | MinutesIncrement | no | Specifies minutes' increment step for `TimeDisplayControlType.Dropdow` |
7475

7576
Enum `TimeDisplayControlType`
7677

@@ -103,4 +104,9 @@ Interface `IDateTimePickerStrings` extends [IDatePickerStrings](https://develope
103104
| amDesignator | string | no | Used as AM designator when 12-hour clock is used. |
104105
| pmDesignator | string | no | Used as PM designator when 12-hour clock is used. |
105106

107+
Type `MinutesIncrement`
108+
```typescript
109+
type MinutesIncrement = 1 | 5 | 10 | 15 | 30;
110+
```
111+
106112
![](https://telemetry.sharepointpnp.com/sp-dev-fx-controls-react/wiki/controls/DateTimePicker)

src/controls/dateTimePicker/DateTimePicker.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,8 @@ export class DateTimePicker extends React.Component<IDateTimePickerProps, IDateT
211211
placeholder,
212212
showLabels,
213213
minDate,
214-
maxDate
214+
maxDate,
215+
minutesIncrementStep
215216
} = this.props;
216217

217218
const hours: number = value != null ? value.getHours() : this.state.hours;
@@ -242,6 +243,7 @@ export class DateTimePicker extends React.Component<IDateTimePickerProps, IDateT
242243
<div className={styles.picker}>
243244
<MinutesComponent disabled={disabled}
244245
value={minutes}
246+
minutesIncrementStep={minutesIncrementStep}
245247
onChange={this.dropdownMinutesChanged}
246248
timeDisplayControlType={timeDisplayControlType || TimeDisplayControlType.Text} />
247249
</div>

src/controls/dateTimePicker/IDateTimePickerProps.ts

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ import { TimeConvention, DateConvention } from './DateTimeConventions';
33
import { IDateTimePickerStrings } from './IDateTimePickerStrings';
44
import { TimeDisplayControlType } from './TimeDisplayControlType';
55

6+
export type MinutesIncrement = 1 | 5 | 10 | 15 | 30;
7+
68
/**
79
* Public properties of the DateTimePicker custom field
810
*
@@ -102,12 +104,12 @@ export interface IDateTimePickerProps {
102104
* Specify if labels in front of date and time parts should be rendered. True by default
103105
*/
104106
showLabels?: boolean;
105-
107+
106108
/**
107109
* Placeholder text for the DatePicker
108110
*/
109111
placeholder?: string;
110-
112+
111113
/**
112114
* The minimum allowable date for the DatePicker
113115
*/
@@ -119,4 +121,9 @@ export interface IDateTimePickerProps {
119121
*/
120122

121123
maxDate?: Date;
124+
125+
/**
126+
* Specifies minutes' increment step
127+
*/
128+
minutesIncrementStep?: MinutesIncrement;
122129
}

src/controls/dateTimePicker/ITimeComponentProps.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { IDropdownOption } from 'office-ui-fabric-react/lib/components/Dropdown';
22
import { TimeConvention } from './DateTimeConventions';
3+
import { MinutesIncrement } from './IDateTimePickerProps';
34
import { TimeDisplayControlType } from './TimeDisplayControlType';
45

56
/**
@@ -9,6 +10,7 @@ export interface ITimeComponentProps {
910
disabled?: boolean;
1011
value: number;
1112
timeDisplayControlType?: TimeDisplayControlType;
13+
minutesIncrementStep?: MinutesIncrement;
1214
onChange: (value?: string) => void;
1315
}
1416

src/controls/dateTimePicker/MinutesComponent.tsx

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ export default class MinutesComponent extends React.Component<ITimeComponentProp
1616
constructor(props: ITimeComponentProps) {
1717
super(props);
1818

19-
this._initMinutesOptions();
19+
this._initMinutesOptions(props.minutesIncrementStep || 1);
2020
}
2121

2222
public render(): JSX.Element {
@@ -69,9 +69,10 @@ export default class MinutesComponent extends React.Component<ITimeComponentProp
6969
}
7070
}
7171

72-
private _initMinutesOptions() {
72+
private _initMinutesOptions(step: number) {
73+
7374
let minutes: IDropdownOption[] = [];
74-
for (let j = 0; j < 60; j++) {
75+
for (let j = 0; j < 60; j += step) {
7576
let digitMin: string;
7677
if (j < 10) {
7778
digitMin = '0' + j;

src/webparts/controlsTest/components/ControlsTest.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1045,7 +1045,7 @@ export default class ControlsTest extends React.Component<IControlsTestProps, IC
10451045

10461046

10471047
<DateTimePicker label="DateTime Picker (unspecified = date and time)" isMonthPickerVisible={false} showSeconds={false} onChange={(value) => console.log("DateTimePicker value:", value)} placeholder="Pick a date" />
1048-
<DateTimePicker label="DateTime Picker 12-hour clock" showSeconds={true} onChange={(value) => console.log("DateTimePicker value:", value)} />
1048+
<DateTimePicker label="DateTime Picker 12-hour clock" showSeconds={true} onChange={(value) => console.log("DateTimePicker value:", value)} timeDisplayControlType={TimeDisplayControlType.Dropdown} minutesIncrementStep={15} />
10491049
<DateTimePicker label="DateTime Picker 24-hour clock" showSeconds={true} timeConvention={TimeConvention.Hours24} onChange={(value) => console.log("DateTimePicker value:", value)} />
10501050
<DateTimePicker label="DateTime Picker no seconds" value={new Date()} onChange={(value) => console.log("DateTimePicker value:", value)} />
10511051
<DateTimePicker label="DateTime Picker (unspecified = date and time)" timeConvention={TimeConvention.Hours24} value={new Date()} onChange={(value) => console.log("DateTimePicker value:", value)} />

0 commit comments

Comments
 (0)