Skip to content
This repository was archived by the owner on Feb 22, 2018. It is now read-only.

feat(ng-model): support input type=date | datetime and all other date/time variants #747

Closed

Conversation

chalin
Copy link
Contributor

@chalin chalin commented Mar 17, 2014

  • Add support for input elements of type date|datetime|datetime-local|month|time|week.
  • Remove non-UTF-8 characters from some other API comments.

@chalin chalin added cla: yes and removed cla: no labels Mar 17, 2014
@chalin chalin closed this Mar 18, 2014
@chalin chalin reopened this Mar 18, 2014
@chalin
Copy link
Contributor Author

chalin commented Mar 18, 2014

As is mentioned in the API documentation for InputDateLikeDirective, date related inputs are not fully supported yet nor does the support always conform to the HTML standard. This required careful design in the behavior of InputDateLikeDirective (see the API doc for details). It also made writing tests a challenge. Tests pass under Dartium (stable and dev), but not under dart2js. Now that I finally have Chrome/dart2js tests running locally, I might need some hints as to how to best approach debugging dart2js test failures. Marking this [WIP] until the dart2js tests pass.

@chalin chalin changed the title feat(ng-model): support input type=date | datetime and all other date/time variants [WIP] feat(ng-model): support input type=date | datetime and all other date/time variants Mar 18, 2014
*/
@NgDirective(selector: '[ng-value-as]')
class NgDateLikeValueAsDirective {
static const String NG_VALUE_AS = 'ng-value-as',
Copy link
Contributor

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 ?

@chalin
Copy link
Contributor Author

chalin commented Mar 19, 2014

Updates done. Tests failing under JS have been disabled. I will create a small test case and file a bug tomorrow.

@chalin chalin changed the title [WIP] feat(ng-model): support input type=date | datetime and all other date/time variants feat(ng-model): support input type=date | datetime and all other date/time variants Mar 19, 2014
@chalin
Copy link
Contributor Author

chalin commented Mar 19, 2014

Removed [WIP] status; I think that this version should be good to merge. If not let me know what else is needed.

@chalin
Copy link
Contributor Author

chalin commented Mar 19, 2014

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',
Copy link
Contributor

Choose a reason for hiding this comment

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

indentation

Copy link
Contributor Author

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*?

Copy link
Contributor

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.

@chalin
Copy link
Contributor Author

chalin commented Mar 20, 2014

Btw, we should use an (pre-)checkin autoformatter. I have had that on other projects. It saves everyone some time.

@vicb
Copy link
Contributor

vicb commented Mar 20, 2014

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);
Copy link
Contributor

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();
Copy link
Contributor

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', () {
        ...;
      });
    });
  });
}

Copy link
Contributor Author

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.,
image

@mhevery
Copy link
Contributor

mhevery commented Apr 1, 2014

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.

@chalin
Copy link
Contributor Author

chalin commented Apr 3, 2014

@mhevery : done. Also, I removed the Directive suffix on the class names, since those are on the way out.

mhevery pushed a commit that referenced this pull request Apr 4, 2014
…/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
mhevery pushed a commit that referenced this pull request Apr 4, 2014
…/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
@mhevery
Copy link
Contributor

mhevery commented Apr 4, 2014

I tried to merge this in (with some changes) but it breaks the travis.
Travis: https://travis-ci.org/angular/angular.dart/jobs/22241686
Code: https://github.com/angular/angular.dart/tree/broken-pr-747

The issue is that dart2js transformer can't seem to handle the annotation. @blois can you look into it?

@chalin
Copy link
Contributor Author

chalin commented Apr 4, 2014

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.

@vicb
Copy link
Contributor

vicb commented Apr 4, 2014

You should first try to rebase on latest master.

@chalin
Copy link
Contributor Author

chalin commented Apr 4, 2014

Done.

@chalin
Copy link
Contributor Author

chalin commented Apr 4, 2014

@vicb : rebasing didn't help, I get the same error

Building angular_dart_example..............................
Build error:
Transform ExpressionGenerator on angular_dart_example|web/todo.dart threw error: Class 'SimpleIdentifier' has no instance getter 'stringValue'.

@chalin
Copy link
Contributor Author

chalin commented Apr 4, 2014

Maybe #856 has something to do with it?

@blois
Copy link

blois commented Apr 4, 2014

The build issue is this @NgAttr(DIRECTIVE_NAME)- right now source_metadata_extractor.dart does not follow property references in the annotations.

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).

@chalin
Copy link
Contributor Author

chalin commented Apr 4, 2014

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.
@chalin
Copy link
Contributor Author

chalin commented Apr 4, 2014

I made the change in @NgAttr(), but the Travis build is still failing, though now with different errors:

build/web/animation.dart.js is too large expecting 205753 was 207946.
build/web/bouncing_balls.dart.js is too large expecting 200130 was 202260.
build/web/hello_world.dart.js is too large expecting 197883 was 199863.
build/web/todo.dart.js is too large expecting 200783 was 203051.

@mhevery mhevery closed this in 90e0e07 Apr 4, 2014
@chalin
Copy link
Contributor Author

chalin commented Apr 4, 2014

Yay! Glad to get this one wrapped up.

@chalin chalin deleted the patch-0315-date-input-ng-model branch April 4, 2014 22:57
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Development

Successfully merging this pull request may close these issues.

4 participants