Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
77 commits
Select commit Hold shift + click to select a range
77a8696
feat(date-time-util): logic to identify numeric formats for editing
ddaribo Jul 3, 2024
705de49
Merge branch 'master' into bpachilova/grid-editor-options-feat-14009
ddaribo Jul 3, 2024
334cba2
chore(date-time-util): formatting fixes
ddaribo Jul 3, 2024
3648659
Merge branch 'bpachilova/grid-editor-options-feat-14009' of https://g…
ddaribo Jul 3, 2024
e24c974
Merge branch 'master' into bpachilova/grid-editor-options-feat-14009
ddaribo Jul 12, 2024
82c1fd3
fix(esf-styles): small margin fix for time picker
ddaribo Jul 12, 2024
602d25d
feat(grid-interface): add editorOptions property on the ColumnType an…
ddaribo Jul 12, 2024
282c896
feat(grid-column): get/set editorOptions and dateTimeFormat
ddaribo Jul 12, 2024
ca0f4f5
feat(grid-cells): use editorOptions.dateTimeFormat; add locale where …
ddaribo Jul 12, 2024
78e76c1
feat(grid-filters): use editorOptions.dateTimeFormat and locale on fi…
ddaribo Jul 12, 2024
6c8e88e
test(grid-column-and-filtering): editors input formats
ddaribo Jul 12, 2024
913a7cd
chore(grid-cells): delete leftover inputFormat bindings
ddaribo Jul 12, 2024
fb063af
chore(column-test): fix time col format test check
ddaribo Jul 12, 2024
d5264e1
Merge branch 'master' into bpachilova/grid-editor-options-feat-14009
ddaribo Jul 15, 2024
dcd9517
Merge branch 'master' into bpachilova/grid-editor-options-feat-14009
ddaribo Jul 15, 2024
017fdfb
feat(date-time-util): default locale-based format for time and date-t…
ddaribo Jul 17, 2024
4c0b4fa
feat(date-time-editors): handle default inputFormat based on locale
ddaribo Jul 17, 2024
cac8366
feat(date-time-util): localize predefined formats used for input; ref…
ddaribo Jul 19, 2024
6cee547
feat(date-range): handle inputFormat when locale is changed
ddaribo Jul 19, 2024
360bc67
feat(dte-dir,pickers): handle locale change and display/input formats
ddaribo Jul 19, 2024
26708b2
refactor(column): do not handle format transformations here
ddaribo Jul 19, 2024
8e1196b
refactor(qb): editorOptions.defaultDateTimeFormat setting
ddaribo Jul 19, 2024
b06fe16
refactor(filtering-ui-test): adjust according to latest changes
ddaribo Jul 19, 2024
02cbe4c
Merge branch 'master' into bpachilova/grid-editor-options-feat-14009
ddaribo Jul 19, 2024
b08258c
Merge branch 'master' into bpachilova/grid-editor-options-feat-14009
ChronosSF Aug 5, 2024
c9b5331
refactor(column): address comment - simplify editorOptions assignment
ddaribo Aug 9, 2024
45ddab0
chore(column): remove unused import
ddaribo Aug 9, 2024
8ce97fa
chore(docs): update changelog, grid feature readme
ddaribo Aug 13, 2024
a65d264
Merge branch 'master' into bpachilova/grid-editor-options-feat-14009
ddaribo Aug 15, 2024
14a6984
chore(*): fixing lint error
ddaribo Aug 15, 2024
188e1ac
chore(docs): move changelog entry under 18.2.0
ddaribo Aug 21, 2024
90018ee
Merge branch 'master' into bpachilova/grid-editor-options-feat-14009
ddaribo Aug 21, 2024
d90f85f
Merge branch 'master' into bpachilova/grid-editor-options-feat-14009
ddaribo Sep 2, 2024
98cac6b
Merge branch 'master' into bpachilova/grid-editor-options-feat-14009
ChronosSF Sep 12, 2024
fcd02f4
chore(date-time.util): use formatDate method instead of new date pipe
ddaribo Sep 27, 2024
09d3978
chore(date-time.util): not set options for DateParts.AmPm (def locale…
ddaribo Sep 27, 2024
a2f2c8e
chore(date-time-tests): normalize expected string values
ddaribo Sep 30, 2024
8b71c7c
fix(date-time.util): remove 'narrow' time option
ddaribo Sep 30, 2024
f3e2a97
chore(picker-base): discard the userSetFormat internal prop
ddaribo Sep 30, 2024
14bdd91
fix(date-time-editors): do not overwrite the set inputFormat
ddaribo Sep 30, 2024
42715e7
chore(date-time-editors-tests): refactor according to the feature specs
ddaribo Sep 30, 2024
51ebb75
refactor(date-time-editors): if not set, infer input format from disp…
ddaribo Sep 30, 2024
6492941
refactor(*): if not set, infer date-time cells input format from display
ddaribo Oct 1, 2024
4ca1812
refactor(interfaces): change name to IFieldEditorOptions and alias fo…
ddaribo Oct 1, 2024
90ab1ed
chore(grid-tests): adjust tests to focus the target editor in edit mode
ddaribo Oct 1, 2024
ce5b19e
chore(dater-range-picker-test): use variable to check expectation as …
ddaribo Oct 1, 2024
72123ac
chore(changelog): edit features description
ddaribo Oct 1, 2024
e676e81
Merge branch 'master' into bpachilova/grid-editor-options-feat-14009
ddaribo Oct 1, 2024
ad76d3f
chore(gird-filtering-tests): fix input checks
ddaribo Oct 1, 2024
fe9d959
chore(grid-filtering-tests): edit input and display format props check
ddaribo Oct 1, 2024
2bb44ad
chore(query-builder): clear redundant logic after changes
ddaribo Oct 3, 2024
a7ffbb5
Merge branch 'master' into bpachilova/grid-editor-options-feat-14009
ddaribo Oct 3, 2024
e675433
fix(dte-dir): upd display value for locale wh input+display format ar…
ddaribo Oct 4, 2024
5ddf08a
chore(tests): address comments
ddaribo Oct 4, 2024
9dce296
chore(date-time.util): address comments
ddaribo Oct 4, 2024
989bde0
fix(column): do not trigger grid pipes on editorOptions set
ddaribo Oct 4, 2024
daed5c0
chore(picker-base): address comments - allow falsy value as input format
ddaribo Oct 4, 2024
567df5b
chore(date-range): address comments
ddaribo Oct 4, 2024
9b78357
chore(dte-dir): comment - allow falsy format, default is date format
ddaribo Oct 4, 2024
7df2a6c
chore(changelog): edit description
ddaribo Oct 4, 2024
625b9b7
chore(picker, date-range): refactor per comments
ddaribo Oct 4, 2024
870a5b2
chore(column.spec): refactor tests related to focusing the cell editor
ddaribo Oct 7, 2024
bbdc60b
feat(date-time-editor.directive): add defaultInputFormatType property
ddaribo Oct 7, 2024
7ace78c
feat(*): set defaultInputFormatType on dateTimeEditor in grid editors…
ddaribo Oct 7, 2024
ec9d6fb
Merge branch 'master' into bpachilova/grid-editor-options-feat-14009
ddaribo Oct 7, 2024
fa8d6fa
Merge branch 'master' into bpachilova/grid-editor-options-feat-14009
ChronosSF Oct 9, 2024
b004bf8
refactor(date-time-editor): rename defaultFormatType prop
ddaribo Oct 9, 2024
216ea4a
refactor(pickers): leave the date-time-editor handle the formats
ddaribo Oct 9, 2024
82f5c3e
fix(filtering-ui-tests): refactor format checks
ddaribo Oct 9, 2024
c7f51ec
refactor(*): check the dateTimeEditor format properties in tests
ddaribo Oct 9, 2024
46e5c69
refactor(editors): clean up changes, restore getters as before
ddaribo Oct 9, 2024
30268f1
feat(time-picker): add appliedFormat internal prop ensuring default f…
ddaribo Oct 9, 2024
4a213bc
chore(*): fix more tests checks
ddaribo Oct 9, 2024
955da2c
chore(*): apply suggestions
ddaribo Oct 10, 2024
b8f3915
feat(docs): add defaultFormatType info to Changelog
ddaribo Oct 10, 2024
3c77f6e
Merge branch 'master' into bpachilova/grid-editor-options-feat-14009
ChronosSF Oct 11, 2024
0789dc7
Merge branch 'master' into bpachilova/grid-editor-options-feat-14009
ChronosSF Oct 11, 2024
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
23 changes: 23 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,29 @@ All notable changes for each version of this project will be documented in this
- `IgxCarousel`
- Added support for vertical alignment. Can be configured via the `vertical` property. Defaults to `false`.
- Added support for showing/hiding the indicator controls (dots). Can be configured via the `indicators` property. Defaults to `true`.
- `ColumnType`, `IgxColumn`
- The built-in editors for columns of type `date`, `dateTime` and `time` now use a default input format as per the `IgxGrid`'s `locale`. This is valid both for cell editors and the ones in the filtering UI for all modes - `quickFilter`, `excelStyle` and the Advanced filtering.
- In case the `pipeArgs.displayFormat` property of a date-time column is set and contains only numeric date-time parts or such that can be handled by the editors, the built-in editors input format is inferred from it.
- To configure the built-in editors, a new `editorOptions` property is added that allows to pass optional parameters. Accepts an `IColumnEditorOptions` object with the `dateTimeFormat` property, that is used as input format for the editors of
`date`, `dateTime` and `time` column data types:
```ts
const editorOptions: IColumnEditorOptions = { Field?
dateTimeFormat: 'MM/dd/YYYY',
}
```
```html
<igx-column field="sampleDate" dataType="date" [editorOptions]="editorOptions"></igx-column>
```
- `FieldType` (`IgxQueryBuilder`)
- Similar to the above, the fields now accept an `editorOptions` object of type `IFieldEditorOptions`. Its `dateTimeFormat` property is used as input format for the query editors of date-time fields.
- `IgxDateTimeEditor`, `IgxDatePicker`, `IgxTimePicker`, `IgxDateRangePicker`
- In case the `inputFormat` property is not set, the input format is inferred from
`displayFormat` if set and if it contains only numeric date-time parts.
- `IgxTimePicker`
- The input and display formats are now adjusted based on the locale. For instance, day period time part (AM/PM or a/p) would not be displayed for locales that do not require it.
- `IgxDateTimeEditor`
- Added a new `defaultFormatType` property (`date` | `time` | `dateTime`) which configures the date-time parts
according to the target type that the editor mask includes. Defaults to `date`.

### Themes
- `Palettes`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -678,7 +678,8 @@
margin: rem(16px) 0;

~ igx-input-group,
~ igx-date-picker {
~ igx-date-picker,
~ igx-time-picker {
margin-inline-start: rem(16px);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ export abstract class PickerBaseDirective implements IToggleView, EditorProvider
*
* @remarks
* Also used as a placeholder when none is provided.
* Default is `"'MM/dd/yyyy'"`
*
* @example
* ```html
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { DateTimeUtil } from './date-time.util';
import { DatePart, DatePartInfo } from '../../directives/date-time-editor/date-time-editor.common';
import { DataType } from '../../data-operations/data-util';

const reduceToDictionary = (parts: DatePartInfo[]) => parts.reduce((obj, x) => {
obj[x.type] = x;
Expand Down Expand Up @@ -233,6 +234,28 @@ describe(`DateTimeUtil Unit tests`, () => {
expect(result).toEqual('MM/dd/yyyy');
});

it('should properly build input formats based on locale for dateTime data type ', () => {
let result = DateTimeUtil.getDefaultInputFormat('en-US', DataType.DateTime);
expect(result.normalize('NFKC')).toEqual('MM/dd/yyyy, hh:mm:ss tt');

result = DateTimeUtil.getDefaultInputFormat('bg-BG', DataType.DateTime);
expect(result.normalize('NFKC')).toEqual('dd.MM.yyyy г., HH:mm:ss');

result = DateTimeUtil.getDefaultInputFormat('fr-FR', DataType.DateTime);
expect(result).toEqual('dd/MM/yyyy HH:mm:ss');
});

it('should properly build input formats based on locale for time data type ', () => {
let result = DateTimeUtil.getDefaultInputFormat('en-US', DataType.Time);
expect(result.normalize('NFKC')).toEqual('hh:mm tt');

result = DateTimeUtil.getDefaultInputFormat('bg-BG', DataType.Time);
expect(result.normalize('NFKC')).toEqual('HH:mm');

result = DateTimeUtil.getDefaultInputFormat('fr-FR', DataType.Time);
expect(result).toEqual('HH:mm');
});

it('should correctly distinguish date from time characters', () => {
expect(DateTimeUtil.isDateOrTimeChar('d')).toBeTrue();
expect(DateTimeUtil.isDateOrTimeChar('M')).toBeTrue();
Expand Down Expand Up @@ -628,4 +651,59 @@ describe(`DateTimeUtil Unit tests`, () => {
expect(DateTimeUtil.isValidDate(false)).toBeFalse();
expect(DateTimeUtil.isValidDate(true)).toBeFalse();
});

it('should correctly identify formats that would resolve to only numeric parts (and period) for the date/time parts', () => {
// test with locale covering non-ASCII characters as well
const locale = 'bg';

const numericFormats = ['y', 'yy', 'yyy', 'yyyy', 'M', 'MM', 'd', 'dd', 'h', 'hh',
'H', 'HH', 'm', 'mm', 's', 'ss', 'S', 'SS', 'SSS',
'dd-MM-yyyy', 'dd/M/yyyy HH:mm:ss tt', 'dd/M/yyyy HH:mm:ss:SS a',
// literals are allowed in the format
'dd/MM/yyyy test hh:mm'
];
numericFormats.forEach(format => {
expect(DateTimeUtil.isFormatNumeric(locale, format)).withContext(`Format: ${format}`).toBeTrue();
});

const nonNumericFormats = ['MMM', 'MMMM', 'MMMMM', 'medium', 'long', 'full', 'mediumDate',
'longDate', 'fullDate', 'longTime', 'fullTime', 'dd-MMM-yyyy', 'E', 'EE'];

nonNumericFormats.forEach(format => {
expect(DateTimeUtil.isFormatNumeric(locale, format)).withContext(`Format: ${format}`).toBeFalse();
});
});

it('getNumericInputFormat should return formats with date parts that the date-time editors can handle', () => {
let locale = 'en-US';

// returns the equivalent of the predefined numeric formats as date parts
// should be transformed as inputFormats for editing (numeric year, 2-digit parts for the rest)
expect(DateTimeUtil.getNumericInputFormat(locale, 'short')).toBe('MM/dd/yyyy, hh:mm tt');
expect(DateTimeUtil.getNumericInputFormat(locale, 'shortDate')).toBe('MM/dd/yyyy');
expect(DateTimeUtil.getNumericInputFormat(locale, 'shortTime').normalize('NFKD')).toBe('hh:mm tt');
expect(DateTimeUtil.getNumericInputFormat(locale, 'mediumTime').normalize('NFKD')).toBe('hh:mm:ss tt');

// handle the predefined formats for different locales
locale = 'bg-BG';
expect(DateTimeUtil.getNumericInputFormat(locale, 'short').normalize('NFKD')).toBe('dd.MM.yyyy г., HH:mm');
expect(DateTimeUtil.getNumericInputFormat(locale, 'shortDate').normalize('NFKD')).toBe('dd.MM.yyyy г.');
expect(DateTimeUtil.getNumericInputFormat(locale, 'shortTime').normalize('NFKD')).toBe('HH:mm');
expect(DateTimeUtil.getNumericInputFormat(locale, 'mediumTime').normalize('NFKD')).toBe('HH:mm:ss');

locale = 'ja-JP';
expect(DateTimeUtil.getNumericInputFormat(locale, 'short')).toBe('yyyy/MM/dd HH:mm');
expect(DateTimeUtil.getNumericInputFormat(locale, 'shortDate')).toBe('yyyy/MM/dd');
expect(DateTimeUtil.getNumericInputFormat(locale, 'shortTime').normalize('NFKD')).toBe('HH:mm');
expect(DateTimeUtil.getNumericInputFormat(locale, 'mediumTime').normalize('NFKD')).toBe('HH:mm:ss');

// returns the same format if it is custom and numeric
expect(DateTimeUtil.getNumericInputFormat(locale, 'dd-MM-yyyy')).toBe('dd-MM-yyyy');
expect(DateTimeUtil.getNumericInputFormat(locale, 'dd/M/yyyy hh:mm:ss:SS aa')).toBe('dd/M/yyyy hh:mm:ss:SS aa');

// returns empty string if predefined and not among the numeric ones
expect(DateTimeUtil.getNumericInputFormat(locale, 'medium')).toBe('');
expect(DateTimeUtil.getNumericInputFormat(locale, 'mediumDate')).toBe('');
expect(DateTimeUtil.getNumericInputFormat(locale, 'longTime')).toBe('');
});
});
Loading