Skip to content

Commit 6e0ec31

Browse files
committed
refactor(time-picker): fix lint errors #6482
1 parent 304daed commit 6e0ec31

File tree

3 files changed

+83
-79
lines changed

3 files changed

+83
-79
lines changed

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

+80-76
Original file line numberDiff line numberDiff line change
@@ -166,16 +166,16 @@ export class IgxTimePickerComponent extends PickerBaseDirective
166166
public mode: PickerInteractionMode = PickerInteractionMode.DropDown;
167167

168168
/**
169-
* The minimum value the picker will accept.
170-
*
171-
* @remarks
172-
* If a `string` value is passed in, it must be in ISO format.
173-
*
174-
* @example
175-
* ```html
176-
* <igx-time-picker [minValue]="18:00:00"></igx-time-picker>
177-
* ```
178-
*/
169+
* The minimum value the picker will accept.
170+
*
171+
* @remarks
172+
* If a `string` value is passed in, it must be in ISO format.
173+
*
174+
* @example
175+
* ```html
176+
* <igx-time-picker [minValue]="18:00:00"></igx-time-picker>
177+
* ```
178+
*/
179179
@Input()
180180
public set minValue(value: Date | string) {
181181
this._minValue = value;
@@ -187,16 +187,16 @@ export class IgxTimePickerComponent extends PickerBaseDirective
187187
}
188188

189189
/**
190-
* The maximum value the picker will accept.
191-
*
192-
* @remarks
193-
* If a `string` value is passed in, it must be in ISO format.
194-
*
195-
* @example
196-
* ```html
197-
* <igx-time-picker [maxValue]="20:30:00"></igx-time-picker>
198-
* ```
199-
*/
190+
* The maximum value the picker will accept.
191+
*
192+
* @remarks
193+
* If a `string` value is passed in, it must be in ISO format.
194+
*
195+
* @example
196+
* ```html
197+
* <igx-time-picker [maxValue]="20:30:00"></igx-time-picker>
198+
* ```
199+
*/
200200
@Input()
201201
public set maxValue(value: Date | string) {
202202
this._maxValue = value;
@@ -219,10 +219,10 @@ export class IgxTimePickerComponent extends PickerBaseDirective
219219

220220
/**
221221
* Sets the orientation of the picker's header.
222-
*
222+
*
223223
* @remarks
224224
* Available in dialog mode only. Default value is `horizontal`.
225-
*
225+
*
226226
* ```html
227227
* <igx-time-picker [headerOrientation]="'vertical'"></igx-time-picker>
228228
* ```
@@ -484,17 +484,17 @@ export class IgxTimePickerComponent extends PickerBaseDirective
484484

485485

486486
/**
487-
* The currently selected value / time from the drop-down/dialog
488-
*
489-
* @remarks
490-
* The current value is of type `Date`
491-
*
492-
* @example
493-
* ```typescript
494-
* const newValue: Date = new Date(2000, 2, 2, 10, 15, 15);
495-
* this.timePicker.value = newValue;
496-
* ```
497-
*/
487+
* The currently selected value / time from the drop-down/dialog
488+
*
489+
* @remarks
490+
* The current value is of type `Date`
491+
*
492+
* @example
493+
* ```typescript
494+
* const newValue: Date = new Date(2000, 2, 2, 10, 15, 15);
495+
* this.timePicker.value = newValue;
496+
* ```
497+
*/
498498
public get value(): Date | string {
499499
return this._value;
500500
}
@@ -579,7 +579,8 @@ export class IgxTimePickerComponent extends PickerBaseDirective
579579
}
580580

