-
Notifications
You must be signed in to change notification settings - Fork 56
Allow costum value parsing #61
Conversation
This would we be sweet since I've been doing this with an observer onDatePickerValueChanged: Ember.observer('datePickerValue', function() {
}) which isn't the cleanest. |
@soulim any thoughts on this? should i rebase or you wanna discuss/close this PR? |
I'm sorry for delay @lazybensch. Your idea and PR looks great! 👍 Could you please rebase the branch? I'll be happy to merge it as soon as you finish with rebase. Thank you! ❤️ |
d18f02f
to
67b7738
Compare
no worries @soulim. rebased the branch. CI is broken (on master though). |
Thank a lot! Don't worry about CI. It has nothing to your PR. |
Wish you a wonderful day! 😄 |
@lazybensch @soulim: The test ''resets date when input is cleared'' introduced by this PR hasn't ever passed. At least if I |
this.$().val(''); | ||
this.$().trigger('input'); | ||
|
||
assert.equal(this.$().datepicker('getDate'), null, 'value is reset when input is cleared'); |
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 is this test for? It looks like testing bootstrap-datepicker
behavior but not this addon. Shouldn't the expected value be this.get('value')
?
Fixes broken test introduced by #61
This PR is related to #58. we too need the input value for our datepicker to sometimes be something else then a date. But I understand that using the
Date
constructor internally is unreliable. With this PR I simply introduce an API for the user to plug in a custom parser for the date string. This way anyone can decide by him/herself how to process the dates for a particular picker.to solve @maladon's issue, he now could do:
and inside his code:
The responsibility for how to parse is now in user land. If you want to, you could do fancy stuff with
moment.js
or other libraries not available from insidebootstrap-datepicker