-
Notifications
You must be signed in to change notification settings - Fork 248
feat(ng-model): support input type=date | datetime and all other date/time variants #747
Conversation
As is mentioned in the API documentation for |
*/ | ||
@NgDirective(selector: '[ng-value-as]') | ||
class NgDateLikeValueAsDirective { | ||
static const String NG_VALUE_AS = 'ng-value-as', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what about multiple lines for readability ?
Updates done. Tests failing under JS have been disabled. I will create a small test case and file a bug tomorrow. |
Removed [WIP] status; I think that this version should be good to merge. If not let me know what else is needed. |
FYI: Issue 17625: Reading InputElement.valueAsDate results in NullError (Cannot call "getTime" on null), but should just be null value. Once this is fixed I will be able to re-enable the disabled tests. |
@NgDirective(selector: '[ng-value-as]') | ||
class NgDateLikeValueAsDirective { | ||
static const NG_VALUE_AS = 'ng-value-as', | ||
BEST = 'best', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
indentation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure what your preference is: to bring the NG_VALUE_AS down a line and match indentation for the rest or to align all of BEST etc with NG_V*?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well my preference would be to repeat static const
but by CS your are only required to 4+ ws a on a continuation line. Change for whatever your prefer.
Btw, we should use an (pre-)checkin autoformatter. I have had that on other projects. It saves everyone some time. |
Yep I agree. I'm not sure if we should really autoformat but at least send the commit author an email with a patch. |
|
||
inputType = 'date'; | ||
describe('type=$inputType', () { | ||
_itWorksM2E(inputType, null, stripTime, setValAsDateTime); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Our style is to keep it methods in the describe. Currently this style is confusing since it is not clear what exactly is being teste. From within the it you are free to call helper methods.
// Test driver: | ||
|
||
void main() { | ||
new NgModelDateLikeTester().run(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is no need for this extra class. It is not how the rest of our tests our set up. Please follow our convertions.
main() {
describe('ng-model for data-like', () {
describe('subsection', () {
it('should do semething', () {
...;
});
});
});
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok. I figured it was worth a try ... of illustrating a slightly different approach that can benefit from use of the Dart Editor:
- outline mode (see the example below)
- editor view fold feature (the minus inside a circle in the left margin)
Some of the main test functions are monolithic: e.g. main()
is 1500 lines in ng_model_spec.dart
, and the Dart Editor can't help navigating it (other than just scrolling).
Using a class allows the test fixture to be set as fields and each second-level describe()
as a method, which makes it easier to visualize grouping: e.g.,
Hi @chalin this is getting very close. I left few more comments, biggest one is to use null value pattern rather then check for nulls and remove the extra Test class you have. Please incorporate the comments, and I will merge it in. |
@mhevery : done. Also, I removed the |
…/time variants - Add support for input elements of type `date|datetime|datetime-local|month|time|week`. - Remove non-UTF-8 characters from some other API comments. Closes #747
…/time variants - Add support for input elements of type `date|datetime|datetime-local|month|time|week`. - Remove non-UTF-8 characters from some other API comments. Closes #747
I tried to merge this in (with some changes) but it breaks the travis. The issue is that dart2js transformer can't seem to handle the annotation. @blois can you look into it? |
Help would be appreciated. I tried to figure out what was going on but was unable to (and now I need to shift to doing some academic work). I'll chime in later today. |
You should first try to rebase on latest master. |
Done. |
@vicb : rebasing didn't help, I get the same error
|
Maybe #856 has something to do with it? |
The build issue is this It's a little complex right now because this code is used from both the command-line expression_extractor.dart and the Angular transformers- the transformers are using a resolved AST which would allow us to evaluate the expression, but the command-line utilities are using an unresolved AST. Proper fix would be to update expression_extractor to use a resolved AST so we can evaluate the expression, but this is a fairly involved change- ideally refactor the command-line tool to just wrap the transformer. The easiest fix (and what I'd recommend going with for now) is to use a string literal in the annotation rather than the const reference. Separately I'm investigating why the test-expression-extractor.sh script is not failing on this- there appear to some issues there where it's not analyzing the entire application (the file that gets generated by the test is missing a LOT of Angular expressions). |
Good bug hunting! @mhevery shall I make the tweak or is this something you will handle when merging? |
…/time variants - Add support for input elements of type `date|datetime|datetime-local|month|time|week`. - Remove non-UTF-8 characters from some other API comments.
I made the change in
|
Yay! Glad to get this one wrapped up. |
date|datetime|datetime-local|month|time|week
.