Skip to content

date-change callback - distinguish explicit selection #250

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions app/scripts/datePicker.js
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ Module.directive('datePicker', ['datePickerConfig', 'datePickerUtils', function

var nextView = scope.views[scope.views.indexOf(scope.view) + 1];
if ((!nextView || partial) || scope.model) {
setDate(date);
setDate(date, true);
}

if (nextView) {
Expand All @@ -130,18 +130,18 @@ Module.directive('datePicker', ['datePickerConfig', 'datePickerUtils', function
}
};

setDate = function (date) {
setDate = function (date, explicit) {
if (date) {
scope.model = date;
if (ngModel) {
ngModel.$setViewValue(date);
}
}
scope.$emit('setDate', scope.model, scope.view);
scope.$emit('setDate', scope.model, scope.view, explicit);

//This is duplicated in the new functionality.
if (scope.callbackOnSetDate) {
scope.callbackOnSetDate(attrs.datePicker, scope.date);
scope.callbackOnSetDate(attrs.datePicker, scope.date, explicit);
}
};

Expand Down Expand Up @@ -265,7 +265,7 @@ Module.directive('datePicker', ['datePickerConfig', 'datePickerUtils', function
date = clipDate(date);
if (date) {
scope.date = date;
setDate(date);
setDate(date, false);
arrowClick = true;
update();
}
Expand Down
4 changes: 2 additions & 2 deletions app/scripts/input.js
Original file line number Diff line number Diff line change
Expand Up @@ -200,10 +200,10 @@ Module.directive('dateTime', ['$compile', '$document', '$filter', 'dateTimeConfi

//If the picker has already been shown before then we shouldn't be binding to events, as these events are already bound to in this scope.
if (!shownOnce) {
scope.$on('setDate', function (event, date, view) {
scope.$on('setDate', function (event, date, view, explicit) {
updateInput(event);
if (dateChange) {
dateChange(attrs.ngModel, date);
dateChange(attrs.ngModel, date, explicit);
}
if (dismiss && views[views.length - 1] === view) {
clear();
Expand Down