-
Notifications
You must be signed in to change notification settings - Fork 161
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
Time picker: add hour/minute only mode #4939
Conversation
Please, @SAndreeva add this change to the changelog.md |
let formattedMinute; | ||
let formattedHour; | ||
let amPM; | ||
const amPM = (hour > 11) ? 'PM' : 'AM'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Better replace am/pm with enum values
projects/igniteui-angular/src/lib/time-picker/time-picker.component.ts
Outdated
Show resolved
Hide resolved
} | ||
} | ||
|
||
if (listName.indexOf('minuteList') !== -1 && this.timePicker.ampmList) { | ||
this.timePicker.ampmList.nativeElement.focus(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
duplicate code with the line above (ampmList.nativeElement.focus()) - merge if possible
if (this.timePicker.minuteList) { | ||
this.timePicker.minuteList.nativeElement.focus(); | ||
} else if (this.timePicker.hourList) { | ||
this.timePicker.hourList.nativeElement.focus(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
duplicate code with the line above (...hourList.nativeElement.focus()) - merge if possible
date.setSeconds(0); | ||
if (this.selectedAmPm === 'PM' && this.selectedHour !== '12') { | ||
if (this.showHoursList && this.selectedAmPm === 'PM' && this.selectedHour !== '12') { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
merge conditions with the below line if possible to avoid duplicating code (date.setHours(date.getHours() + 12))
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd rather not, this logic is very fragile.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You could merge those with ||
and the result will be the same.
date.setHours(date.getHours() + 12); | ||
} | ||
|
||
if (!this.showHoursList && amPM === 'PM' && date.getHours().toString() <= '11') { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
merge with the above condition to avoid duplicating code (date.setHours(date.getHours() + 12))
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd rather not, this logic is very fragile.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You could merge those with || and the result will be the same.
date.setSeconds(0); | ||
if (this.selectedAmPm === 'PM' && this.selectedHour !== '12') { | ||
if (this.showHoursList && this.selectedAmPm === 'PM' && this.selectedHour !== '12') { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You could merge those with ||
and the result will be the same.
Closes #4679
Additional information (check all that apply):
Checklist:
feature/README.MD
updates for the feature docsREADME.MD
CHANGELOG.MD
updates for newly added functionalityng update
migrations for the breaking changes