581581
/**
582-
* Delta values used to increment or decrement each editor date part on spin actions and to display time portions in the dropdown/dialog.
582+
* Delta values used to increment or decrement each editor date part on spin actions and
583+
* to display time portions in the dropdown/dialog.
583584
* By default `itemsDelta` is set to `{hour: 1, minute: 1, second: 1}`
584585
* ```html
585586
* <igx-time-picker [itemsDelta]="{hour:3, minute:5, second:10}" id="time-picker"></igx-time-picker>
@@ -728,15 +729,15 @@ export class IgxTimePickerComponent extends PickerBaseDirective
728729
}
729730

730731
/**
731-
* Closes the dropdown/dialog.
732-
* ```html
733-
* <igx-time-picker #timePicker></igx-time-picker>
734-
* ```
735-
* ```typescript
736-
* @ViewChild('timePicker', { read: IgxTimePickerComponent }) picker: IgxTimePickerComponent;
737-
* picker.close();
738-
* ```
739-
*/
732+
* Closes the dropdown/dialog.
733+
* ```html
734+
* <igx-time-picker #timePicker></igx-time-picker>
735+
* ```
736+
* ```typescript
737+
* @ViewChild('timePicker', { read: IgxTimePickerComponent }) picker: IgxTimePickerComponent;
738+
* picker.close();
739+
* ```
740+
*/
740741
public close(): void {
741742
this.toggleRef.close();
742743
}
@@ -750,12 +751,13 @@ export class IgxTimePickerComponent extends PickerBaseDirective
750751
}
751752

