From 81b0c82f8e27e2cd73fce678554d31fc00588e7b Mon Sep 17 00:00:00 2001 From: Coleman Watts Date: Tue, 10 Mar 2015 15:41:11 -0400 Subject: [PATCH] CRM-16019 - Reset mode if user entered an invalid date --- js/angular-crmMailing/directives.js | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/js/angular-crmMailing/directives.js b/js/angular-crmMailing/directives.js index a9977a6a9f..307df6369e 100644 --- a/js/angular-crmMailing/directives.js +++ b/js/angular-crmMailing/directives.js @@ -148,9 +148,18 @@ } }); - element.on('click', ':radio[value=at]', function() { - $('.crm-form-date', element).focus(); - }); + element + // Open datepicker when clicking "At" radio + .on('click', ':radio[value=at]', function() { + $('.crm-form-date', element).focus(); + }) + // Reset mode if user entered an invalid date + .on('change', '.crm-hidden-date', function(e, context) { + if (context === 'userInput' && $(this).val() === '' && $(this).siblings('.crm-form-date').val().length) { + schedule.mode = 'at'; + schedule.datetime = '?'; + } + }); $scope.$watch(attrs.crmMailingRadioDate + '.mode', updateParent); $scope.$watch(attrs.crmMailingRadioDate + '.datetime', function (newValue, oldValue) { -- 2.25.1