Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Datepicker default time #632

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,7 @@ Here are the available configurations:
| maxTime | `Dayjs\| String` | `undefined` | `daytime\|time` | Disables arrow buttons on the time select that would make the time after the `maxTime`. |
| meridiemFormat | `String` | `"A"` | `daytime\ |time` | The AM/PM format of the time select when `showTwentyFourHours` is `false`. |
| minTime | `Dayjs\| String` | `undefined` | `daytime\|time` | Disables arrow buttons on the time select that would make the time before the `minTime`. |
| defaultTime | `Dayjs\| String` | `current time` | `daytime\|time` | Default time displayed in time picker and saved if user does not select new time. |
| minutesFormat | `String` | `"mm"` | `daytime\ |time` | The minutes format of the time select. |
| minutesInterval | `number` | `1` | `daytime\ |time` | The number of minutes that will be added/subtracted when clicking up/down arrows on the time select. |
| secondsFormat | `String` | `"ss"` | `daytime\ |time` | The seconds format of the time select. |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ interface IConfig {
showTwentyFourHours?: boolean;
timeSeparator?: string;
returnedValueType?: ECalendarValue;
defaultTime?: Dayjs
}

export interface ITimeSelectConfig extends IConfig, ICalendar {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,16 @@ export class TimeSelectComponent implements OnInit, OnChanges, ControlValueAcces

init(): void {
this.componentConfig = this.timeSelectService.getConfig(this.config);
this.selected = this.selected || dayjsRef();

if (!this.selected) {
this.selected = dayjsRef();

if (this.componentConfig.defaultTime) {
const defaultTime = this.componentConfig.defaultTime;
this.selected = this.selected.set('hour', defaultTime.hour()).set('minute', defaultTime.minute()).set('second', defaultTime.second());
}
}

this.inputValueType = this.utilsService.getInputType(this.inputValue, false);
}

Expand Down