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

feat(grid): expose editorOptions for the default editors and improve built-in editing for date/time cols (input formats) #14465

Open
wants to merge 65 commits into
base: master
Choose a base branch
from

Conversation

ddaribo
Copy link
Contributor

@ddaribo ddaribo commented Jul 3, 2024

Related to #14009 and #14010

Additional information (check all that apply):

  • Bug fix
  • New functionality
  • Documentation
  • Demos
  • CI/CD

Checklist:

  • All relevant tags have been applied to this PR
  • This PR includes unit tests covering all the new code (test guidelines)
  • This PR includes API docs for newly added methods/properties (api docs guidelines)
  • This PR includes feature/README.MD updates for the feature docs
  • This PR includes general feature table updates in the root README.MD
  • This PR includes CHANGELOG.MD updates for newly added functionality
  • This PR contains breaking changes
  • This PR includes ng update migrations for the breaking changes (migrations guidelines)
  • This PR includes behavioral changes and the feature specification has been updated with them - compare revisions
    TODO: refactor the column datat types spec after comments, update editors spec

@ddaribo ddaribo changed the title feat(date-time-util): logic to identify numeric formats for editing feat(grid): expose editorOptions for the default editors and improve built-in editing for date/time cols (input formats) Jul 15, 2024
@ddaribo ddaribo added the grid label Jul 15, 2024
@ddaribo ddaribo force-pushed the bpachilova/grid-editor-options-feat-14009 branch from e8ca056 to 4c0b4fa Compare July 17, 2024 14:37
@ddaribo ddaribo force-pushed the bpachilova/grid-editor-options-feat-14009 branch 2 times, most recently from 8268f79 to b06fe16 Compare July 19, 2024 07:20
Comment on lines 42 to 44
if (value) {
this._inputFormat = value;
}
Copy link
Member

Choose a reason for hiding this comment

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

Hm, I think the check can be omitted - if the option can be falsy (and is by default) and used to behave that way too, it should be able to accept such value to revert to an initial state. Same goes for displayFormat

Comment on lines 177 to 182
if (value) {
this._inputFormat = value;
if (this.hasProjectedInputs) {
this.updateInputFormat();
}
}
Copy link
Member

Choose a reason for hiding this comment

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

Same logic with the picker base - the old functionality around updateInputFormat didn't care if there was a value or not.
Also you could use super.inputFormat to avoid rewriting the same get/set logic, IIRC it should work with our compile options. It's already in the state directive.

Copy link
Member

Choose a reason for hiding this comment

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

Same could go for the displayFormat, assuming the override is for documentation snippet purposes?

@@ -500,8 +512,9 @@ export class IgxDateTimeEditorDirective extends IgxMaskDirective implements OnCh
/** @hidden */
protected override setPlaceholder(_value: string): void { }

private updateDefaultFormat(): void {
this._defaultInputFormat = DateTimeUtil.getDefaultInputFormat(this.locale);
private updateDefaultFormat(dataType: DataType = DataType.DateTime): void {
Copy link
Member

Choose a reason for hiding this comment

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

Um wouldn't this make the editor default to date-time format if not specified, where it used to default to date-only? Don't think that'd be expected and the param isn't used, so just leave it to the old default in getDefaultInputFormat

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Right, I changed this, but since this is related to the default format for the dateTime column in the grid, thought before trying to come up with anything, it would be better to discuss how it should be addressed, after this change and according to the new implementation. Currently some tests will be failing.
So far, the input format was set to a default format property (ref) defined on the FieldType interface (ref). So it is hardcoded and also includes time parts.

So, if we'd like that to remain the same, I guess it should be additionally handled for the dateTime column?

To give some more context, the input format will not be inferred from the displayFormat in this case, as the default display format for dateTime col (medium) contains non-numeric parts (ref here and here). So, it will resolve to the default one for the dateTimeEditorDirective, which will be date-only.

Copy link
Member

Choose a reason for hiding this comment

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

Okay, was going to ask how the columns even manage the difference between date/date-time because either default on the editor won't work for both. That medium format is unfortunate, but I guess it's the only reasonable option w/ time included :/
Regardless, changing the behavior of another component to suit the grid usage probably not the way to go. Would've also been nice if the spec actually specified the default inputFormat behavior rather than a remark on the API doc. Which reminds me multiple specs are also likely due an update once we're done moving around changes.

CHANGELOG.md Outdated
@@ -28,6 +28,20 @@ For Firefox users, we provide limited scrollbar styling options through the foll
- `--sb-thumb-bg-color`: Sets the background color of the scrollbar thumb.
- `--sb-track-bg-color`: Sets the background color of the scrollbar track.

#### Column editor options
- `ColumnType`, `IgxColumn`
Copy link
Member

@damyanpetev damyanpetev Oct 3, 2024

Choose a reason for hiding this comment

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

@ddaribo I'd still describe the auto localized input format and infer from the display(pipe) format as a separate (first) point. That could even be more impactful for more people than the new option which is an override if the new functionality doesn't produce quite what you'd like :)

Comment on lines 1149 to 1150
let input = firstCell.nativeElement.querySelector('.igx-input-group__input');
expect((input as any).value).toEqual('01-10-2015 11:37 AM');
Copy link
Member

Choose a reason for hiding this comment

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

Since you started cleaning up the hardcoded selector elsewhere, might as well continue to query By.directive(IgxDateTimeEditorDirective) in all tests. Or make the selector a constant.
Also judging by the other tests at this point the editor isn't focused yet, right? So checking the the value will give you the display instead of checking the input format. IIRC, I think you need to wait for a rAF for the focus directive to kick in (i.e. tick(16)), though you could as well just check the intputFormat prop on the editor to confirm the column passed the correct options and the rest in theory is already covered by the editor tests.

@damyanpetev damyanpetev added the squash-merge Merge PR with "Squash and Merge" option label Oct 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants