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

IgxTimePicker refactoring #8947

Merged
merged 53 commits into from
Apr 19, 2021
Merged
Show file tree
Hide file tree
Changes from 33 commits
Commits
Show all changes
53 commits
Select commit Hold shift + click to select a range
e309406
refactor(time-picker): initial refactoring #6482
PlamenaMiteva Feb 10, 2021
0dd4ae4
Merge branch 'pickers-refactoring' of https://github.com/IgniteUI/ign…
PlamenaMiteva Feb 10, 2021
0c5adc9
refactor(time-picker): add dialog orientaation #6482
PlamenaMiteva Feb 10, 2021
54b14e0
refactor(time-picker): in/decrement and spinning refactoring #6482
PlamenaMiteva Feb 11, 2021
b7acbac
Merge branch 'pickers-refactoring' into PMiteva/time-picker-refactoring
PlamenaMiteva Feb 16, 2021
a02af40
refactor(time-picker): valueChange & validationFailed events refactor…
PlamenaMiteva Feb 16, 2021
1c80641
Merge branch 'PMiteva/time-picker-refactoring' of https://github.com/…
PlamenaMiteva Feb 16, 2021
6dc5451
chore(time-picker): fix typo in package-lock.json
PlamenaMiteva Feb 16, 2021
6f5ef51
refactor(time-picker): add validation refactoring #6482
PlamenaMiteva Feb 18, 2021
d75263b
refactor(time-picker): fix dialog header format #6482
PlamenaMiteva Feb 22, 2021
9c34e2a
refactor(time-picker): refactoring tests #6482
PlamenaMiteva Feb 26, 2021
575b01c
Merge branch 'pickers-refactoring' of https://github.com/IgniteUI/ign…
PlamenaMiteva Mar 1, 2021
43f4222
Update projects/igniteui-angular/src/lib/time-picker/time-picker.comp…
PlamenaMiteva Mar 1, 2021
efa390b
Update projects/igniteui-angular/src/lib/time-picker/time-picker.comp…
PlamenaMiteva Mar 1, 2021
c154bb6
refactor(time-picker): addressing comments #6482
PlamenaMiteva Mar 11, 2021
f93a9c9
Merge branch 'PMiteva/time-picker-refactoring' of https://github.com/…
PlamenaMiteva Mar 11, 2021
633bb0c
Merge branch 'pickers-refactoring' into PMiteva/time-picker-refactoring
PlamenaMiteva Mar 11, 2021
f116c9b
Merge branch 'pickers-refactoring' of https://github.com/IgniteUI/ign…
PlamenaMiteva Apr 2, 2021
c4d528f
refactor(time-picker): add time pipe #6482
PlamenaMiteva Apr 2, 2021
f28fda0
refactor(time-picker): container refactoring #6482
PlamenaMiteva Apr 8, 2021
be97844
Merge branch 'pickers-refactoring' of https://github.com/IgniteUI/ign…
PlamenaMiteva Apr 8, 2021
eab163d
Merge branch 'PMiteva/time-picker-refactoring' of https://github.com/…
PlamenaMiteva Apr 8, 2021
e155b2e
refactor(time-picker): incorporate ISO format implementation #6482
PlamenaMiteva Apr 9, 2021
384818f
refactor(time-picker): add input/display format validation #6482
PlamenaMiteva Apr 9, 2021
0a0e710
refactor(time-picker): add input/display format validation #6482
PlamenaMiteva Apr 9, 2021
1e40a76
Merge branch 'PMiteva/time-picker-refactoring' of https://github.com/…
PlamenaMiteva Apr 9, 2021
e9794ec
refactor(time-picker): fix typos #6482
PlamenaMiteva Apr 9, 2021
677eb48
refactor(time-picker): remove spinDelta #6482
PlamenaMiteva Apr 13, 2021
f2c8cac
test(time-picker): fix failing tests #6482
PlamenaMiteva Apr 13, 2021
304daed
refactor(time-picker): add aria attributes #6482
PlamenaMiteva Apr 14, 2021
6e0ec31
refactor(time-picker): fix lint errors #6482
PlamenaMiteva Apr 14, 2021
7e3c840
refactor(time-picker): fix lint errors #6482
PlamenaMiteva Apr 14, 2021
2071cc1
Merge branch 'PMiteva/time-picker-refactoring' of https://github.com/…
PlamenaMiteva Apr 14, 2021
d233a17
Merge branch 'pickers-refactoring' into PMiteva/time-picker-refactoring
PlamenaMiteva Apr 15, 2021
77d7e28
refactor(time-picker): addressing comments #6482
PlamenaMiteva Apr 15, 2021
c397f18
Merge branch 'PMiteva/time-picker-refactoring' of https://github.com/…
PlamenaMiteva Apr 15, 2021
9a95535
refactor(time-picker): include platformUtil #6482
PlamenaMiteva Apr 15, 2021
ef058be
refactor(time-picker): addressing comments #6482
PlamenaMiteva Apr 16, 2021
c82f73c
refactor(time-picker): fix lint errors #6482
PlamenaMiteva Apr 16, 2021
fad482d
refactor(time-picker): fix failing tests #6482
PlamenaMiteva Apr 16, 2021
ae279d8
refactor(time-picker): add aria attributes to selected items #6482
PlamenaMiteva Apr 18, 2021
7dc7fbd
refactor(time-picker): revert tabs component #6482
PlamenaMiteva Apr 19, 2021
fbdaa1a
Merge branch 'pickers-refactoring' of https://github.com/IgniteUI/ign…
PlamenaMiteva Apr 19, 2021
304a0a3
refactor(time-picker): remove fontSet #6482
PlamenaMiteva Apr 19, 2021
ac685cb
Merge branch 'pickers-refactoring' of https://github.com/IgniteUI/ign…
PlamenaMiteva Apr 19, 2021
8e24a34
refactor(time-picker): add readOnly property #6482
PlamenaMiteva Apr 19, 2021
7185716
refactor(time-picker): fix time picker settings in grid templates #6482
PlamenaMiteva Apr 19, 2021
f19b98b
refactor(time-picker): fix typos #6482
PlamenaMiteva Apr 19, 2021
4c1ef00
refactor(time-picker): addressing comments #6482
PlamenaMiteva Apr 19, 2021
1b5c9ab
refactor(time-picker): remove unnecessary event subscription #6482
PlamenaMiteva Apr 19, 2021
8e25f92
refactor(time-picker): add HostListner on keydown event #6482
PlamenaMiteva Apr 19, 2021
fa790a6
chore(time-picker): fix typos #6482
PlamenaMiteva Apr 19, 2021
92d3351
chore(time-picker): move host listener up #6482
PlamenaMiteva Apr 19, 2021
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
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ export abstract class PickerBaseDirective extends DisplayDensityBase implements
this.locale = this.locale || this._localeId;
}

