JedWatson/keystone — pull request #559 by JohnnyEstilles (2014-08-21 04:13:35+00:00)
Title: Adding date type component

This date component is functionally equivalent to its "pre-react" counterpart.

I did not add any client-side validation yet because I believe we should come to a consensus on how we will implement the client/server-side code sharing.

On the server-side code, I added a `formatString` property to store the string passed using the `format` option. This way the format string is available to the client-side component. I didn't name the property "format" because it was already used by a method. As per a discussion with @JedWatson on Slack, when `noedit` is true and the `format` option is used, the `format` string is now used to display the date field value. However, it will default to the `Do MMM YYYY` format when no `format` option is used.

I've been holding off on suggesting a couple tweaks to the date field functionality until we started the move to react, so I guess now is the time.

1. Use strict parsing with moment() so that calls with incomplete dates, such as `moment('1', 'YYYY-MM-DD')`, will not pass validation. It's kind of weird that enter `1` renders a `2001-01-01` date.
2. Add an optional feature that will prevent user input and force selection from date picker, and another that ONLY shows the date picker. (My customer's have been requesting these for specific use cases.)

Also, I noticed we're getting a `moment()` deprecation warning on the server-side `updateItem()` method for the date field.

> Deprecation warning: moment construction falls back to js Date. This is discouraged and will be removed in upcoming major release. Please refer to https://github.com/moment/moment/issues/1407 for more info.

Moment now requires the format argument when parsing a date.I will clean that up on my next PR.

Let me know what you all think about my suggested tweaks and let's talk about client-side validation (I think it's long overdue).