katemihalikova / ion-datetime-picker

Date and/or time picker for awesome Ionic framework
MIT License
169 stars 101 forks source link

Enable/Disable dates. #39

Closed marcochavezf closed 8 years ago

marcochavezf commented 8 years ago

Hi Kate! hope your're fine. At my work we're using your awesome date picker, but we require to disable or enable dates in different ways (by range or after/before certain day). According to our needs I think it will be useful to enable/disable dates by this way:

for example if we need to allow only select days after 2016-04-09, we use: only-valid="{'after': '2016-04-09' }"

or if we need to disable days prior to today we use ('inclusive' will include today's date): only-valid="{'after': 'today', 'inclusive': true }"

of by range: only-valid="{'outside': {'initial': '2016-04-09', 'final': '2016-06-15'}, 'inclusive': true }"

I hope my implementation is ok, any issue/mod please let me know :)

marcochavezf commented 8 years ago

https://github.com/katemihalikova/ion-datetime-picker/issues/1

katemihalikova commented 8 years ago

Hi Marco, thanks for your work, it's amazing!

It has some problems though. Now the day can be changed even by month, year, hours, minutes and seconds buttons. This is not covered by your PR. Furthermore, you are introducing dates in ISO format which is what I wanted to avoid.

For v1 milestone, I'm going to introduce an argument that would be user-supplied function that would validate if any datetime is valid.

katemihalikova commented 8 years ago

If anybody is interested in this feature before it is merged, feel free to add "ion-datetime-picker": "marcochavezf/ion-datetime-picker#dd5164b" to your bower.json.

lumarega commented 8 years ago

I´m interested in this feature. What attributes should I use if my valid date is only within the last 3 months. Can I use as said above only-valid="{'after': '2016-03-20' }"? @katemihalikova

marcochavezf commented 8 years ago

Correct @lumarega, I'm working on the problems @katemihalikova commented. Maybe today I'm gonna push a fixed version (at least when the day is changed by month/year/etc) :)

lumarega commented 8 years ago

ok thanks @marcochavezf :D If its possible please let me know when you have implemented it so I can try it out.

marcochavezf commented 8 years ago

@lumarega @katemihalikova I fixed the problem when the date is changed (by month, year, etc.) to a disabled range. It just set the last or next valid date. Kate which approach could we use to avoid dates in ISO format, sorry but it's not clear for me what another approach we could use :) Cheers!

przemkow commented 8 years ago

@marcochavezf good job! I also need that feature. I wanted even to implement the same thing but if there is already pull request I'm waiting for merge :)

katemihalikova commented 8 years ago

@przemkow Could you please test this? I will merge it then.

przemkow commented 8 years ago

Sure, I'll try to test it today

przemkow commented 8 years ago

for me it looks fine :) @katemihalikova bug you mentioned before is right now well covered, it's impossible to choose disabled date in any way

katemihalikova commented 8 years ago

Thanks! Let's solve the format later for v1.