public abstract select(value: Date | DateRange): void;
public abstract select(value: Date | DateRange | string): void;
public abstract open(settings?: OverlaySettings): void;
public abstract toggle(settings?: OverlaySettings): void;
public abstract close(): void;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ const enum DateParts {
/** @hidden */
export abstract class DateTimeUtil {
public static readonly DEFAULT_INPUT_FORMAT = 'MM/dd/yyyy';
public static readonly DEFAULT_TIME_INPUT_FORMAT = 'hh:mm tt';
private static readonly SEPARATOR = 'literal';
private static readonly DEFAULT_LOCALE = 'en';

Expand Down Expand Up @@ -359,6 +360,7 @@ export abstract class DateTimeUtil {
const format = timePart.replace(/\d/g, '0');
timePart = new MaskParsingService().replaceInMask(timePart, value,
{ format, promptChar: '' }, 0, value.length).value;
timePart = timePart.substr(0, timePart.length - 1);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, taking everything except the last char won't work in too many scenarios - time portion has zone different than UTC (+00) or no zone at all in which case you'd be removing from the milliseconds most likely. What's more, I don't see the need to remove parts of the value or go as far as the mask parsing for this - you already have a date-only part, perhaps just combining it with the literal and the time portion will produce a valid date string?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, might want to add some invalid date checks to this parse method, unless the consuming locations are supposed to check for that. The return type is described as Date | null but I don't see how the latter is possible in the current code

return new Date(`${datePart}T${timePart}`);
}

Expand Down Expand Up @@ -426,6 +428,66 @@ export abstract class DateTimeUtil {
console.warn('Using default browser locale settings.');
}

public static getPartValue(value: Date, datePartInfo: DatePartInfo, partLength: number): string {
PlamenaMiteva marked this conversation as resolved.
Show resolved Hide resolved
let maskedValue;
const datePart = datePartInfo.type;
switch (datePart) {
case DatePart.Date:
maskedValue = value.getDate();
break;
case DatePart.Month:
// months are zero based
maskedValue = value.getMonth() + 1;
break;
case DatePart.Year:
if (partLength === 2) {
maskedValue = this.prependValue(
parseInt(value.getFullYear().toString().slice(-2), 10), partLength, '0');
} else {
maskedValue = value.getFullYear();
}
break;
case DatePart.Hours:
if (datePartInfo.format.indexOf('h') !== -1) {
maskedValue = this.prependValue(
this.toTwelveHourFormat(value.getHours().toString()), partLength, '0');
} else {
maskedValue = value.getHours();
}
break;
case DatePart.Minutes:
maskedValue = value.getMinutes();
break;
case DatePart.Seconds:
maskedValue = value.getSeconds();
break;
case DatePart.AmPm:
maskedValue = value.getHours() >= 12 ? 'PM' : 'AM';
break;
}

if (datePartInfo.type !== DatePart.AmPm) {
return this.prependValue(maskedValue, partLength, '0');
}

return maskedValue;
}

private static prependValue(value: number, partLength: number, prependChar: string): string {
return (prependChar + value.toString()).slice(-partLength);
}

private static toTwelveHourFormat(value: string, promptChar = '_'): number {
let hour = parseInt(value.replace(new RegExp(promptChar, 'g'), '0'), 10);
if (hour > 12) {
PlamenaMiteva marked this conversation as resolved.
Show resolved Hide resolved
hour -= 12;
} else if (hour === 0) {
hour = 12;
}

return hour;
}

private static ensureLeadingZero(part: DatePartInfo) {
switch (part.type) {
case DatePart.Date:
Expand Down
Loading