752753
/**
753-
* Clears the time picker value if it is a `string` or resets the time to `00:00:00` if the value is a Date object.
754-
* @example
755-
* ```typescript
756-
* this.timePicker.clear();
757-
* ```
758-
*/
754+
* Clears the time picker value if it is a `string` or resets the time to `00:00:00` if the value is a Date object.
755+
*
756+
* @example
757+
* ```typescript
758+
* this.timePicker.clear();
759+
* ```
760+
*/
759761
public clear(): void {
760762
if (this.disabled) {
761763
return;
@@ -780,12 +782,12 @@ export class IgxTimePickerComponent extends PickerBaseDirective
780782
}
781783

782784
/**
783-
* Selects time from the igxTimePicker.
785+
* Selects time from the igxTimePicker.
784786
*
785787
* @example
786788
* ```typescript
787789
* this.timePicker.select(date);
788-
*
790+
*
789791
* @param date Date object containing the time to be selected.
790792
*/
791793
public select(date: Date | string): void {
@@ -798,10 +800,10 @@ export class IgxTimePickerComponent extends PickerBaseDirective
798800
}
799801

800802
/**
801-
* Increment specified TimePart.
802-
*
803-
* @param datePart The optional DatePart to increment. Defaults to Hours.
804-
*/
803+
* Increment specified TimePart.
804+
*
805+
* @param datePart The optional DatePart to increment. Defaults to Hours.
806+
*/
805807
public increment(datePart?: DatePart): void {
806808
const timePart = datePart ? datePart : DatePart.Hours;
807809

@@ -813,10 +815,10 @@ export class IgxTimePickerComponent extends PickerBaseDirective
813815
}
814816

815817
/**
816-
* Decrement specified TimePart.
817-
*
818-
* @param datePart The optional DatePart to decrement. Defaults to Hours.
819-
*/
818+
* Decrement specified TimePart.
819+
*
820+
* @param datePart The optional DatePart to decrement. Defaults to Hours.
821+
*/
820822
public decrement(datePart?: DatePart): void {
821823
const timePart = datePart ? datePart : DatePart.Hours;
822824

@@ -841,7 +843,7 @@ export class IgxTimePickerComponent extends PickerBaseDirective
841843
case 'hourList':
842844
const previousDate = new Date(date);
843845
let ampm: string;
844-
let selectedHour = parseInt(item, 10);
846+
const selectedHour = parseInt(item, 10);
845847
let hours = selectedHour;
846848

847849
if (this.showAmPmList) {
@@ -887,13 +889,13 @@ export class IgxTimePickerComponent extends PickerBaseDirective
887889
break;
888890
}
889891
case 'ampmList': {
890-
let hours = this._selectedDate.getHours();
891-
hours = item === 'AM' ? hours - 12 : hours + 12;
892-
date.setHours(hours);
892+
let hour = this._selectedDate.getHours();
893+
hour = item === 'AM' ? hour - 12 : hour + 12;
894+
date.setHours(hour);
893895
date = this.validateDropdownValue(date, true);
894-
hours = this.toTwelveHourFormat(date.getHours());
896+
hour = this.toTwelveHourFormat(date.getHours());
895897
this._ampmView = this.scrollListItem(item, this._ampmItems, DatePart.AmPm);
896-
this._hourView = this.scrollListItem(hours, this._hourItems, DatePart.Hours);
898+
this._hourView = this.scrollListItem(hour, this._hourItems, DatePart.Hours);
897899
this._selectedDate = date;
898900
this.updateSelectedMinutes();
899901
this.updateSelectedSeconds();
@@ -909,7 +911,7 @@ export class IgxTimePickerComponent extends PickerBaseDirective
909911
const previousDate = new Date(this._selectedDate);
910912
const minHours = this._minDropdownValue?.getHours() || 0;
911913
const maxHours = this._maxDropdownValue?.getHours() || 24;
912-
let previousHours = previousDate.getHours();
914+
const previousHours = previousDate.getHours();
913915
let hours = previousHours + delta * this.itemsDelta.hour;
914916
if ((previousHours === maxHours && delta > 0) || (previousHours === minHours && delta < 0)) {
915917
hours = !this.spinLoop ? previousHours : delta > 0 ? minHours : maxHours;
@@ -1205,7 +1207,8 @@ export class IgxTimePickerComponent extends PickerBaseDirective
12051207
this._onTouchedCallback();
12061208

12071209
if (this.showHoursList) {
1208-
const selectedHour = this.isTwelveHourFormat ? this.toTwelveHourFormat(this._selectedDate.getHours()) : this._selectedDate.getHours();
1210+
const hours = this._selectedDate.getHours();
1211+
const selectedHour = this.isTwelveHourFormat ? this.toTwelveHourFormat(hours) : hours;
12091212
this._hourView = this.scrollListItem(selectedHour, this._hourItems, DatePart.Hours);
12101213
}
12111214
if (this.showMinutesList) {
@@ -1237,13 +1240,11 @@ export class IgxTimePickerComponent extends PickerBaseDirective
12371240
}
12381241

12391242
private findArrayMinMax(array: any[]): any {
1240-
const filteredArray = array.filter(function (val) {
1241-
return val !== null
1242-
});
1243+
const filteredArray = array.filter(val => val !== null);
12431244
return {
12441245
min: Math.min(...filteredArray),
12451246
max: Math.max(...filteredArray)
1246-
}
1247+
};
12471248
}
12481249

12491250
private updateSelectedMinutes() {
@@ -1378,15 +1379,18 @@ export class IgxTimePickerComponent extends PickerBaseDirective
13781379
}
13791380

13801381
private toISOString(value: Date): string {
1381-
return value.toLocaleTimeString("en-GB", {
1382-
hour: "2-digit",
1383-
minute: "2-digit",
1384-
second: "2-digit",
1382+
return value.toLocaleTimeString('en-GB', {
1383+
hour: '2-digit',
1384+
minute: '2-digit',
1385+
second: '2-digit',
13851386
});
13861387
}
13871388

13881389
private isTimePart(datePart: DatePart): boolean {
1389-
return (datePart === DatePart.Hours || datePart === DatePart.Minutes || datePart === DatePart.Seconds || datePart === DatePart.AmPm);
1390+
return (datePart === DatePart.Hours ||
1391+
datePart === DatePart.Minutes ||
1392+
datePart === DatePart.Seconds ||
1393+
datePart === DatePart.AmPm);
13901394
}
13911395

13921396
private toTwelveHourFormat(hour: number): number {

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

+2-2
Original file line numberDiff line numberDiff line change
@@ -276,8 +276,8 @@ export class IgxTimeItemDirective {
276276
return DateTimeUtil.getPartValue(this.timePicker.selectedDate, minutePart, minutePart.format.length) === this.value;
277277
}
278278
case 'secondsList': {
279-
const hourPart = inputDateParts.find(element => element.type === 'second');
280-
return DateTimeUtil.getPartValue(this.timePicker.selectedDate, hourPart, hourPart.format.length) === this.value;
279+
const secondsPart = inputDateParts.find(element => element.type === 'second');
280+
return DateTimeUtil.getPartValue(this.timePicker.selectedDate, secondsPart, secondsPart.format.length) === this.value;
281281
}
282282
case 'ampmList': {
283283
const ampmPart = inputDateParts.find(element => element.format === 'tt');

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ export class TimeFormatPipe implements PipeTransform {
1111

1212
public transform(value: Date): string {
1313
const format = this.timePicker.inputFormat.replace('tt', 'aa');
14-
var datePipe = new DatePipe(this.timePicker.locale);
14+
const datePipe = new DatePipe(this.timePicker.locale);
1515
return datePipe.transform(value, format);
1616
}
1717
}

0 commit comments

Comments
 (0)