feat(datepicker): add timepicker support#6275
feat(datepicker): add timepicker support#6275valorkin merged 12 commits intovalor-software:developmentfrom ErikYu:feat-add-datetimepicker
Conversation
Codecov Report
@@ Coverage Diff @@
## development #6275 +/- ##
===============================================
- Coverage 77.06% 77.04% -0.03%
===============================================
Files 311 312 +1
Lines 10793 10863 +70
Branches 2599 2612 +13
===============================================
+ Hits 8318 8369 +51
- Misses 2463 2482 +19
Partials 12 12
Continue to review full report at Codecov.
|
| return this._daysCalendar$; | ||
| } | ||
|
|
||
| selectedTime!: Observable<Date[]|undefined>; |
There was a problem hiding this comment.
make it with optional type
enforce non nullable is no go
|
|
||
| @NgModule({ | ||
| imports: [CommonModule, TooltipModule], | ||
| imports: [CommonModule, TooltipModule, FormsModule, TimepickerModule.forRoot()], |
There was a problem hiding this comment.
injecting forms here seem is a bit too much, you can do it without it
plus you should not use .forRoot() here
There was a problem hiding this comment.
.forRoot() is removed. And i added TimepickerActions in providers. Or there will be errors
| view: state.view | ||
| }; | ||
|
|
||
| const _time = (state.selectedTime || [])[0]; |
There was a problem hiding this comment.
move this code to a helper function copyTime
const _time = (state.selectedTime || [])[0]; this is a hack around
property access is faster and memory cheaper than creating empty array each time for no good reason
if (state.selectedTime && state.selectedTime[0]) {
const _time = state.selectedTime[0];
newState.selectedDate.setHours(_time.getHours());
newState.selectedDate.setMinutes(_time.getMinutes());
newState.selectedDate.setSeconds(_time.getSeconds());
newState.selectedDate.setMilliseconds(_time.getMilliseconds());
}There was a problem hiding this comment.
added one util function
|
|
||
| case BsDatepickerActions.SELECT_TIME: { | ||
| const {date, index} = action.payload; | ||
| const selectedTime = [...state.selectedTime || []] ; |
There was a problem hiding this comment.
do proper checks and not || [] hacks please
you will get selectedTime is not iterable if it will be undefined
| }; | ||
|
|
||
| newState.selectedRange.forEach((dte: Date, index: number) => { | ||
| const _time = (state.selectedTime || [])[index]; |
Fixes #551
PR Checklist
Before creating new PR, please take a look at checklist below to make sure that you've done everything that needs to be done before we can merge it.