A textbox that will guess the date you want and assign it to your model or query-params.
- Ember.js v3.12 or above
- Ember CLI v2.13 or above
- Node.js v10 or above
- Requires
ember-auto-import>= 2 & the latestwebpack
The following will install this add-on:
ember install ember-cli-date-textbox
yarn add -D ember-auto-import webpackThe following dependencies are used with this addon and may collide with dependencies in your app/addon:
ember-cli-text-support-mixinsmomentmoment-timezonesugar
The demonstration web application can be found here: http://ember-cli-date-textbox.cybertooth.io/.
As mentioned above there are several examples on the demonstration site: http://ember-cli-date-textbox.cybertooth.io/
This add-on supplies the following components:
input-date- a basic HTML textbox that will take your input and try to parse it to a date. If the parse succeeds, the date will be formatted according to your preference. Ideal for binding to your model's date fields (e.g.DS.attr('date')) or to your component or controller's properties.input-iso8601- another basic HTML textbox that will once again take your input, parse it to a date, and then store the ISO8601 representation of the date. This is a great way for binding your date to Ember's query parameters.
Further information about these items can be found in the Usage section below and in the demo (dummy) application.
If the supplied value can't be parsed to a date, we add the has-error style class to the .form-group that the
{{input-date}} and/or {{input-iso8601}} belongs to. This visualizes that the date parse was rejected.
This component makes a textbox. It takes in user input in the form of a date that is swiftly parsed and formatted.
The parsed date object is assigned to the component's date property.
date- REQUIRED. Rather than binding to thevalueproperty, this textbox input will be binding to thedateattribute.value- DO NOT USE. I mention thevalueproperty because you shouldn't bind anything to it. Users type in the textbox, the date they settle on will be formatted in the textbox which is assigned to thevalueproperty. In addition...if you supply a validdateattribute to this textbox, it will be formatted for you. Don't go being all clever trying to do things that are already taken care of for you.afterParseFail- OPTIONAL, defaultundefined. Use this argument to bind an action that accepts this component as an argument. This action will be triggered only when the date parsing fails.afterParseSuccess- OPTIONAL, defaultundefined. Use this argument to bind an action that accepts this component as an argument. This action will be triggered only when the date parsing succeeds.beforeParse- OPTIONAL, defaultundefined. Use this argument to bind an action that accepts this component as an argument. This action will be triggered prior to every parsing action.displayFormat- OPTIONAL, DEFAULTLL. Formatting is done using moment.js. The default format of your dates is the localizedLL. You can change this however you want. See the demo.endOfDay?- OPTIONAL, DEFAULTfalse.. When parsing dates, always set them to the last second of the day.future?- OPTIONAL, DEFAULTfalse. Iftrue, ambiguous dates likeSundaywill be parsed asnext Sunday. Note that non-ambiguous dates are not guaranteed to be in the future. Default isfalse.past?- OPTIONAL, DEFAULTfalse. Iftrue, ambiguous dates likeSundaywill be parsed aslast Sunday. Note that non-ambiguous dates are not guaranteed to be in the past. Default isfalse.startOfDay?- OPTIONAL, DEFAULTfalse. When parsing dates, always set them to the start of the day. If set totrue, this will take precedence over theendOfDayproperty.timezone- OPTIONAL, DEFAULTmoment.tz.guess(). Dates will be parsed and formatted in the specified timezone.- All the attributes from
ember-cli-text-support-mixins' {{input-text}}. See https://github.com/cybertoothca/ember-cli-text-support-mixins#arguments - All the standard input attributes that apply to text boxes.
What's iso8601? Go read: https://en.wikipedia.org/wiki/ISO_8601
Just like {{input-date}}, {{input-iso8601}} also makes a simple textbox. It takes in user input in the form of a date that is swiftly parsed and formatted.
iso8601- REQUIRED & MUST BE A STRING. Like the {{input-date}} component we do not use the textbox'svalueproperty and instead bind to theiso8601attribute. Thisiso8601attribute expects a String and it should be in ISO format (e.g.yyyy-MM-ddTHH:mm:ssZ).value- DO NOT USE. I mention thevalueproperty because you shouldn't bind anything to it. Users type in the textbox, the date they settle on will be formatted in the textbox which is assigned to thevalueproperty. In addition...if you supply a validdateattribute to this textbox, it will be formatted for you. Don't go being all clever trying to do things that are already taken care of for you.afterParseFail- OPTIONAL, defaultundefined. Use this argument to bind an action that accepts this component as an argument. This action will be triggered only when the date parsing fails.afterParseSuccess- OPTIONAL, defaultundefined. Use this argument to bind an action that accepts this component as an argument. This action will be triggered only when the date parsing succeeds.beforeParse- OPTIONAL, defaultundefined. Use this argument to bind an action that accepts this component as an argument. This action will be triggered prior to every parsing action.displayFormat- OPTIONAL, DEFAULTLL. Formatting is done using moment.js. The default format of your dates is the localizedLL. You can change this however you want. See the demo.endOfDay?- OPTIONAL, DEFAULTfalse.. When parsing dates, always set them to the last second of the day.future?- OPTIONAL, DEFAULTfalse. Iftrue, ambiguous dates likeSundaywill be parsed asnext Sunday. Note that non-ambiguous dates are not guaranteed to be in the future. Default isfalse.past?- OPTIONAL, DEFAULTfalse. Iftrue, ambiguous dates likeSundaywill be parsed aslast Sunday. Note that non-ambiguous dates are not guaranteed to be in the past. Default isfalse.startOfDay?- OPTIONAL, DEFAULTfalse. When parsing dates, always set them to the start of the day. If set totrue, this will take precedence over theendOfDayproperty.timezone- OPTIONAL, DEFAULTmoment.tz.guess(). Dates will be parsed and formatted in the specified timezone.- All the attributes from
ember-cli-text-support-mixins' {{input-text}}. See https://github.com/cybertoothca/ember-cli-text-support-mixins#arguments - All the standard input attributes that apply to text boxes.
See the Contributing guide for details.
This project is licensed under the MIT License.