Skip to content

Commit df6c855

Browse files
committed
fix(time-picker): Addressing the change requests. #3978
1 parent 20ab3dc commit df6c855

File tree

3 files changed

+12
-14
lines changed

3 files changed

+12
-14
lines changed

projects/igniteui-angular/src/lib/time-picker/time-picker.component.ts

+2-5
Original file line numberDiff line numberDiff line change
@@ -578,10 +578,6 @@ export class IgxTimePickerComponent implements
578578
*/
579579
public selectedAmPm: string;
580580

581-
public minValueConverted: Date;
582-
583-
public maxValueConverted: Date;
584-
585581
/** @hidden @internal */
586582
private _value: Date;
587583
private _resourceStrings = CurrentResourceStrings.TimePickerResStrings;
@@ -1271,8 +1267,9 @@ export class IgxTimePickerComponent implements
12711267
return date;
12721268
}
12731269

1270+
/** @hidden @internal */
12741271
public convertMinMaxValue(value: string): Date {
1275-
if (value == null) {
1272+
if (!value) {
12761273
return;
12771274
} else {
12781275
const date = this.value ? new Date(this.value) : this._dateFromModel ? new Date(this._dateFromModel) : new Date();

projects/igniteui-angular/src/lib/time-picker/time-picker.directives.ts

+9-8
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import {
1414
} from '@angular/core';
1515
import { IGX_TIME_PICKER_COMPONENT, IgxTimePickerBase } from './time-picker.common';
1616
import { InteractionMode } from '../core/enums';
17+
import { DatePickerUtil } from '../date-picker/date-picker.utils';
1718

1819
/** @hidden */
1920
@Directive({
@@ -268,7 +269,7 @@ export class IgxHourItemDirective {
268269

269270
@HostBinding('class.igx-time-picker__item--disabled')
270271
get applyDisabledStyleForHours(): boolean {
271-
if (this.minValueDate === undefined || this.maxValueDate === undefined) {
272+
if (!this.minValueDate || !this.maxValueDate) {
272273
return false;
273274
}
274275
let hour = parseInt(this.value, 10);
@@ -277,7 +278,7 @@ export class IgxHourItemDirective {
277278
}
278279
const date = new Date(this.minValueDate);
279280
date.setHours(hour);
280-
return !(date <= this.maxValueDate && date >= this.minValueDate);
281+
return (DatePickerUtil.lessThanMinValue(date, this.minValueDate) || DatePickerUtil.greaterThanMaxValue(date, this.maxValueDate));
281282
}
282283

283284
get isSelectedHour(): boolean {
@@ -336,7 +337,7 @@ export class IgxMinuteItemDirective {
336337

337338
@HostBinding('class.igx-time-picker__item--disabled')
338339
get applyDisabledStyleForMinutes(): boolean {
339-
if (this.minValueDate === undefined || this.maxValueDate === undefined) {
340+
if (!this.minValueDate || !this.maxValueDate) {
340341
return false;
341342
}
342343
const minute = parseInt(this.value, 10);
@@ -347,7 +348,7 @@ export class IgxMinuteItemDirective {
347348
const date = new Date(this.minValueDate);
348349
date.setHours(hour);
349350
date.setMinutes(minute);
350-
return !(date <= this.maxValueDate && date >= this.minValueDate);
351+
return (DatePickerUtil.lessThanMinValue(date, this.minValueDate) || DatePickerUtil.greaterThanMaxValue(date, this.maxValueDate));
351352
}
352353

353354
get isSelectedMinute(): boolean {
@@ -409,7 +410,7 @@ export class IgxSecondsItemDirective {
409410

410411
@HostBinding('class.igx-time-picker__item--disabled')
411412
get applyDisabledStyleForSeconds(): boolean {
412-
if (this.minValueDate === undefined || this.maxValueDate === undefined) {
413+
if (!this.minValueDate || !this.maxValueDate) {
413414
return false;
414415
}
415416
const minute = parseInt(this.selectedMinute, 10);
@@ -422,7 +423,7 @@ export class IgxSecondsItemDirective {
422423
date.setHours(hour);
423424
date.setMinutes(minute);
424425
date.setSeconds(second);
425-
return !(date <= this.maxValueDate && date >= this.minValueDate);
426+
return (DatePickerUtil.lessThanMinValue(date, this.minValueDate) || DatePickerUtil.greaterThanMaxValue(date, this.maxValueDate));
426427
}
427428

428429
get isSelectedSeconds(): boolean {
@@ -484,7 +485,7 @@ export class IgxAmPmItemDirective {
484485

485486
@HostBinding('class.igx-time-picker__item--disabled')
486487
get applyDisabledStyleForAmPm(): boolean {
487-
if (this.minValueDate === undefined || this.maxValueDate === undefined) {
488+
if (!this.minValueDate || !this.maxValueDate) {
488489
return false;
489490
}
490491
const minute = parseInt(this.selectedMinute, 10);
@@ -498,7 +499,7 @@ export class IgxAmPmItemDirective {
498499
date.setHours(hour);
499500
date.setMinutes(minute);
500501
date.setSeconds(second);
501-
return !(date <= this.maxValueDate && date >= this.minValueDate);
502+
return (DatePickerUtil.lessThanMinValue(date, this.minValueDate) || DatePickerUtil.greaterThanMaxValue(date, this.maxValueDate));
502503
}
503504

504505
get isSelectedAmPm(): boolean {

src/app/time-picker/time-picker.sample.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ export class TimePickerSampleComponent implements AfterViewInit {
1717
mode = InteractionMode.DropDown;
1818

1919
date1 = new Date(2018, 10, 27, 17, 45, 0, 0);
20-
date = new Date(2018, 10, 27, 21, 45, 0, 0);
20+
date = new Date(2018, 10, 27, 9, 45, 0, 0);
2121
val = new Date(0, 0, 0, 19, 35, 30, 0);
2222
today = new Date(Date.now());
2323

0 commit comments

Comments
 (0)