g00fy- / angular-datepicker

calendar and datepicker directives for angular
MIT License
719 stars 420 forks source link

date-change callback - distinguish explicit selection #250

Open jharting opened 8 years ago

jharting commented 8 years ago

This change makes it possible for the date-change callback to distinguish between explicit and implicit date changes. An explicit date change happens when a user explicitly select an option (e.g. a given day in the date view). An implicit date change happens e.g. in next()/prev() navigation.

Before this change there is no way to distinguish what exactly the user is doing. This change is useful when an app needs to perform an action when a user selects an option (e.g. a day).

AdamGerthel commented 8 years ago

Why not just make the date picker never change the model unless a date is picked? What is the reasoning behind having the date update when the user is browsing the calendar?

jharting commented 8 years ago

I do not know. It does not make sense to me either. However, given that this behavior is already in place I implemented the change with an additional param so that the change does not break existing users.

dumitru commented 8 years ago

Also will be more "explicit" if in callbackOnSetDate will be passed view. Now in our projects we use this pull request with minor change: scope.callbackOnSetDate(attrs.datePicker, scope.date, explicit && scope.view === 'date'); but I think will be more correctly if in callback function we will have more info about current state of datepicker.